Index: media/audio/android/opensles_output.h |
diff --git a/media/audio/android/opensles_output.h b/media/audio/android/opensles_output.h |
index f505b5165cd4d2016ef3560d3a47e270c65c5977..f18e346ef35bef5ce630b5509e2f34edc4109a98 100644 |
--- a/media/audio/android/opensles_output.h |
+++ b/media/audio/android/opensles_output.h |
@@ -9,6 +9,7 @@ |
#include <SLES/OpenSLES_Android.h> |
#include "base/compiler_specific.h" |
+#include "base/threading/thread_checker.h" |
#include "media/audio/android/opensles_util.h" |
#include "media/audio/audio_io.h" |
#include "media/audio/audio_parameters.h" |
@@ -18,9 +19,12 @@ namespace media { |
class AudioManagerAndroid; |
// Implements PCM audio output support for Android using the OpenSLES API. |
+// This class is created and lives on the Audio Manager thread but recorded |
+// audio buffers are given to us from an internal OpenSLES audio thread. |
+// All public methods should be called on the Audio Manager thread. |
class OpenSLESOutputStream : public AudioOutputStream { |
public: |
- static const int kNumOfQueuesInBuffer = 2; |
+ static const int kMaxNumOfBuffersInQueue = 2; |
OpenSLESOutputStream(AudioManagerAndroid* manager, |
const AudioParameters& params); |
@@ -38,11 +42,17 @@ class OpenSLESOutputStream : public AudioOutputStream { |
private: |
bool CreatePlayer(); |
+ // Called from OpenSLES specific audio worker thread. |
static void SimpleBufferQueueCallback( |
SLAndroidSimpleBufferQueueItf buffer_queue, void* instance); |
+ // Fills up one buffer by asking the registered source for data. |
+ // Called from OpenSLES specific audio worker thread. |
void FillBufferQueue(); |
+ // Called from the audio manager thread. |
+ void FillBufferQueueNoLock(); |
+ |
// Called in Open(); |
void SetupAudioBuffer(); |
@@ -53,6 +63,11 @@ class OpenSLESOutputStream : public AudioOutputStream { |
// the attached AudioOutputCallback::OnError(). |
void HandleError(SLresult error); |
+ base::ThreadChecker thread_checker_; |
+ |
+ // TODO(henrika): add comments.... |
tommi (sloooow) - chröme
2013/09/03 12:15:09
ping
henrika (OOO until Aug 14)
2013/09/03 12:48:32
Done.
|
+ base::Lock lock_; |
+ |
AudioManagerAndroid* audio_manager_; |
AudioSourceCallback* callback_; |
@@ -69,10 +84,11 @@ class OpenSLESOutputStream : public AudioOutputStream { |
SLDataFormat_PCM format_; |
- // Audio buffer arrays that are allocated in the constructor. |
- uint8* audio_data_[kNumOfQueuesInBuffer]; |
+ // Audio buffers that are allocated in the constructor based on |
+ // info from audio parameters. |
+ uint8* audio_data_[kMaxNumOfBuffersInQueue]; |
- int active_queue_; |
+ int active_buffer_; |
tommi (sloooow) - chröme
2013/09/03 12:15:09
nit: active_buffer_index_
henrika (OOO until Aug 14)
2013/09/03 12:48:32
Done.
|
size_t buffer_size_bytes_; |
bool started_; |
@@ -88,4 +104,4 @@ class OpenSLESOutputStream : public AudioOutputStream { |
} // namespace media |
-#endif // MEDIA_AUDIO_ANDROID_OPENSLES_INPUT_H_ |
+#endif // MEDIA_AUDIO_ANDROID_OPENSLES_OUTPUT_H_ |