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

Unified Diff: media/filters/decrypting_audio_decoder.cc

Issue 331863004: Revert 276344 "Add callback in VideoDecoder and AudioDecoder to ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2049/src/
Patch Set: Created 6 years, 6 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/decrypting_audio_decoder.h ('k') | media/filters/decrypting_audio_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/decrypting_audio_decoder.cc
===================================================================
--- media/filters/decrypting_audio_decoder.cc (revision 277175)
+++ media/filters/decrypting_audio_decoder.cc (working copy)
@@ -45,8 +45,7 @@
weak_factory_(this) {}
void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
- const PipelineStatusCB& status_cb,
- const OutputCB& output_cb) {
+ const PipelineStatusCB& status_cb) {
DVLOG(2) << "Initialize()";
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(decode_cb_.is_null());
@@ -54,7 +53,6 @@
weak_this_ = weak_factory_.GetWeakPtr();
init_cb_ = BindToCurrentLoop(status_cb);
- output_cb_ = BindToCurrentLoop(output_cb);
if (!config.IsValidConfig()) {
DLOG(ERROR) << "Invalid audio stream config.";
@@ -94,11 +92,17 @@
// Return empty (end-of-stream) frames if decoding has finished.
if (state_ == kDecodeFinished) {
- output_cb_.Run(AudioBuffer::CreateEOSBuffer());
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(kOk, AudioBuffer::CreateEOSBuffer());
return;
}
+ if (!queued_audio_frames_.empty()) {
+ DCHECK(!buffer);
+ base::ResetAndReturn(&decode_cb_).Run(kOk, queued_audio_frames_.front());
+ queued_audio_frames_.pop_front();
+ return;
+ }
+
// Initialize the |next_output_timestamp_| to be the timestamp of the first
// non-EOS buffer.
if (timestamp_helper_->base_timestamp() == kNoTimestamp() &&
@@ -111,6 +115,14 @@
DecodePendingBuffer();
}
+scoped_refptr<AudioBuffer> DecryptingAudioDecoder::GetDecodeOutput() {
+ if (queued_audio_frames_.empty())
+ return NULL;
+ scoped_refptr<AudioBuffer> out = queued_audio_frames_.front();
+ queued_audio_frames_.pop_front();
+ return out;
+}
+
void DecryptingAudioDecoder::Reset(const base::Closure& closure) {
DVLOG(2) << "Reset() - state: " << state_;
DCHECK(task_runner_->BelongsToCurrentThread());
@@ -137,7 +149,7 @@
if (state_ == kWaitingForKey) {
DCHECK(!decode_cb_.is_null());
pending_buffer_to_decode_ = NULL;
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
}
DCHECK(decode_cb_.is_null());
@@ -162,7 +174,7 @@
if (!init_cb_.is_null())
base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
if (!decode_cb_.is_null())
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
@@ -253,6 +265,7 @@
DCHECK_EQ(state_, kPendingDecode) << state_;
DCHECK(!decode_cb_.is_null());
DCHECK(pending_buffer_to_decode_.get());
+ DCHECK(queued_audio_frames_.empty());
bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_;
key_added_while_decode_pending_ = false;
@@ -262,7 +275,7 @@
pending_buffer_to_decode_ = NULL;
if (!reset_cb_.is_null()) {
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
DoReset();
return;
}
@@ -272,7 +285,7 @@
if (status == Decryptor::kError) {
DVLOG(2) << "DeliverFrame() - kError";
state_ = kDecodeFinished; // TODO add kError state
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
+ base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL);
return;
}
@@ -296,22 +309,23 @@
DVLOG(2) << "DeliverFrame() - kNeedMoreData";
if (scoped_pending_buffer_to_decode->end_of_stream()) {
state_ = kDecodeFinished;
- output_cb_.Run(AudioBuffer::CreateEOSBuffer());
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_)
+ .Run(kOk, AudioBuffer::CreateEOSBuffer());
return;
}
state_ = kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(kNotEnoughData, NULL);
return;
}
DCHECK_EQ(status, Decryptor::kSuccess);
DCHECK(!frames.empty());
- ProcessDecodedFrames(frames);
+ EnqueueFrames(frames);
state_ = kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(kOk, queued_audio_frames_.front());
+ queued_audio_frames_.pop_front();
}
void DecryptingAudioDecoder::OnKeyAdded() {
@@ -336,12 +350,14 @@
base::ResetAndReturn(&reset_cb_).Run();
}
-void DecryptingAudioDecoder::ProcessDecodedFrames(
+void DecryptingAudioDecoder::EnqueueFrames(
const Decryptor::AudioBuffers& frames) {
- for (Decryptor::AudioBuffers::const_iterator iter = frames.begin();
- iter != frames.end();
+ queued_audio_frames_ = frames;
+
+ for (Decryptor::AudioBuffers::iterator iter = queued_audio_frames_.begin();
+ iter != queued_audio_frames_.end();
++iter) {
- scoped_refptr<AudioBuffer> frame = *iter;
+ scoped_refptr<AudioBuffer>& frame = *iter;
DCHECK(!frame->end_of_stream()) << "EOS frame returned.";
DCHECK_GT(frame->frame_count(), 0) << "Empty frame returned.";
@@ -356,8 +372,6 @@
frame->set_timestamp(current_time);
timestamp_helper_->AddFrames(frame->frame_count());
-
- output_cb_.Run(frame);
}
}
« no previous file with comments | « media/filters/decrypting_audio_decoder.h ('k') | media/filters/decrypting_audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698