Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilterAudioStream does not provide Input Preset of the underlying stream in case of fallback #1090

Closed
rpattabi opened this issue Nov 20, 2020 · 2 comments · Fixed by #1094
Closed
Labels
input_preset Bugs related to input presets
Milestone

Comments

@rpattabi
Copy link
Contributor

When a specific InputPreset is specified in Audio Stream Builder, oboe may choose to fallback to a different preset if it's unavailable on a device. For instance, when opening OpenSLES stream, if setting a given preset fails, it falls back to Voice Recognition. Similarly, the recently introduced Voice Performance preset fallsback to Voice Recognition on older devices.

When such fallback happens, FilterAudioStream still has the input preset as provided in the builder, but not the actual one in the underlying stream. This is misleading for the developers to think that the requested input preset is available on the device.

The following code may have to copy input preset as well to address this problem.

// Copy parameters that may not match builder.
mBufferCapacityInFrames = mChildStream->getBufferCapacityInFrames();
mPerformanceMode = mChildStream->getPerformanceMode();

Additionally, the following sections in AudioStreamBuilder.cpp may also need to consider InputPreset as it can also be left kUnspecified:

bool AudioStreamBuilder::isCompatible(AudioStreamBase &other) {
return (getSampleRate() == oboe::Unspecified || getSampleRate() == other.getSampleRate())
&& (getFormat() == (AudioFormat)oboe::Unspecified || getFormat() == other.getFormat())
&& (getFramesPerCallback() == oboe::Unspecified || getFramesPerCallback() == other.getFramesPerCallback())
&& (getChannelCount() == oboe::Unspecified || getChannelCount() == other.getChannelCount());
}

// Build a stream that is as close as possible to the childStream.
if (getFormat() == oboe::AudioFormat::Unspecified) {
parentBuilder.setFormat(tempStream->getFormat());
}
if (getChannelCount() == oboe::Unspecified) {
parentBuilder.setChannelCount(tempStream->getChannelCount());
}
if (getSampleRate() == oboe::Unspecified) {
parentBuilder.setSampleRate(tempStream->getSampleRate());
}
if (getFramesPerCallback() == oboe::Unspecified) {
parentBuilder.setFramesPerCallback(tempStream->getFramesPerCallback());
}

@philburk
Copy link
Collaborator

Thanks! I reproduced this on an S10e running P.

  1. launch OboeTester
  2. tap TEST INPUT
  3. select InPreset = Performance
  4. select SRATE 44100
  5. select SRC Quality "Medium"
  6. tap OPEN

EXPECT
Actual InPreset = VoiceRec

ACTUAL
Actual InPreset = Performance

The same problem occurs with OpenSL ES but for a different reason.

@philburk philburk added this to the v1.5 milestone Nov 20, 2020
philburk added a commit that referenced this issue Nov 20, 2020
The InputPreset can be coerced from VoicePerformance to
VoiceRecognition. But getInputPreset() returned the wrong value.
Fixed for FilterAudioStream and OpenSL ES.

Fixes #1090
@philburk
Copy link
Collaborator

Fixed as you suggested. Thanks.

By the way, isCompatible() does not check InputPreset because the FilterAudioStream does not provide a conversion for that InputPreset. It only converts data rates, formats, channels and callback sizes. So it is OK.

philburk added a commit that referenced this issue Nov 24, 2020
The InputPreset can be coerced from VoicePerformance to
VoiceRecognition. But getInputPreset() returned the wrong value.
Fixed for FilterAudioStream and OpenSL ES.

Fixes #1090
@philburk philburk added the input_preset Bugs related to input presets label Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input_preset Bugs related to input presets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants