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

"processAudioBuffer(666): Error -61 obtaining an audio buffer, giving up." from AudioRecord, in Android 13 #2124

Open
amos-yau opened this issue Dec 6, 2024 · 6 comments
Assignees

Comments

@amos-yau
Copy link

amos-yau commented Dec 6, 2024

Sorry I may have missing something, so this would be a question rather than a bug:

  1. My app has 2 streams, recording and playback
  2. They run simultaneously and using individual onAudioReady callback
  3. For Android 13 the recording stream run smoothly with start and stop repeatedly
  4. But after the playback stream ever started, then call recording stream requestStart(), the title error message is shown
  5. But the same code logic works fine in another device which is Android 8, so I doubt this is Android compatibility issue?
  6. Asked in GPT but no luck, see if someone could help, thanks a lot!
@amos-yau amos-yau changed the title "processAudioBuffer(666): Error -61 obtaining an audio buffer, giving up." in Android 13 "processAudioBuffer(666): Error -61 obtaining an audio buffer, giving up." from AudioRecord, in Android 13 Dec 6, 2024
@amos-yau
Copy link
Author

amos-yau commented Dec 6, 2024

Supplements:

  1. Checked the 2 streams onAudioReady run on different thread
  2. Checked the Android 8 is using OpenSLES, which Android 13 is using AAudio

After forcing Android 13 to using OpenSLES, the behaviour resume the same as Android 8 works smoothly, why?
recordingStream.setAudioApi(oboe::AudioApi::OpenSLES);

But the code document said this is deprecated in Android 13 and above, so I bet it's not the best solution, anyone encountered the similar thing would give some tips? Thanks in advance!

@philburk
Copy link
Collaborator

philburk commented Dec 8, 2024

They run simultaneously and using individual onAudioReady callback

Are the two streams related? In other words is the output a processed version of the input?
If so then you should try using the FullDuplexStream object.
See the LiveEffect app for an example.

processAudioBuffer(666): Error -61 obtaining an audio buffer, giving up.

That error messages comes from frameworks/av/media/libaudioclient/AudioRecord.cpp
in the processAudioBuffer() method.

After forcing Android 13 to using OpenSLES, the behaviour resume the same as Android 8 works smoothly, why?

Yes, OpenSL ES is deprecated. It is OK to use it on older devices. But it is no longer actively supported.

We would need more information to help diagnose the problem.
Please provide the settings for the input and output streams.
A few short logs would also help.

Also what devices is this on?

@amos-yau
Copy link
Author

amos-yau commented Dec 16, 2024

Thanks @philburk for your reply, here are some supplements:

Are the two streams related? In other words is the output a processed version of the input?

Nope they're unrelated, this is a communication mobile app, one stream for recording voice, another one for playing incoming voice.

Please provide the settings for the input and output streams.

For playing:

oboe::AudioStreamBuilder outputBuilder;
    outputBuilder.setAudioApi(oboe::AudioApi::OpenSLES);
    outputBuilder.setFormat(oboe::AudioFormat::I16);
    outputBuilder.setPerformanceMode(oboe::PerformanceMode::LowLatency);
    outputBuilder.setDirection(oboe::Direction::Output);
    outputBuilder.setSampleRate(sampleRate);
    outputBuilder.setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Best);
    outputBuilder.setChannelCount(oboe::ChannelCount::Stereo);
    outputBuilder.setSharingMode(oboe::SharingMode::Shared);
    outputBuilder.setDataCallback(this);

For recording:

oboe::AudioStreamBuilder inputBuilder;
    inputBuilder.setAudioApi(oboe::AudioApi::OpenSLES);
    inputBuilder.setFormat(oboe::AudioFormat::I16);
    inputBuilder.setPerformanceMode(oboe::PerformanceMode::LowLatency);
    inputBuilder.setDirection(oboe::Direction::Input);
    inputBuilder.setSampleRate(sampleRate);
    inputBuilder.setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Best);
    inputBuilder.setChannelCount(oboe::ChannelCount::Stereo);
    inputBuilder.setSharingMode(oboe::SharingMode::Shared);
    inputBuilder.setDataCallback(this);

Also what devices is this on?

This is realme note 50, Android 13

@philburk
Copy link
Collaborator

philburk commented Dec 16, 2024

@amos-yau - Thanks for the additional info.

Does this happen on Android 14 or 15?

Can you capture some of the logcat right before the processAudioBuffer() error? Maybe 100 lines?
Please attach it as a file and not in a comment.

outputBuilder.setDataCallback(this);
inputBuilder.setDataCallback(this);

Are the two callbacks with "this" using different objects?

@philburk
Copy link
Collaborator

Do you have the same error on different phones or just the Realme Note 50?

https://www.gsmarena.com/realme_note_50-12799.php

It is runnng a UniSOC Tiger T612

Is the failure intermittent or does it always happen?

@amos-yau
Copy link
Author

amos-yau commented Jan 7, 2025

Sorry for the late reply in the year end holiday season, currently I'm using the OpenSLES as a quick fix interim solution, will get back and dig into this issue after the current feature released, kindly keep this thread open, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants