diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 20:41:57 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 20:41:57 +0000 |
commit | b6d4b183e06259c87ff7c6b067edd71a118b21ed (patch) | |
tree | 46ba777e073e016730b7589a1763aea9317fbd20 /media | |
parent | 477fcd28fd16b72d097d787629b323d1c16b79bb (diff) | |
download | chromium_src-b6d4b183e06259c87ff7c6b067edd71a118b21ed.zip chromium_src-b6d4b183e06259c87ff7c6b067edd71a118b21ed.tar.gz chromium_src-b6d4b183e06259c87ff7c6b067edd71a118b21ed.tar.bz2 |
Replaced DCHECKs to use MessageLoop::current() for FFmpegDemuxer and DecoderBase.
TEST=media_unittests
BUG=none
Review URL: http://codereview.chromium.org/149475
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/filters/decoder_base.h | 31 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer.cc | 31 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer.h | 6 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder_unittest.cc | 3 |
4 files changed, 25 insertions, 46 deletions
diff --git a/media/filters/decoder_base.h b/media/filters/decoder_base.h index a4ed764..22127c2 100644 --- a/media/filters/decoder_base.h +++ b/media/filters/decoder_base.h @@ -65,8 +65,7 @@ class DecoderBase : public Decoder { DecoderBase() : pending_reads_(0), seeking_(false), - state_(UNINITIALIZED), - thread_id_(NULL) { + state_(UNINITIALIZED) { } virtual ~DecoderBase() { @@ -79,7 +78,7 @@ class DecoderBase : public Decoder { // It places an output buffer in the result queue. It must be called from // within the OnDecode method. void EnqueueResult(Output* output) { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), this->message_loop()); if (!IsStopped()) { result_queue_.push_back(output); } @@ -108,18 +107,14 @@ class DecoderBase : public Decoder { // the EnequeueResult() method from within this method. virtual void OnDecode(Buffer* input) = 0; - // Used for subclasses who friend unit tests and need to set the thread id. - virtual void set_thread_id(PlatformThreadId thread_id) { - thread_id_ = thread_id; - } - MediaFormat media_format_; private: bool IsStopped() { return state_ == STOPPED; } void StopTask() { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), this->message_loop()); + // Delegate to the subclass first. OnStop(); @@ -130,7 +125,8 @@ class DecoderBase : public Decoder { } void SeekTask(base::TimeDelta time) { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), this->message_loop()); + // Delegate to the subclass first. OnSeek(time); @@ -143,14 +139,11 @@ class DecoderBase : public Decoder { } void InitializeTask(DemuxerStream* demuxer_stream) { + DCHECK_EQ(MessageLoop::current(), this->message_loop()); DCHECK(state_ == UNINITIALIZED); DCHECK(!demuxer_stream_); - DCHECK(!thread_id_ || thread_id_ == PlatformThread::CurrentId()); demuxer_stream_ = demuxer_stream; - // Grab the thread id for debugging. - thread_id_ = PlatformThread::CurrentId(); - // Delegate to subclass first. if (!OnInitialize(demuxer_stream_)) { this->host()->Error(PIPELINE_ERROR_DECODE); @@ -164,7 +157,8 @@ class DecoderBase : public Decoder { } void ReadTask(ReadCallback* read_callback) { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), this->message_loop()); + // TODO(scherkus): should reply with a null operation (empty buffer). if (IsStopped()) { delete read_callback; @@ -183,7 +177,7 @@ class DecoderBase : public Decoder { } void ReadCompleteTask(scoped_refptr<Buffer> buffer) { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), this->message_loop()); DCHECK_GT(pending_reads_, 0u); --pending_reads_; if (IsStopped()) { @@ -226,7 +220,7 @@ class DecoderBase : public Decoder { // Attempts to fulfill a single pending read by dequeuing a buffer and read // callback pair and executing the callback. void FulfillPendingRead() { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), this->message_loop()); if (read_queue_.empty() || result_queue_.empty()) { return; } @@ -276,9 +270,6 @@ class DecoderBase : public Decoder { }; State state_; - // Used for debugging. - PlatformThreadId thread_id_; - DISALLOW_COPY_AND_ASSIGN(DecoderBase); }; diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index c12e0ad..aa7ff27 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc @@ -110,14 +110,14 @@ void* FFmpegDemuxerStream::QueryInterface(const char* id) { } bool FFmpegDemuxerStream::HasPendingReads() { - DCHECK_EQ(PlatformThread::CurrentId(), demuxer_->thread_id_); + DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); DCHECK(!stopped_ || read_queue_.empty()) << "Read queue should have been emptied if demuxing stream is stopped"; return !read_queue_.empty(); } base::TimeDelta FFmpegDemuxerStream::EnqueuePacket(AVPacket* packet) { - DCHECK_EQ(PlatformThread::CurrentId(), demuxer_->thread_id_); + DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); base::TimeDelta timestamp = ConvertTimestamp(packet->pts); base::TimeDelta duration = ConvertTimestamp(packet->duration); if (stopped_) { @@ -138,13 +138,13 @@ base::TimeDelta FFmpegDemuxerStream::EnqueuePacket(AVPacket* packet) { } void FFmpegDemuxerStream::FlushBuffers() { - DCHECK_EQ(PlatformThread::CurrentId(), demuxer_->thread_id_); + DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); buffer_queue_.clear(); discontinuous_ = true; } void FFmpegDemuxerStream::Stop() { - DCHECK_EQ(PlatformThread::CurrentId(), demuxer_->thread_id_); + DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); buffer_queue_.clear(); STLDeleteElements(&read_queue_); stopped_ = true; @@ -161,7 +161,7 @@ void FFmpegDemuxerStream::Read(Callback1<Buffer*>::Type* read_callback) { } void FFmpegDemuxerStream::ReadTask(Callback1<Buffer*>::Type* read_callback) { - DCHECK_EQ(PlatformThread::CurrentId(), demuxer_->thread_id_); + DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); // Don't accept any additional reads if we've been told to stop. // @@ -182,7 +182,7 @@ void FFmpegDemuxerStream::ReadTask(Callback1<Buffer*>::Type* read_callback) { } void FFmpegDemuxerStream::FulfillPendingRead() { - DCHECK_EQ(PlatformThread::CurrentId(), demuxer_->thread_id_); + DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop()); if (buffer_queue_.empty() || read_queue_.empty()) { return; } @@ -215,8 +215,7 @@ base::TimeDelta FFmpegDemuxerStream::ConvertTimestamp(int64 timestamp) { // FFmpegDemuxer // FFmpegDemuxer::FFmpegDemuxer() - : format_context_(NULL), - thread_id_(NULL) { + : format_context_(NULL) { } FFmpegDemuxer::~FFmpegDemuxer() { @@ -288,6 +287,8 @@ scoped_refptr<DemuxerStream> FFmpegDemuxer::GetStream(int stream) { } void FFmpegDemuxer::InititalizeTask(DataSource* data_source) { + DCHECK_EQ(MessageLoop::current(), message_loop()); + // In order to get FFmpeg to use |data_source| for file IO we must transfer // ownership via FFmpegGlue. We'll add |data_source| to FFmpegGlue and pass // the resulting key to FFmpeg. FFmpeg will pass the key to FFmpegGlue which @@ -297,10 +298,6 @@ void FFmpegDemuxer::InititalizeTask(DataSource* data_source) { // // Refer to media/filters/ffmpeg_glue.h for details. - // Grab the thread id for debugging. - DCHECK(!thread_id_); - thread_id_ = PlatformThread::CurrentId(); - // Add our data source and get our unique key. std::string key = FFmpegGlue::get()->AddDataSource(data_source); @@ -359,7 +356,7 @@ void FFmpegDemuxer::InititalizeTask(DataSource* data_source) { } void FFmpegDemuxer::SeekTask(base::TimeDelta time) { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), message_loop()); // Tell streams to flush buffers due to seeking. StreamVector::iterator iter; @@ -381,7 +378,7 @@ void FFmpegDemuxer::SeekTask(base::TimeDelta time) { } void FFmpegDemuxer::DemuxTask() { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), message_loop()); // Make sure we have work to do before demuxing. if (!StreamsHavePendingReads()) { @@ -438,7 +435,7 @@ void FFmpegDemuxer::DemuxTask() { } void FFmpegDemuxer::StopTask() { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), message_loop()); StreamVector::iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { (*iter)->Stop(); @@ -446,7 +443,7 @@ void FFmpegDemuxer::StopTask() { } bool FFmpegDemuxer::StreamsHavePendingReads() { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), message_loop()); StreamVector::iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { if ((*iter)->HasPendingReads()) { @@ -457,7 +454,7 @@ bool FFmpegDemuxer::StreamsHavePendingReads() { } void FFmpegDemuxer::StreamHasEnded() { - DCHECK_EQ(PlatformThread::CurrentId(), thread_id_); + DCHECK_EQ(MessageLoop::current(), message_loop()); StreamVector::iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { AVPacket* packet = new AVPacket(); diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h index 8c4e128..9d68e35 100644 --- a/media/filters/ffmpeg_demuxer.h +++ b/media/filters/ffmpeg_demuxer.h @@ -128,9 +128,6 @@ class FFmpegDemuxer : public Demuxer { virtual scoped_refptr<DemuxerStream> GetStream(int stream_id); private: - // Allow FFmpegDemuxerStream to post tasks to our message loop. - friend class FFmpegDemuxerStream; - // Only allow a factory to create this class. friend class FilterFactoryImpl0<FFmpegDemuxer>; FFmpegDemuxer(); @@ -181,9 +178,6 @@ class FFmpegDemuxer : public Demuxer { StreamVector streams_; StreamVector packet_streams_; - // Used for debugging. - PlatformThreadId thread_id_; - DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); }; diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc index 6603b58..b4d4ace 100644 --- a/media/filters/ffmpeg_video_decoder_unittest.cc +++ b/media/filters/ffmpeg_video_decoder_unittest.cc @@ -83,9 +83,6 @@ class FFmpegVideoDecoderTest : public testing::Test { decoder_->set_message_loop(&message_loop_); demuxer_ = new StrictMock<MockFFmpegDemuxerStream>(); - // Manually set the thread id for tests that don't initialize the decoder. - decoder_->set_thread_id(PlatformThread::CurrentId()); - // Initialize FFmpeg fixtures. memset(&stream_, 0, sizeof(stream_)); memset(&codec_context_, 0, sizeof(codec_context_)); |