diff options
Diffstat (limited to 'media/audio/null_audio_sink.h')
-rw-r--r-- | media/audio/null_audio_sink.h | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/media/audio/null_audio_sink.h b/media/audio/null_audio_sink.h index f892ab4..c528473 100644 --- a/media/audio/null_audio_sink.h +++ b/media/audio/null_audio_sink.h @@ -2,25 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MEDIA_AUDIO_NULL_AUDIO_SINK_H_ -#define MEDIA_AUDIO_NULL_AUDIO_SINK_H_ +#ifndef MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ +#define MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ + +// NullAudioSink effectively uses an extra thread to "throw away" the +// audio data at a rate resembling normal playback speed. It's just like +// decoding to /dev/null! +// +// NullAudioSink can also be used in situations where the client has no +// audio device or we haven't written an audio implementation for a particular +// platform yet. #include "base/md5.h" #include "base/memory/scoped_ptr.h" +#include "base/threading/thread.h" #include "media/base/audio_renderer_sink.h" -namespace base { -class MessageLoopProxy; -} - namespace media { class AudioBus; -class FakeAudioConsumer; class MEDIA_EXPORT NullAudioSink : NON_EXPORTED_BASE(public AudioRendererSink) { public: - NullAudioSink(const scoped_refptr<base::MessageLoopProxy>& message_loop); + NullAudioSink(); // AudioRendererSink implementation. virtual void Initialize(const AudioParameters& params, @@ -42,23 +46,31 @@ class MEDIA_EXPORT NullAudioSink virtual ~NullAudioSink(); private: - // Task that periodically calls Render() to consume audio data. - void CallRender(AudioBus* audio_bus); + // Audio thread task that periodically calls FillBuffer() to consume + // audio data. + void FillBufferTask(); + + void SetPlaying(bool is_playing); + // A buffer passed to FillBuffer to advance playback. + scoped_ptr<AudioBus> audio_bus_; + + AudioParameters params_; bool initialized_; + bool playing_; RenderCallback* callback_; + // Separate thread used to throw away data. + base::Thread thread_; + base::Lock lock_; + // Controls whether or not a running MD5 hash is computed for audio frames. bool hash_audio_for_testing_; - int channels_; scoped_array<base::MD5Context> md5_channel_contexts_; - scoped_refptr<base::MessageLoopProxy> message_loop_; - scoped_ptr<FakeAudioConsumer> fake_consumer_; - DISALLOW_COPY_AND_ASSIGN(NullAudioSink); }; } // namespace media -#endif // MEDIA_AUDIO_NULL_AUDIO_SINK_H_ +#endif // MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ |