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

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: comments addressed 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 9b0c098b191ecbdfae2fa85e03c60f2f855aed0b..bea35d559ee326eba768e210e29c7f1abd3b0064 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();
DaleCurtis 2014/07/22 00:15:48 Correct, once this returns no further calls to the
+
+ if (!init_cb_.is_null())
+ base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
}
void AudioRendererImpl::StartRendering() {
@@ -174,8 +180,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());
@@ -199,37 +203,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());
@@ -319,11 +292,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);
@@ -454,7 +422,7 @@ bool AudioRendererImpl::HandleSplicerBuffer_Locked(
return true;
}
- if (state_ != kUninitialized && state_ != kStopped)
+ if (state_ != kUninitialized)
algorithm_->EnqueueBuffer(buffer);
}
@@ -476,9 +444,6 @@ bool AudioRendererImpl::HandleSplicerBuffer_Locked(
return false;
}
return true;
-
- case kStopped:
- return false;
}
return false;
}
@@ -508,7 +473,6 @@ bool AudioRendererImpl::CanRead_Locked() {
case kInitializing:
case kFlushing:
case kFlushed:
- case kStopped:
return false;
case kPlaying:
@@ -675,7 +639,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