summaryrefslogtreecommitdiffstats
path: root/media/audio/null_audio_sink.cc
diff options
context:
space:
mode:
authorsandersd <sandersd@chromium.org>2015-11-09 13:46:49 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-09 21:47:54 +0000
commitf0f2233b00187007db7ad9ee0071cea47b20a53e (patch)
tree9d2d6258b5ef3f449d03e6078986e2e862a05ad9 /media/audio/null_audio_sink.cc
parenta1d5cfea190592803aa4d23658f26fdc635906cd (diff)
downloadchromium_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.cc16
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;