diff options
author | sandersd <sandersd@chromium.org> | 2015-11-09 13:46:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-09 21:47:54 +0000 |
commit | f0f2233b00187007db7ad9ee0071cea47b20a53e (patch) | |
tree | 9d2d6258b5ef3f449d03e6078986e2e862a05ad9 /media/audio/null_audio_sink.cc | |
parent | a1d5cfea190592803aa4d23658f26fdc635906cd (diff) | |
download | chromium_src-f0f2233b00187007db7ad9ee0071cea47b20a53e.zip chromium_src-f0f2233b00187007db7ad9ee0071cea47b20a53e.tar.gz chromium_src-f0f2233b00187007db7ad9ee0071cea47b20a53e.tar.bz2 |
Add RestartableAudioRendererSink, a restartable AudioRendererSink.
This is the start of a refactor of the semantics of the
AudioRendererSink interface to allow Start() to be called again
after Stop(). This change defines the new interface and ports
MockAudioRendererSink, NullAudioSink, AudioRendererMixerInput,
AudioOutputStreamSink, and WebAudioSourceProviderImpl) to it. This
allows WebMediaPlayerImpl to switch to using
RestartableAudioRendererSink.
BUG=516850
Review URL: https://codereview.chromium.org/1428313003
Cr-Commit-Position: refs/heads/master@{#358666}
Diffstat (limited to 'media/audio/null_audio_sink.cc')
-rw-r--r-- | media/audio/null_audio_sink.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/media/audio/null_audio_sink.cc b/media/audio/null_audio_sink.cc index ba25718..5b043a0 100644 --- a/media/audio/null_audio_sink.cc +++ b/media/audio/null_audio_sink.cc @@ -15,16 +15,16 @@ namespace media { NullAudioSink::NullAudioSink( const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) : initialized_(false), + started_(false), playing_(false), callback_(NULL), - task_runner_(task_runner) { -} + task_runner_(task_runner) {} NullAudioSink::~NullAudioSink() {} void NullAudioSink::Initialize(const AudioParameters& params, RenderCallback* callback) { - DCHECK(!initialized_); + DCHECK(!started_); fake_worker_.reset(new FakeAudioWorker(task_runner_, params)); audio_bus_ = AudioBus::Create(params); callback_ = callback; @@ -33,12 +33,14 @@ void NullAudioSink::Initialize(const AudioParameters& params, void NullAudioSink::Start() { DCHECK(task_runner_->BelongsToCurrentThread()); - DCHECK(!playing_); + DCHECK(initialized_); + DCHECK(!started_); + started_ = true; } void NullAudioSink::Stop() { DCHECK(task_runner_->BelongsToCurrentThread()); - + started_ = false; // Stop may be called at any time, so we have to check before stopping. if (fake_worker_) fake_worker_->Stop(); @@ -46,18 +48,20 @@ void NullAudioSink::Stop() { void NullAudioSink::Play() { DCHECK(task_runner_->BelongsToCurrentThread()); - DCHECK(initialized_); + DCHECK(started_); if (playing_) return; fake_worker_->Start(base::Bind( &NullAudioSink::CallRender, base::Unretained(this))); + playing_ = true; } void NullAudioSink::Pause() { DCHECK(task_runner_->BelongsToCurrentThread()); + DCHECK(started_); if (!playing_) return; |