aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_aaudio.cpp
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2020-10-29 15:28:22 +0100
committerPaul Adenot <[email protected]>2020-11-02 15:37:29 +0000
commit3fe4d25c047134e395d016d35826b667e5200d30 (patch)
tree2e3b132039d984bffc3e4e4a6c0ec677643157a4 /src/cubeb_aaudio.cpp
parente479f4268d63a183463c438feba1645a38e46049 (diff)
downloadcubeb-3fe4d25c047134e395d016d35826b667e5200d30.tar.gz
cubeb-3fe4d25c047134e395d016d35826b667e5200d30.zip
Make the low-latency/powersave policy choice dynamic, based on latency.
This adds a new file that shares the value between the two non-obsolete android backend.
Diffstat (limited to 'src/cubeb_aaudio.cpp')
-rw-r--r--src/cubeb_aaudio.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
index 27a6752..ca1da93 100644
--- a/src/cubeb_aaudio.cpp
+++ b/src/cubeb_aaudio.cpp
@@ -20,6 +20,7 @@
#include "cubeb-internal.h"
#include "cubeb_resampler.h"
#include "cubeb_log.h"
+#include "cubeb_android.h"
#ifdef DISABLE_LIBAAUDIO_DLOPEN
#define WRAP(x) x
@@ -821,13 +822,13 @@ aaudio_stream_init_impl(
WRAP(AAudioStreamBuilder_setSharingMode)(sb, AAUDIO_SHARING_MODE_EXCLUSIVE);
#endif
-#ifdef CUBEB_AAUDIO_LOW_LATENCY
- LOG("AAudio setting low latency mode for stream");
- WRAP(AAudioStreamBuilder_setPerformanceMode)(sb, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
-#elif defined(CUBEB_AAUDIO_POWER_SAVING)
- LOG("AAudio setting power saving mode for stream");
- WRAP(AAudioStreamBuilder_setPerformanceMode)(sb, AAUDIO_PERFORMANCE_MODE_POWER_SAVING);
-#endif
+ if (latency_frames <= POWERSAVE_LATENCY_FRAMES_THRESHOLD) {
+ LOG("AAudio setting low latency mode for stream");
+ WRAP(AAudioStreamBuilder_setPerformanceMode)(sb, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
+ } else {
+ LOG("AAudio setting power saving mode for stream");
+ WRAP(AAudioStreamBuilder_setPerformanceMode)(sb, AAUDIO_PERFORMANCE_MODE_POWER_SAVING);
+ }
unsigned frame_size;