aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_aaudio.cpp
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2020-10-30 16:57:26 +0100
committerPaul Adenot <[email protected]>2020-11-02 15:37:29 +0000
commit97ef18c8e8a9d08826ba35b6f263b73eee92f8dc (patch)
tree06ccc9521c7adb80ff1a6edbf64f2996df10a0d5 /src/cubeb_aaudio.cpp
parent9d421b9935b19777e644c814d910813e765e7c80 (diff)
downloadcubeb-97ef18c8e8a9d08826ba35b6f263b73eee92f8dc.tar.gz
cubeb-97ef18c8e8a9d08826ba35b6f263b73eee92f8dc.zip
Implement cubeb_get_preferred_sample_rate for the new AAudio backend.
Diffstat (limited to 'src/cubeb_aaudio.cpp')
-rw-r--r--src/cubeb_aaudio.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
index 183f8e3..d65f86c 100644
--- a/src/cubeb_aaudio.cpp
+++ b/src/cubeb_aaudio.cpp
@@ -1380,6 +1380,24 @@ aaudio_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * laten
return CUBEB_OK;
}
+int
+aaudio_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
+{
+ AAudioStream* stream = init_dummy_stream();
+
+ if (!stream) {
+ return CUBEB_ERROR;
+ }
+
+ *rate = WRAP(AAudioStream_getSampleRate)(stream);
+
+ LOG("aaudio_get_preferred_sample_rate %uHz", *rate);
+
+ destroy_dummy_stream(stream);
+
+ return CUBEB_OK;
+}
+
extern "C" int aaudio_init(cubeb ** context, char const * context_name);
const static struct cubeb_ops aaudio_ops = {
@@ -1387,7 +1405,7 @@ const static struct cubeb_ops aaudio_ops = {
/*.get_backend_id =*/ aaudio_get_backend_id,
/*.get_max_channel_count =*/ aaudio_get_max_channel_count,
/* .get_min_latency =*/ aaudio_get_min_latency,
- /*.get_preferred_sample_rate =*/ NULL,
+ /*.get_preferred_sample_rate =*/ aaudio_get_preferred_sample_rate,
/*.enumerate_devices =*/ NULL,
/*.device_collection_destroy =*/ NULL,
/*.destroy =*/ aaudio_destroy,