Index: media/filters/decoder_stream.cc |
diff --git a/media/filters/decoder_stream.cc b/media/filters/decoder_stream.cc |
index ebda8c00594cc948e3fb528e85b4c1ee2f05d1ff..40ce25453bb3a8f59c3850e6136d27b50217fdd5 100644 |
--- a/media/filters/decoder_stream.cc |
+++ b/media/filters/decoder_stream.cc |
@@ -10,6 +10,7 @@ |
#include "base/location.h" |
#include "base/logging.h" |
#include "base/single_thread_task_runner.h" |
+#include "media/base/audio_decoder.h" |
#include "media/base/bind_to_current_loop.h" |
#include "media/base/decoder_buffer.h" |
#include "media/base/demuxer_stream.h" |
@@ -28,6 +29,11 @@ const char* GetTraceString<DemuxerStream::VIDEO>() { |
return "DecoderStream<VIDEO>::Decode"; |
} |
+template <> |
+const char* GetTraceString<DemuxerStream::AUDIO>() { |
+ return "DecoderStream<AUDIO>::Decode"; |
+} |
+ |
template <DemuxerStream::Type StreamType> |
DecoderStream<StreamType>::DecoderStream( |
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
@@ -65,7 +71,6 @@ void DecoderStream<StreamType>::Initialize(DemuxerStream* stream, |
// TODO(xhwang): DecoderSelector only needs a config to select a decoder. |
decoder_selector_->SelectDecoder( |
stream, |
- StatisticsCB(), |
base::Bind(&DecoderStream<StreamType>::OnDecoderSelected, |
weak_factory_.GetWeakPtr())); |
} |
@@ -319,6 +324,7 @@ void DecoderStream<StreamType>::OnDecodeOutputReady( |
return; |
} |
+ DCHECK(output); |
SatisfyRead(OK, output); |
} |
@@ -335,6 +341,25 @@ void DecoderStream<StreamType>::ReadFromDemuxerStream() { |
weak_factory_.GetWeakPtr())); |
} |
+template <> |
+void DecoderStream<DemuxerStream::AUDIO>::ReadFromDemuxerStream() { |
+ DVLOG(2) << __FUNCTION__; |
+ DCHECK_EQ(state_, STATE_NORMAL) << state_; |
+ DCHECK(!read_cb_.is_null()); |
+ DCHECK(reset_cb_.is_null()); |
+ DCHECK(stop_cb_.is_null()); |
+ DCHECK(decoder_); |
+ |
+ if (decoder_->HasQueuedData()) { |
+ Decode(NULL); |
DaleCurtis
2014/02/21 21:48:48
Won't this happen naturally as the decoder is drai
rileya (GONE FROM CHROMIUM)
2014/02/21 23:04:02
I just realized how unintuitive this looks now, ha
xhwang
2014/02/21 23:57:56
Some random ideas:
1, See comment above, if you h
rileya (GONE FROM CHROMIUM)
2014/02/24 21:04:11
1) Sounds good, done.
2) Yup, this was originally
rileya (GONE FROM CHROMIUM)
2014/02/24 21:07:50
s/VRD/GVD/
Not sure how I messed that up haha...
|
+ } else { |
+ state_ = STATE_PENDING_DEMUXER_READ; |
+ stream_->Read( |
+ base::Bind(&DecoderStream<DemuxerStream::AUDIO>::OnBufferReady, |
+ weak_factory_.GetWeakPtr())); |
+ } |
+} |
+ |
template <DemuxerStream::Type StreamType> |
void DecoderStream<StreamType>::OnBufferReady( |
DemuxerStream::Status status, |
@@ -387,12 +412,10 @@ void DecoderStream<StreamType>::ReinitializeDecoder() { |
DCHECK(task_runner_->BelongsToCurrentThread()); |
DCHECK_EQ(state_, STATE_FLUSHING_DECODER) << state_; |
- // TODO(rileya): Specialize this for audio, or, better yet, change |
- // DemuxerStream config getters to be templated. |
- DCHECK(stream_->video_decoder_config().IsValidConfig()); |
+ DCHECK(StreamTraits::GetDecoderConfig(*stream_).IsValidConfig()); |
state_ = STATE_REINITIALIZING_DECODER; |
decoder_->Initialize( |
- stream_->video_decoder_config(), |
+ StreamTraits::GetDecoderConfig(*stream_), |
base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, |
weak_factory_.GetWeakPtr())); |
} |
@@ -492,4 +515,5 @@ void DecoderStream<StreamType>::OnDecoderStopped() { |
} |
template class DecoderStream<DemuxerStream::VIDEO>; |
+template class DecoderStream<DemuxerStream::AUDIO>; |
} // namespace media |