| Index: media/audio/android/opensles_output.h
|
| diff --git a/media/audio/android/opensles_output.h b/media/audio/android/opensles_output.h
|
| index 0fef1bdb23129798fa966941f557c11dba4ac4fb..f41befbd894855b5b069a1373b0717de27a5903a 100644
|
| --- a/media/audio/android/opensles_output.h
|
| +++ b/media/audio/android/opensles_output.h
|
| @@ -8,12 +8,20 @@
|
| #include <SLES/OpenSLES.h>
|
| #include <SLES/OpenSLES_Android.h>
|
|
|
| +#include "base/cancelable_callback.h"
|
| #include "base/compiler_specific.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/threading/thread_checker.h"
|
| +#include "base/time/time.h"
|
| #include "media/audio/android/opensles_util.h"
|
| #include "media/audio/audio_io.h"
|
| #include "media/audio/audio_parameters.h"
|
| +#include "media/base/audio_timestamp_helper.h"
|
| +
|
| +namespace base {
|
| +class SingleThreadTaskRunner;
|
| +}
|
|
|
| namespace media {
|
|
|
| @@ -57,8 +65,10 @@ class OpenSLESOutputStream : public AudioOutputStream {
|
| // Called from OpenSLES specific audio worker thread.
|
| void FillBufferQueue();
|
|
|
| - // Called from the audio manager thread.
|
| - void FillBufferQueueNoLock();
|
| + // Called from either the audio manager thread or the OpenSLES audio worker
|
| + // thread. |lock_| must be held when this method is called.
|
| + // |in_idle_mode| is true if the player is in idle mode, or false otherwise.
|
| + void FillBufferQueueNoLock(bool in_idle_mode);
|
|
|
| // Called in Open();
|
| void SetupAudioBuffer();
|
| @@ -70,6 +80,20 @@ class OpenSLESOutputStream : public AudioOutputStream {
|
| // the attached AudioOutputCallback::OnError().
|
| void HandleError(SLresult error);
|
|
|
| + // Called to check whether there are any audio data available to render.
|
| + void CheckForIdle();
|
| +
|
| + // Called to cancel the check for empty audio data.
|
| + void CancelIdleCheck();
|
| +
|
| + // Starts entering idle mode. The player will stop writing data to buffer
|
| + // queue until non empty data arrives. |in_idle_mode| indicates whether
|
| + // the player is in the idle mode. |frames_filled| and |idle_start_time|
|
| + // are used by |audio_timestamp_helper_| and |idle_start_time_| to avoid
|
| + // time drifting.
|
| + void WaitingForAudio(bool in_idle_mode,
|
| + int frames_filled, base::TimeTicks idle_start_time);
|
| +
|
| base::ThreadChecker thread_checker_;
|
|
|
| // Protects |callback_|, |active_buffer_index_|, |audio_data_|,
|
| @@ -117,6 +141,28 @@ class OpenSLESOutputStream : public AudioOutputStream {
|
| // Container for retrieving data from AudioSourceCallback::OnMoreData().
|
| scoped_ptr<AudioBus> audio_bus_;
|
|
|
| + // Object to calculate the current audio timestamp in idle mode.
|
| + scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
|
| +
|
| + // The start TimeTicks when the player enters idle mode.
|
| + base::TimeTicks idle_start_time_;
|
| +
|
| + // The number of consecutive empty audio buffers encountered.
|
| + uint32 consecutive_empty_buffer_count_;
|
| +
|
| + // A cancelable task that is posted when the player enters idle mode. The task
|
| + // is posted regularly to check whether there are any audio data available to
|
| + // render.
|
| + base::CancelableClosure idle_check_callback_;
|
| +
|
| + // TaskRunner to post |idle_check_callback_|.
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| +
|
| + // Weak pointer for callbacks.
|
| + base::WeakPtr<OpenSLESOutputStream> weak_this_;
|
| + // NOTE: Weak pointers must be invalidated before all other member variables.
|
| + base::WeakPtrFactory<OpenSLESOutputStream> weak_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(OpenSLESOutputStream);
|
| };
|
|
|
|
|