Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: media/filters/audio_renderer_impl.cc

Issue 407583002: Fold AudioRenderer::Stop() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ClocklessAudioSink Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/audio_renderer_impl.h ('k') | media/filters/audio_renderer_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_renderer_impl.cc
diff --git a/media/filters/audio_renderer_impl.cc b/media/filters/audio_renderer_impl.cc
index cfdf016ec0088df2ae9e62c8fe6752e799838f39..44536de51723cb502a2b211f412056a6e1f01057 100644
--- a/media/filters/audio_renderer_impl.cc
+++ b/media/filters/audio_renderer_impl.cc
@@ -67,9 +67,15 @@ AudioRendererImpl::AudioRendererImpl(
}
AudioRendererImpl::~AudioRendererImpl() {
- // Stop() should have been called and |algorithm_| should have been destroyed.
- DCHECK(state_ == kUninitialized || state_ == kStopped);
- DCHECK(!algorithm_.get());
+ DVLOG(1) << __FUNCTION__;
+ DCHECK(task_runner_->BelongsToCurrentThread());
+
+ // If Render() is in progress, this call will wait for Render() to finish.
+ // After this call, the |sink_| will not call back into |this| anymore.
+ sink_->Stop();
+
+ if (!init_cb_.is_null())
+ base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
}
void AudioRendererImpl::StartTicking() {
@@ -189,8 +195,6 @@ void AudioRendererImpl::ResetDecoderDone() {
DCHECK(task_runner_->BelongsToCurrentThread());
{
base::AutoLock auto_lock(lock_);
- if (state_ == kStopped)
- return;
DCHECK_EQ(state_, kFlushed);
DCHECK(!flush_cb_.is_null());
@@ -214,37 +218,6 @@ void AudioRendererImpl::ResetDecoderDone() {
task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&flush_cb_));
}
-void AudioRendererImpl::Stop(const base::Closure& callback) {
- DVLOG(1) << __FUNCTION__;
- DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(!callback.is_null());
-
- // TODO(scherkus): Consider invalidating |weak_factory_| and replacing
- // task-running guards that check |state_| with DCHECK().
-
- {
- base::AutoLock auto_lock(lock_);
-
- if (state_ == kStopped) {
- task_runner_->PostTask(FROM_HERE, callback);
- return;
- }
-
- ChangeState_Locked(kStopped);
- algorithm_.reset();
- time_cb_.Reset();
- flush_cb_.Reset();
- }
-
- if (sink_) {
- sink_->Stop();
- sink_ = NULL;
- }
-
- audio_buffer_stream_.reset();
- task_runner_->PostTask(FROM_HERE, callback);
-}
-
void AudioRendererImpl::StartPlaying() {
DVLOG(1) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
@@ -334,11 +307,6 @@ void AudioRendererImpl::OnAudioBufferStreamInitialized(bool success) {
base::AutoLock auto_lock(lock_);
- if (state_ == kStopped) {
- base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
- return;
- }
-
if (!success) {
state_ = kUninitialized;
base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
@@ -469,7 +437,7 @@ bool AudioRendererImpl::HandleSplicerBuffer_Locked(
return true;
}
- if (state_ != kUninitialized && state_ != kStopped)
+ if (state_ != kUninitialized)
algorithm_->EnqueueBuffer(buffer);
}
@@ -491,9 +459,6 @@ bool AudioRendererImpl::HandleSplicerBuffer_Locked(
return false;
}
return true;
-
- case kStopped:
- return false;
}
return false;
}
@@ -523,7 +488,6 @@ bool AudioRendererImpl::CanRead_Locked() {
case kInitializing:
case kFlushing:
case kFlushed:
- case kStopped:
return false;
case kPlaying:
@@ -690,7 +654,6 @@ void AudioRendererImpl::HandleAbortedReadOrDecodeError(bool is_decode_error) {
case kFlushed:
case kPlaying:
- case kStopped:
if (status != PIPELINE_OK)
error_cb_.Run(status);
return;
« no previous file with comments | « media/filters/audio_renderer_impl.h ('k') | media/filters/audio_renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698