| Index: media/audio/android/opensles_output.cc
|
| diff --git a/media/audio/android/opensles_output.cc b/media/audio/android/opensles_output.cc
|
| index e6062362fad53b13538d52c5031e22e860d7d951..76f6165ecd0de2093f560ac2af5e0ee5b8d1156b 100644
|
| --- a/media/audio/android/opensles_output.cc
|
| +++ b/media/audio/android/opensles_output.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "media/audio/android/opensles_output.h"
|
|
|
| +#include "base/android/build_info.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/time/time.h"
|
| @@ -20,6 +21,26 @@
|
| } \
|
| } while (0)
|
|
|
| +#if !defined(SL_ANDROID_KEY_PERFORMANCE_MODE)
|
| +/** Audio Performance mode key */
|
| +#define SL_ANDROID_KEY_PERFORMANCE_MODE \
|
| + ((const SLchar*)"androidPerformanceMode")
|
| +
|
| +/** Audio performance values */
|
| +/* No specific performance requirement. Allows HW and SW pre/post
|
| + * processing. */
|
| +#define SL_ANDROID_PERFORMANCE_NONE ((SLuint32)0x00000000)
|
| +/* Priority given to latency. No HW or software pre/post processing.
|
| + * This is the default if no performance mode is specified. */
|
| +#define SL_ANDROID_PERFORMANCE_LATENCY ((SLuint32)0x00000001)
|
| +/* Priority given to latency while still allowing HW pre and post
|
| + * processing. */
|
| +#define SL_ANDROID_PERFORMANCE_LATENCY_EFFECTS ((SLuint32)0x00000002)
|
| +/* Priority given to power saving if latency is not a concern.
|
| + * Allows HW and SW pre/post processing. */
|
| +#define SL_ANDROID_PERFORMANCE_POWER_SAVING ((SLuint32)0x00000003)
|
| +#endif
|
| +
|
| namespace media {
|
|
|
| OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager,
|
| @@ -38,6 +59,7 @@ OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager,
|
| muted_(false),
|
| volume_(1.0),
|
| samples_per_second_(params.sample_rate()),
|
| + use_high_latency_(params.latency_tag() == AudioLatency::LATENCY_PLAYBACK),
|
| delay_calculator_(samples_per_second_) {
|
| DVLOG(2) << "OpenSLESOutputStream::OpenSLESOutputStream("
|
| << "stream_type=" << stream_type << ")";
|
| @@ -50,6 +72,11 @@ OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager,
|
| format_.endianness = SL_BYTEORDER_LITTLEENDIAN;
|
| format_.channelMask = ChannelCountToSLESChannelMask(params.channels());
|
| audio_bus_ = AudioBus::Create(params);
|
| +
|
| + if (use_high_latency_) {
|
| + LOG(ERROR) << "Enabling high latency audio with buffer size: "
|
| + << params.frames_per_buffer();
|
| + }
|
| }
|
|
|
| OpenSLESOutputStream::~OpenSLESOutputStream() {
|
| @@ -272,12 +299,22 @@ bool OpenSLESOutputStream::CreatePlayer() {
|
|
|
| // Set configuration using the stream type provided at construction.
|
| LOG_ON_FAILURE_AND_RETURN(
|
| - (*player_config)->SetConfiguration(player_config,
|
| - SL_ANDROID_KEY_STREAM_TYPE,
|
| - &stream_type_,
|
| - sizeof(SLint32)),
|
| + (*player_config)
|
| + ->SetConfiguration(player_config, SL_ANDROID_KEY_STREAM_TYPE,
|
| + &stream_type_, sizeof(SLint32)),
|
| false);
|
|
|
| + // Set configuration using the stream type provided at construction.
|
| + if (use_high_latency_ && base::android::BuildInfo::GetInstance()->sdk_int() >=
|
| + base::android::SDK_VERSION_NOUGAT) {
|
| + SLuint32 perf_mode = SL_ANDROID_PERFORMANCE_POWER_SAVING;
|
| + LOG_ON_FAILURE_AND_RETURN(
|
| + (*player_config)
|
| + ->SetConfiguration(player_config, SL_ANDROID_KEY_PERFORMANCE_MODE,
|
| + &perf_mode, sizeof(SLuint32)),
|
| + false);
|
| + }
|
| +
|
| // Realize the player object in synchronous mode.
|
| LOG_ON_FAILURE_AND_RETURN(
|
| player_object_->Realize(player_object_.Get(), SL_BOOLEAN_FALSE), false);
|
|
|