Audio input stream starts, but always fails to read with AAUDIO_ERROR_INVALID_STATE
#1451
Answered
by
philburk
CatalinVoss
asked this question in
Q&A
Replies: 2 comments 1 reply
-
You opened the stream with a callback. So you do not need to read it. The
data is already passed to you in the audioData buffer.
…On Mon, Nov 22, 2021, 6:37 PM Catalin Voss ***@***.***> wrote:
I'm opening a vanilla input stream like so:
void SpeechService::setup_stream() {
oboe::AudioStreamBuilder builder;
builder.setDirection(oboe::Direction::Input);
builder.setPerformanceMode(oboe::PerformanceMode::LowLatency);
builder.setChannelCount(1);
builder.setChannelConversionAllowed(true);
builder.setFormat(oboe::AudioFormat::I16);
builder.setSampleRate(kSampleRate);
builder.setCallback(this);
oboe::Result result = builder.openStream(input_stream);
if (result != oboe::Result::OK){
LOGE("Error opening audio stream: %d", (result));
} else {
LOGI("Successfully set up native oboe stream");
}
}
After opening it, I can verify that the stream is in "started" state. I
have audio recording permission.
Then my callback follows the sample code:
oboe::DataCallbackResult SpeechService::onAudioReady(oboe::AudioStream *oboe_stream,
void *audio_data,
int32_t num_frames) {
const int64_t timeout_nanos = 0; // for a non-blocking read
auto result = input_stream->read(audio_data, num_frames, timeout_nanos);
...
}
This gets called with a small number of frames -- 320 or 192 or so.
However, the read call always fails with the error ErrorInvalidState =
-895, // AAUDIO_ERROR_INVALID_STATE.
Any idea how I should approach debugging this?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1451>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHPU2MDVY7DLQ5KCTYHPS3UNL44ZANCNFSM5ISOKUMA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
CatalinVoss
-
We should update the docs to make it more clear. That code is "reading" from a renderer into a buffer that is provided by the callback. Maybe we should just write some white noise into the buffer to make it more clear That's the easiest thing to do in a couple lines of code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm on Android target SDK 28, NDK version 21.4.7075529, oboe 1.6.1 linked via the out-of-the-box
find_package
setup.I'm opening a vanilla input stream like so:
After opening it, I can verify that the stream is in "started" state. I have audio recording permission.
Then my callback follows the sample code:
This gets called with a small number of frames -- 320 or 192 or so. However, the read call always fails with the error
ErrorInvalidState = -895, // AAUDIO_ERROR_INVALID_STATE
.Any idea how I should approach debugging this?
Update 1: On another device, the same code crashes on the read line with error
Update 2: If I call
builder.setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Medium)
on the builder, the crash goes away and result returns OK, butresult.value()
in the read callback is always 0.Beta Was this translation helpful? Give feedback.
All reactions