blob: 513f8233f855e050152a2a36189df82036be7282 [file] [log] [blame]
henrikab2619892015-05-18 16:49:16 +02001/*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/modules/audio_device/android/opensles_player.h"
12
13#include <android/log.h>
14
kwiberg529662a2017-09-04 05:43:17 -070015#include "webrtc/api/array_view.h"
henrika521f7a82016-05-31 07:03:17 -070016#include "webrtc/modules/audio_device/android/audio_common.h"
henrikab2619892015-05-18 16:49:16 +020017#include "webrtc/modules/audio_device/android/audio_manager.h"
henrika86d907c2015-09-07 16:09:50 +020018#include "webrtc/modules/audio_device/fine_audio_buffer.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020019#include "webrtc/rtc_base/arraysize.h"
20#include "webrtc/rtc_base/checks.h"
21#include "webrtc/rtc_base/format_macros.h"
22#include "webrtc/rtc_base/timeutils.h"
henrikab2619892015-05-18 16:49:16 +020023
24#define TAG "OpenSLESPlayer"
25#define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
26#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
27#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
28#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
29#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
30
henrika521f7a82016-05-31 07:03:17 -070031#define RETURN_ON_ERROR(op, ...) \
32 do { \
33 SLresult err = (op); \
34 if (err != SL_RESULT_SUCCESS) { \
35 ALOGE("%s failed: %s", #op, GetSLErrorString(err)); \
36 return __VA_ARGS__; \
37 } \
henrikab2619892015-05-18 16:49:16 +020038 } while (0)
39
40namespace webrtc {
41
42OpenSLESPlayer::OpenSLESPlayer(AudioManager* audio_manager)
henrika521f7a82016-05-31 07:03:17 -070043 : audio_manager_(audio_manager),
44 audio_parameters_(audio_manager->GetPlayoutAudioParameters()),
45 audio_device_buffer_(nullptr),
henrikab2619892015-05-18 16:49:16 +020046 initialized_(false),
47 playing_(false),
henrikab2619892015-05-18 16:49:16 +020048 buffer_index_(0),
49 engine_(nullptr),
50 player_(nullptr),
51 simple_buffer_queue_(nullptr),
henrikae71b24e2015-11-12 01:48:32 -080052 volume_(nullptr),
53 last_play_time_(0) {
henrikab2619892015-05-18 16:49:16 +020054 ALOGD("ctor%s", GetThreadInfo().c_str());
55 // Use native audio output parameters provided by the audio manager and
56 // define the PCM format structure.
57 pcm_format_ = CreatePCMConfiguration(audio_parameters_.channels(),
58 audio_parameters_.sample_rate(),
59 audio_parameters_.bits_per_sample());
60 // Detach from this thread since we want to use the checker to verify calls
61 // from the internal audio thread.
62 thread_checker_opensles_.DetachFromThread();
63}
64
65OpenSLESPlayer::~OpenSLESPlayer() {
66 ALOGD("dtor%s", GetThreadInfo().c_str());
henrikg91d6ede2015-09-17 00:24:34 -070067 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +020068 Terminate();
69 DestroyAudioPlayer();
70 DestroyMix();
henrika521f7a82016-05-31 07:03:17 -070071 engine_ = nullptr;
henrikg91d6ede2015-09-17 00:24:34 -070072 RTC_DCHECK(!engine_);
73 RTC_DCHECK(!output_mix_.Get());
74 RTC_DCHECK(!player_);
75 RTC_DCHECK(!simple_buffer_queue_);
76 RTC_DCHECK(!volume_);
henrikab2619892015-05-18 16:49:16 +020077}
78
79int OpenSLESPlayer::Init() {
80 ALOGD("Init%s", GetThreadInfo().c_str());
henrikg91d6ede2015-09-17 00:24:34 -070081 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +020082 return 0;
83}
84
85int OpenSLESPlayer::Terminate() {
86 ALOGD("Terminate%s", GetThreadInfo().c_str());
henrikg91d6ede2015-09-17 00:24:34 -070087 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +020088 StopPlayout();
89 return 0;
90}
91
92int OpenSLESPlayer::InitPlayout() {
93 ALOGD("InitPlayout%s", GetThreadInfo().c_str());
henrikg91d6ede2015-09-17 00:24:34 -070094 RTC_DCHECK(thread_checker_.CalledOnValidThread());
95 RTC_DCHECK(!initialized_);
96 RTC_DCHECK(!playing_);
henrika918b5542016-09-19 15:44:09 +020097 if (!ObtainEngineInterface()) {
98 ALOGE("Failed to obtain SL Engine interface");
99 return -1;
100 }
henrikab2619892015-05-18 16:49:16 +0200101 CreateMix();
102 initialized_ = true;
103 buffer_index_ = 0;
104 return 0;
105}
106
107int OpenSLESPlayer::StartPlayout() {
108 ALOGD("StartPlayout%s", GetThreadInfo().c_str());
henrikg91d6ede2015-09-17 00:24:34 -0700109 RTC_DCHECK(thread_checker_.CalledOnValidThread());
110 RTC_DCHECK(initialized_);
111 RTC_DCHECK(!playing_);
henrika918b5542016-09-19 15:44:09 +0200112 if (fine_audio_buffer_) {
113 fine_audio_buffer_->ResetPlayout();
114 }
henrikab2619892015-05-18 16:49:16 +0200115 // The number of lower latency audio players is limited, hence we create the
116 // audio player in Start() and destroy it in Stop().
117 CreateAudioPlayer();
118 // Fill up audio buffers to avoid initial glitch and to ensure that playback
119 // starts when mode is later changed to SL_PLAYSTATE_PLAYING.
120 // TODO(henrika): we can save some delay by only making one call to
121 // EnqueuePlayoutData. Most likely not worth the risk of adding a glitch.
henrika918b5542016-09-19 15:44:09 +0200122 last_play_time_ = rtc::Time();
henrikab2619892015-05-18 16:49:16 +0200123 for (int i = 0; i < kNumOfOpenSLESBuffers; ++i) {
henrika14acf652016-10-11 06:15:41 -0700124 EnqueuePlayoutData(true);
henrikab2619892015-05-18 16:49:16 +0200125 }
126 // Start streaming data by setting the play state to SL_PLAYSTATE_PLAYING.
127 // For a player object, when the object is in the SL_PLAYSTATE_PLAYING
128 // state, adding buffers will implicitly start playback.
129 RETURN_ON_ERROR((*player_)->SetPlayState(player_, SL_PLAYSTATE_PLAYING), -1);
130 playing_ = (GetPlayState() == SL_PLAYSTATE_PLAYING);
henrikg91d6ede2015-09-17 00:24:34 -0700131 RTC_DCHECK(playing_);
henrikab2619892015-05-18 16:49:16 +0200132 return 0;
133}
134
135int OpenSLESPlayer::StopPlayout() {
136 ALOGD("StopPlayout%s", GetThreadInfo().c_str());
henrikg91d6ede2015-09-17 00:24:34 -0700137 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +0200138 if (!initialized_ || !playing_) {
139 return 0;
140 }
141 // Stop playing by setting the play state to SL_PLAYSTATE_STOPPED.
142 RETURN_ON_ERROR((*player_)->SetPlayState(player_, SL_PLAYSTATE_STOPPED), -1);
143 // Clear the buffer queue to flush out any remaining data.
144 RETURN_ON_ERROR((*simple_buffer_queue_)->Clear(simple_buffer_queue_), -1);
kwiberg5377bc72016-10-04 13:46:56 -0700145#if RTC_DCHECK_IS_ON
henrikab2619892015-05-18 16:49:16 +0200146 // Verify that the buffer queue is in fact cleared as it should.
147 SLAndroidSimpleBufferQueueState buffer_queue_state;
148 (*simple_buffer_queue_)->GetState(simple_buffer_queue_, &buffer_queue_state);
kwibergaf476c72016-11-28 15:21:39 -0800149 RTC_DCHECK_EQ(0, buffer_queue_state.count);
150 RTC_DCHECK_EQ(0, buffer_queue_state.index);
henrikab2619892015-05-18 16:49:16 +0200151#endif
152 // The number of lower latency audio players is limited, hence we create the
153 // audio player in Start() and destroy it in Stop().
154 DestroyAudioPlayer();
155 thread_checker_opensles_.DetachFromThread();
156 initialized_ = false;
157 playing_ = false;
158 return 0;
159}
160
161int OpenSLESPlayer::SpeakerVolumeIsAvailable(bool& available) {
162 available = false;
163 return 0;
164}
165
166int OpenSLESPlayer::MaxSpeakerVolume(uint32_t& maxVolume) const {
167 return -1;
168}
169
170int OpenSLESPlayer::MinSpeakerVolume(uint32_t& minVolume) const {
171 return -1;
172}
173
174int OpenSLESPlayer::SetSpeakerVolume(uint32_t volume) {
175 return -1;
176}
177
178int OpenSLESPlayer::SpeakerVolume(uint32_t& volume) const {
179 return -1;
180}
181
182void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
183 ALOGD("AttachAudioBuffer");
henrikg91d6ede2015-09-17 00:24:34 -0700184 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +0200185 audio_device_buffer_ = audioBuffer;
186 const int sample_rate_hz = audio_parameters_.sample_rate();
187 ALOGD("SetPlayoutSampleRate(%d)", sample_rate_hz);
188 audio_device_buffer_->SetPlayoutSampleRate(sample_rate_hz);
Peter Kasting69558702016-01-12 16:26:35 -0800189 const size_t channels = audio_parameters_.channels();
190 ALOGD("SetPlayoutChannels(%" PRIuS ")", channels);
henrikab2619892015-05-18 16:49:16 +0200191 audio_device_buffer_->SetPlayoutChannels(channels);
henrikg91d6ede2015-09-17 00:24:34 -0700192 RTC_CHECK(audio_device_buffer_);
henrikab2619892015-05-18 16:49:16 +0200193 AllocateDataBuffers();
194}
195
henrikab2619892015-05-18 16:49:16 +0200196void OpenSLESPlayer::AllocateDataBuffers() {
197 ALOGD("AllocateDataBuffers");
henrikg91d6ede2015-09-17 00:24:34 -0700198 RTC_DCHECK(thread_checker_.CalledOnValidThread());
199 RTC_DCHECK(!simple_buffer_queue_);
200 RTC_CHECK(audio_device_buffer_);
henrikab2619892015-05-18 16:49:16 +0200201 // Create a modified audio buffer class which allows us to ask for any number
202 // of samples (and not only multiple of 10ms) to match the native OpenSL ES
henrika918b5542016-09-19 15:44:09 +0200203 // buffer size. The native buffer size corresponds to the
204 // PROPERTY_OUTPUT_FRAMES_PER_BUFFER property which is the number of audio
205 // frames that the HAL (Hardware Abstraction Layer) buffer can hold. It is
206 // recommended to construct audio buffers so that they contain an exact
207 // multiple of this number. If so, callbacks will occur at regular intervals,
208 // which reduces jitter.
henrikab3ebc1a2017-02-27 05:14:17 -0800209 const size_t buffer_size_in_bytes = audio_parameters_.GetBytesPerBuffer();
210 ALOGD("native buffer size: %" PRIuS, buffer_size_in_bytes);
henrika918b5542016-09-19 15:44:09 +0200211 ALOGD("native buffer size in ms: %.2f",
212 audio_parameters_.GetBufferSizeInMilliseconds());
henrikabb6f7522017-05-30 02:01:30 -0700213 fine_audio_buffer_.reset(new FineAudioBuffer(audio_device_buffer_,
214 audio_parameters_.sample_rate(),
215 2 * buffer_size_in_bytes));
henrikab3ebc1a2017-02-27 05:14:17 -0800216 // Allocated memory for audio buffers.
henrikab2619892015-05-18 16:49:16 +0200217 for (int i = 0; i < kNumOfOpenSLESBuffers; ++i) {
henrikab3ebc1a2017-02-27 05:14:17 -0800218 audio_buffers_[i].reset(new SLint8[buffer_size_in_bytes]);
henrikab2619892015-05-18 16:49:16 +0200219 }
220}
221
henrika521f7a82016-05-31 07:03:17 -0700222bool OpenSLESPlayer::ObtainEngineInterface() {
223 ALOGD("ObtainEngineInterface");
henrikg91d6ede2015-09-17 00:24:34 -0700224 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrika918b5542016-09-19 15:44:09 +0200225 if (engine_)
226 return true;
henrika521f7a82016-05-31 07:03:17 -0700227 // Get access to (or create if not already existing) the global OpenSL Engine
228 // object.
229 SLObjectItf engine_object = audio_manager_->GetOpenSLEngine();
230 if (engine_object == nullptr) {
231 ALOGE("Failed to access the global OpenSL engine");
232 return false;
233 }
234 // Get the SL Engine Interface which is implicit.
henrikab2619892015-05-18 16:49:16 +0200235 RETURN_ON_ERROR(
henrika521f7a82016-05-31 07:03:17 -0700236 (*engine_object)->GetInterface(engine_object, SL_IID_ENGINE, &engine_),
henrikab2619892015-05-18 16:49:16 +0200237 false);
henrikab2619892015-05-18 16:49:16 +0200238 return true;
239}
240
henrikab2619892015-05-18 16:49:16 +0200241bool OpenSLESPlayer::CreateMix() {
242 ALOGD("CreateMix");
henrikg91d6ede2015-09-17 00:24:34 -0700243 RTC_DCHECK(thread_checker_.CalledOnValidThread());
244 RTC_DCHECK(engine_);
henrikab2619892015-05-18 16:49:16 +0200245 if (output_mix_.Get())
246 return true;
247
248 // Create the ouput mix on the engine object. No interfaces will be used.
249 RETURN_ON_ERROR((*engine_)->CreateOutputMix(engine_, output_mix_.Receive(), 0,
henrika521f7a82016-05-31 07:03:17 -0700250 nullptr, nullptr),
henrikab2619892015-05-18 16:49:16 +0200251 false);
252 RETURN_ON_ERROR(output_mix_->Realize(output_mix_.Get(), SL_BOOLEAN_FALSE),
253 false);
254 return true;
255}
256
257void OpenSLESPlayer::DestroyMix() {
258 ALOGD("DestroyMix");
henrikg91d6ede2015-09-17 00:24:34 -0700259 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +0200260 if (!output_mix_.Get())
261 return;
262 output_mix_.Reset();
263}
264
265bool OpenSLESPlayer::CreateAudioPlayer() {
266 ALOGD("CreateAudioPlayer");
henrikg91d6ede2015-09-17 00:24:34 -0700267 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikg91d6ede2015-09-17 00:24:34 -0700268 RTC_DCHECK(output_mix_.Get());
henrikab2619892015-05-18 16:49:16 +0200269 if (player_object_.Get())
270 return true;
henrikg91d6ede2015-09-17 00:24:34 -0700271 RTC_DCHECK(!player_);
272 RTC_DCHECK(!simple_buffer_queue_);
273 RTC_DCHECK(!volume_);
henrikab2619892015-05-18 16:49:16 +0200274
275 // source: Android Simple Buffer Queue Data Locator is source.
276 SLDataLocator_AndroidSimpleBufferQueue simple_buffer_queue = {
277 SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
278 static_cast<SLuint32>(kNumOfOpenSLESBuffers)};
279 SLDataSource audio_source = {&simple_buffer_queue, &pcm_format_};
280
281 // sink: OutputMix-based data is sink.
282 SLDataLocator_OutputMix locator_output_mix = {SL_DATALOCATOR_OUTPUTMIX,
283 output_mix_.Get()};
henrika521f7a82016-05-31 07:03:17 -0700284 SLDataSink audio_sink = {&locator_output_mix, nullptr};
henrikab2619892015-05-18 16:49:16 +0200285
286 // Define interfaces that we indend to use and realize.
287 const SLInterfaceID interface_ids[] = {
288 SL_IID_ANDROIDCONFIGURATION, SL_IID_BUFFERQUEUE, SL_IID_VOLUME};
289 const SLboolean interface_required[] = {
290 SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
291
292 // Create the audio player on the engine interface.
293 RETURN_ON_ERROR(
294 (*engine_)->CreateAudioPlayer(
295 engine_, player_object_.Receive(), &audio_source, &audio_sink,
296 arraysize(interface_ids), interface_ids, interface_required),
297 false);
298
299 // Use the Android configuration interface to set platform-specific
300 // parameters. Should be done before player is realized.
301 SLAndroidConfigurationItf player_config;
302 RETURN_ON_ERROR(
303 player_object_->GetInterface(player_object_.Get(),
304 SL_IID_ANDROIDCONFIGURATION, &player_config),
305 false);
306 // Set audio player configuration to SL_ANDROID_STREAM_VOICE which
307 // corresponds to android.media.AudioManager.STREAM_VOICE_CALL.
henrika1ba936a2015-11-03 04:27:58 -0800308 SLint32 stream_type = SL_ANDROID_STREAM_VOICE;
henrikab2619892015-05-18 16:49:16 +0200309 RETURN_ON_ERROR(
310 (*player_config)
311 ->SetConfiguration(player_config, SL_ANDROID_KEY_STREAM_TYPE,
312 &stream_type, sizeof(SLint32)),
313 false);
314
315 // Realize the audio player object after configuration has been set.
316 RETURN_ON_ERROR(
317 player_object_->Realize(player_object_.Get(), SL_BOOLEAN_FALSE), false);
318
319 // Get the SLPlayItf interface on the audio player.
320 RETURN_ON_ERROR(
321 player_object_->GetInterface(player_object_.Get(), SL_IID_PLAY, &player_),
322 false);
323
324 // Get the SLAndroidSimpleBufferQueueItf interface on the audio player.
325 RETURN_ON_ERROR(
326 player_object_->GetInterface(player_object_.Get(), SL_IID_BUFFERQUEUE,
327 &simple_buffer_queue_),
328 false);
329
330 // Register callback method for the Android Simple Buffer Queue interface.
331 // This method will be called when the native audio layer needs audio data.
332 RETURN_ON_ERROR((*simple_buffer_queue_)
333 ->RegisterCallback(simple_buffer_queue_,
334 SimpleBufferQueueCallback, this),
335 false);
336
337 // Get the SLVolumeItf interface on the audio player.
338 RETURN_ON_ERROR(player_object_->GetInterface(player_object_.Get(),
339 SL_IID_VOLUME, &volume_),
340 false);
341
342 // TODO(henrika): might not be required to set volume to max here since it
343 // seems to be default on most devices. Might be required for unit tests.
344 // RETURN_ON_ERROR((*volume_)->SetVolumeLevel(volume_, 0), false);
345
346 return true;
347}
348
349void OpenSLESPlayer::DestroyAudioPlayer() {
350 ALOGD("DestroyAudioPlayer");
henrikg91d6ede2015-09-17 00:24:34 -0700351 RTC_DCHECK(thread_checker_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +0200352 if (!player_object_.Get())
353 return;
henrika918b5542016-09-19 15:44:09 +0200354 (*simple_buffer_queue_)
355 ->RegisterCallback(simple_buffer_queue_, nullptr, nullptr);
henrikab2619892015-05-18 16:49:16 +0200356 player_object_.Reset();
357 player_ = nullptr;
358 simple_buffer_queue_ = nullptr;
359 volume_ = nullptr;
360}
361
362// static
363void OpenSLESPlayer::SimpleBufferQueueCallback(
364 SLAndroidSimpleBufferQueueItf caller,
365 void* context) {
366 OpenSLESPlayer* stream = reinterpret_cast<OpenSLESPlayer*>(context);
367 stream->FillBufferQueue();
368}
369
370void OpenSLESPlayer::FillBufferQueue() {
henrikg91d6ede2015-09-17 00:24:34 -0700371 RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread());
henrikab2619892015-05-18 16:49:16 +0200372 SLuint32 state = GetPlayState();
373 if (state != SL_PLAYSTATE_PLAYING) {
374 ALOGW("Buffer callback in non-playing state!");
375 return;
376 }
henrika14acf652016-10-11 06:15:41 -0700377 EnqueuePlayoutData(false);
henrikab2619892015-05-18 16:49:16 +0200378}
379
henrika14acf652016-10-11 06:15:41 -0700380void OpenSLESPlayer::EnqueuePlayoutData(bool silence) {
henrikae71b24e2015-11-12 01:48:32 -0800381 // Check delta time between two successive callbacks and provide a warning
382 // if it becomes very large.
henrika918b5542016-09-19 15:44:09 +0200383 // TODO(henrika): using 150ms as upper limit but this value is rather random.
henrikae71b24e2015-11-12 01:48:32 -0800384 const uint32_t current_time = rtc::Time();
385 const uint32_t diff = current_time - last_play_time_;
henrika918b5542016-09-19 15:44:09 +0200386 if (diff > 150) {
henrikae71b24e2015-11-12 01:48:32 -0800387 ALOGW("Bad OpenSL ES playout timing, dT=%u [ms]", diff);
388 }
389 last_play_time_ = current_time;
henrikab2619892015-05-18 16:49:16 +0200390 SLint8* audio_ptr = audio_buffers_[buffer_index_].get();
henrika14acf652016-10-11 06:15:41 -0700391 if (silence) {
392 RTC_DCHECK(thread_checker_.CalledOnValidThread());
393 // Avoid aquiring real audio data from WebRTC and fill the buffer with
394 // zeros instead. Used to prime the buffer with silence and to avoid asking
395 // for audio data from two different threads.
396 memset(audio_ptr, 0, audio_parameters_.GetBytesPerBuffer());
397 } else {
398 RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread());
399 // Read audio data from the WebRTC source using the FineAudioBuffer object
400 // to adjust for differences in buffer size between WebRTC (10ms) and native
401 // OpenSL ES.
henrikabb6f7522017-05-30 02:01:30 -0700402 fine_audio_buffer_->GetPlayoutData(rtc::ArrayView<SLint8>(
403 audio_ptr, audio_parameters_.GetBytesPerBuffer()));
henrika14acf652016-10-11 06:15:41 -0700404 }
henrikab2619892015-05-18 16:49:16 +0200405 // Enqueue the decoded audio buffer for playback.
henrika918b5542016-09-19 15:44:09 +0200406 SLresult err = (*simple_buffer_queue_)
407 ->Enqueue(simple_buffer_queue_, audio_ptr,
408 audio_parameters_.GetBytesPerBuffer());
henrikab2619892015-05-18 16:49:16 +0200409 if (SL_RESULT_SUCCESS != err) {
410 ALOGE("Enqueue failed: %d", err);
411 }
412 buffer_index_ = (buffer_index_ + 1) % kNumOfOpenSLESBuffers;
413}
414
415SLuint32 OpenSLESPlayer::GetPlayState() const {
henrikg91d6ede2015-09-17 00:24:34 -0700416 RTC_DCHECK(player_);
henrikab2619892015-05-18 16:49:16 +0200417 SLuint32 state;
418 SLresult err = (*player_)->GetPlayState(player_, &state);
419 if (SL_RESULT_SUCCESS != err) {
420 ALOGE("GetPlayState failed: %d", err);
421 }
422 return state;
423}
424
425} // namespace webrtc