зеркало из https://github.com/mozilla/cubeb.git
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.
This commit is contained in:
Родитель
e479f4268d
Коммит
3fe4d25c04
|
@ -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;
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef CUBEB_ANDROID_H
|
||||
#define CUBEB_ANDROID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
// If the latency requested is above this threshold, this stream is considered
|
||||
// intended for playback (vs. real-time). Tell Android it should favor saving
|
||||
// power over performance or latency.
|
||||
// This is around 100ms at 44100 or 48000
|
||||
const uint16_t POWERSAVE_LATENCY_FRAMES_THRESHOLD = 4000;
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // CUBEB_ANDROID_H
|
|
@ -27,6 +27,7 @@
|
|||
#include "cubeb-sles.h"
|
||||
#include "cubeb_array_queue.h"
|
||||
#include "android/cubeb-output-latency.h"
|
||||
#include "cubeb_android.h"
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#ifdef LOG
|
||||
|
@ -65,11 +66,6 @@
|
|||
|
||||
#define DEFAULT_SAMPLE_RATE 48000
|
||||
#define DEFAULT_NUM_OF_FRAMES 480
|
||||
// If the latency requested is above this threshold, this stream is considered
|
||||
// intended for playback (vs. real-time). Tell Android it should favor saving
|
||||
// power over performance or latency.
|
||||
// This is around 100ms at 44100 or 48000
|
||||
#define POWERSAVE_LATENCY_FRAMES_THRESHOLD 4000
|
||||
|
||||
static struct cubeb_ops const opensl_ops;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче