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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 139513007: Revert of Add Stop() to AudioDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_audio_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_audio_decoder.cc
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index 2bc21c7be0b6b11b8f1daefde0b5c7094b5317d9..a0e5889eff11aca7e6c84c6bdbf26080ca2fd8c0 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -115,8 +115,6 @@
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!read_cb.is_null());
CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported.";
- DCHECK(reset_cb_.is_null());
- DCHECK(stop_cb_.is_null());
read_cb_ = BindToCurrentLoop(read_cb);
@@ -149,32 +147,19 @@
void FFmpegAudioDecoder::Reset(const base::Closure& closure) {
DCHECK(task_runner_->BelongsToCurrentThread());
- reset_cb_ = BindToCurrentLoop(closure);
-
- // A demuxer read is pending, we'll wait until it finishes.
- if (!read_cb_.is_null())
- return;
-
- DoReset();
-}
-
-void FFmpegAudioDecoder::Stop(const base::Closure& closure) {
- DCHECK(task_runner_->BelongsToCurrentThread());
- stop_cb_ = BindToCurrentLoop(closure);
-
- // A demuxer read is pending, we'll wait until it finishes.
- if (!read_cb_.is_null())
- return;
-
- if (!reset_cb_.is_null()) {
- DoReset();
- return;
- }
-
- DoStop();
-}
-
-FFmpegAudioDecoder::~FFmpegAudioDecoder() {}
+ base::Closure reset_cb = BindToCurrentLoop(closure);
+
+ avcodec_flush_buffers(codec_context_.get());
+ ResetTimestampState();
+ queued_audio_.clear();
+ reset_cb.Run();
+}
+
+FFmpegAudioDecoder::~FFmpegAudioDecoder() {
+ // TODO(scherkus): should we require Stop() to be called? this might end up
+ // getting called on a random thread due to refcounting.
+ ReleaseFFmpegResources();
+}
int FFmpegAudioDecoder::GetAudioBuffer(AVCodecContext* codec,
AVFrame* frame,
@@ -241,32 +226,6 @@
return 0;
}
-void FFmpegAudioDecoder::DoStop() {
- DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(!stop_cb_.is_null());
- DCHECK(read_cb_.is_null());
- DCHECK(reset_cb_.is_null());
-
- ResetTimestampState();
- queued_audio_.clear();
- ReleaseFFmpegResources();
- base::ResetAndReturn(&stop_cb_).Run();
-}
-
-void FFmpegAudioDecoder::DoReset() {
- DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(!reset_cb_.is_null());
- DCHECK(read_cb_.is_null());
-
- avcodec_flush_buffers(codec_context_.get());
- ResetTimestampState();
- queued_audio_.clear();
- base::ResetAndReturn(&reset_cb_).Run();
-
- if (!stop_cb_.is_null())
- DoStop();
-}
-
void FFmpegAudioDecoder::ReadFromDemuxerStream() {
DCHECK(!read_cb_.is_null());
demuxer_stream_->Read(base::Bind(
@@ -280,24 +239,6 @@
DCHECK(!read_cb_.is_null());
DCHECK(queued_audio_.empty());
DCHECK_EQ(status != DemuxerStream::kOk, !input.get()) << status;
-
- // Pending Reset: ignore the buffer we just got, send kAborted to |read_cb_|
- // and carry out the Reset().
- // If there happens to also be a pending Stop(), that will be handled at
- // the end of DoReset().
- if (!reset_cb_.is_null()) {
- base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
- DoReset();
- return;
- }
-
- // Pending Stop: ignore the buffer we just got, send kAborted to |read_cb_|
- // and carry out the Stop().
- if (!stop_cb_.is_null()) {
- base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
- DoStop();
- return;
- }
if (status == DemuxerStream::kAborted) {
DCHECK(!input.get());
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698