aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_aaudio.cpp
diff options
context:
space:
mode:
authorAndreas Pehrson <[email protected]>2024-06-27 12:04:24 +0200
committerAndreas Pehrson <[email protected]>2024-07-01 12:18:39 +0200
commit5d5008d25cef5237711b500f7d8a8653942530f1 (patch)
tree588c98b7a4ea61f02eec1065d772ebccba9a68e0 /src/cubeb_aaudio.cpp
parent42cf7061fcea5fd6178d6affe27da4a388346bda (diff)
downloadcubeb-5d5008d25cef5237711b500f7d8a8653942530f1.tar.gz
cubeb-5d5008d25cef5237711b500f7d8a8653942530f1.zip
Set buffer capacity to allow for buffering
Diffstat (limited to 'src/cubeb_aaudio.cpp')
-rw-r--r--src/cubeb_aaudio.cpp34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
index 9e81ed3..5f38c43 100644
--- a/src/cubeb_aaudio.cpp
+++ b/src/cubeb_aaudio.cpp
@@ -50,7 +50,6 @@ using namespace std;
X(AAudioStream_read) \
X(AAudioStream_requestStart) \
X(AAudioStream_requestPause) \
- X(AAudioStream_setBufferSizeInFrames) \
X(AAudioStream_getTimestamp) \
X(AAudioStream_requestFlush) \
X(AAudioStream_requestStop) \
@@ -68,8 +67,8 @@ using namespace std;
X(AAudioStreamBuilder_setUsage) \
X(AAudioStreamBuilder_setFramesPerDataCallback)
-// not needed or added later on
-// X(AAudioStreamBuilder_setDeviceId) \
+// not needed or added later on \
+ // X(AAudioStreamBuilder_setDeviceId) \
// X(AAudioStreamBuilder_setSamplesPerFrame) \
// X(AAudioStream_getSamplesPerFrame) \
// X(AAudioStream_getDeviceId) \
@@ -84,6 +83,7 @@ using namespace std;
// X(AAudioStream_getContentType) \
// X(AAudioStream_getInputPreset) \
// X(AAudioStream_getSessionId) \
+ // X(AAudioStream_setBufferSizeInFrames) \
// END: not needed or added later on
#define MAKE_TYPEDEF(x) static decltype(x) * cubeb_##x;
@@ -1095,8 +1095,10 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard<mutex> & lock)
std::unique_ptr<AAudioStreamBuilder, StreamBuilderDestructor> 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<int32_t>(stm->latency_frames));
+ (sb, static_cast<int32_t>(3 * stm->latency_frames));
AAudioStream_dataCallback in_data_callback{};
AAudioStream_dataCallback out_data_callback{};
@@ -1149,18 +1151,6 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard<mutex> & 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));
@@ -1204,18 +1194,6 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard<mutex> & lock)
return res_err;
}
- 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);
LOG("AAudio input stream sharing mode: %d",