diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp index 7711d15..7d725ad 100644 --- a/src/cubeb_aaudio.cpp +++ b/src/cubeb_aaudio.cpp @@ -1134,8 +1134,10 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard & lock) std::unique_ptr sbPtr(sb); WRAP(AAudioStreamBuilder_setErrorCallback)(sb, aaudio_error_cb, stm); + // Capacity should be at least twice the frames-per-callback to allow double + // buffering. WRAP(AAudioStreamBuilder_setBufferCapacityInFrames) - (sb, static_cast(stm->latency_frames)); + (sb, static_cast(3 * stm->latency_frames)); AAudioStream_dataCallback in_data_callback{}; AAudioStream_dataCallback out_data_callback{}; @@ -1188,18 +1190,6 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard & lock) return res_err; } - int32_t output_burst_size = - WRAP(AAudioStream_getFramesPerBurst)(stm->ostream); - LOG("AAudio output burst size: %d", output_burst_size); - // 3 times the burst size seems to be robust. - res = WRAP(AAudioStream_setBufferSizeInFrames)(stm->ostream, - output_burst_size * 3); - if (res < 0) { - LOG("AAudioStream_setBufferSizeInFrames error (ostream): %s", - WRAP(AAudio_convertResultToText)(res)); - // Not fatal - } - int rate = WRAP(AAudioStream_getSampleRate)(stm->ostream); LOG("AAudio output stream sharing mode: %d", WRAP(AAudioStream_getSharingMode)(stm->ostream)); @@ -1252,17 +1242,6 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard & lock) if (stm->voice_input) { stm->input_session_id = WRAP(AAudioStream_getSessionId)(stm->istream); } - int32_t input_burst_size = - WRAP(AAudioStream_getFramesPerBurst)(stm->istream); - LOG("AAudio input burst size: %d", input_burst_size); - // 3 times the burst size seems to be robust. - res = WRAP(AAudioStream_setBufferSizeInFrames)(stm->istream, - input_burst_size * 3); - if (res < AAUDIO_OK) { - LOG("AAudioStream_setBufferSizeInFrames error (istream): %s", - WRAP(AAudio_convertResultToText)(res)); - // Not fatal - } int bcap = WRAP(AAudioStream_getBufferCapacityInFrames)(stm->istream); int rate = WRAP(AAudioStream_getSampleRate)(stm->istream);