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

Side by Side Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 11420070: Remove locking from FFmpegDemuxerStream and associated TODOs from media code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/ffmpeg_audio_decoder.h" 5 #include "media/filters/ffmpeg_audio_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 base::ResetAndReturn(&read_cb_).Run( 184 base::ResetAndReturn(&read_cb_).Run(
185 queued_audio_.front().status, queued_audio_.front().buffer); 185 queued_audio_.front().status, queued_audio_.front().buffer);
186 queued_audio_.pop_front(); 186 queued_audio_.pop_front();
187 } 187 }
188 188
189 void FFmpegAudioDecoder::DoDecodeBuffer( 189 void FFmpegAudioDecoder::DoDecodeBuffer(
190 DemuxerStream::Status status, 190 DemuxerStream::Status status,
191 const scoped_refptr<DecoderBuffer>& input) { 191 const scoped_refptr<DecoderBuffer>& input) {
192 DCHECK(message_loop_->BelongsToCurrentThread()); 192 if (!message_loop_->BelongsToCurrentThread()) {
193 message_loop_->PostTask(FROM_HERE, base::Bind(
194 &FFmpegAudioDecoder::DoDecodeBuffer, this, status, input));
195 return;
196 }
197
193 DCHECK(!read_cb_.is_null()); 198 DCHECK(!read_cb_.is_null());
194 DCHECK(queued_audio_.empty()); 199 DCHECK(queued_audio_.empty());
200 DCHECK_EQ(status != DemuxerStream::kOk, !input) << status;
195 201
196 if (status != DemuxerStream::kOk) { 202 if (status != DemuxerStream::kOk) {
197 DCHECK(!input);
198 // TODO(acolwell): Add support for reinitializing the decoder when 203 // TODO(acolwell): Add support for reinitializing the decoder when
199 // |status| == kConfigChanged. For now we just trigger a decode error. 204 // |status| == kConfigChanged. For now we just trigger a decode error.
200 AudioDecoder::Status decoder_status = 205 AudioDecoder::Status decoder_status =
201 (status == DemuxerStream::kAborted) ? kAborted : kDecodeError; 206 (status == DemuxerStream::kAborted) ? kAborted : kDecodeError;
202 base::ResetAndReturn(&read_cb_).Run(decoder_status, NULL); 207 base::ResetAndReturn(&read_cb_).Run(decoder_status, NULL);
203 return; 208 return;
204 } 209 }
205 210
206 // Make sure we are notified if http://crbug.com/49709 returns. Issue also 211 // Make sure we are notified if http://crbug.com/49709 returns. Issue also
207 // occurs with some damaged files. 212 // occurs with some damaged files.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 363
359 // Execute callback to return the first frame we decoded. 364 // Execute callback to return the first frame we decoded.
360 base::ResetAndReturn(&read_cb_).Run( 365 base::ResetAndReturn(&read_cb_).Run(
361 queued_audio_.front().status, queued_audio_.front().buffer); 366 queued_audio_.front().status, queued_audio_.front().buffer);
362 queued_audio_.pop_front(); 367 queued_audio_.pop_front();
363 } 368 }
364 369
365 void FFmpegAudioDecoder::ReadFromDemuxerStream() { 370 void FFmpegAudioDecoder::ReadFromDemuxerStream() {
366 DCHECK(!read_cb_.is_null()); 371 DCHECK(!read_cb_.is_null());
367 372
368 demuxer_stream_->Read(base::Bind(&FFmpegAudioDecoder::DecodeBuffer, this)); 373 demuxer_stream_->Read(base::Bind(&FFmpegAudioDecoder::DoDecodeBuffer, this));
369 }
370
371 void FFmpegAudioDecoder::DecodeBuffer(
372 DemuxerStream::Status status,
373 const scoped_refptr<DecoderBuffer>& buffer) {
374 DCHECK_EQ(status != DemuxerStream::kOk, !buffer) << status;
375
376 // TODO(scherkus): fix FFmpegDemuxerStream::Read() to not execute our read
377 // callback on the same execution stack so we can get rid of forced task post.
378 message_loop_->PostTask(FROM_HERE, base::Bind(
379 &FFmpegAudioDecoder::DoDecodeBuffer, this, status, buffer));
380 } 374 }
381 375
382 base::TimeDelta FFmpegAudioDecoder::GetNextOutputTimestamp() const { 376 base::TimeDelta FFmpegAudioDecoder::GetNextOutputTimestamp() const {
383 DCHECK(output_timestamp_base_ != kNoTimestamp()); 377 DCHECK(output_timestamp_base_ != kNoTimestamp());
384 double decoded_us = (total_frames_decoded_ / samples_per_second_) * 378 double decoded_us = (total_frames_decoded_ / samples_per_second_) *
385 base::Time::kMicrosecondsPerSecond; 379 base::Time::kMicrosecondsPerSecond;
386 return output_timestamp_base_ + base::TimeDelta::FromMicroseconds(decoded_us); 380 return output_timestamp_base_ + base::TimeDelta::FromMicroseconds(decoded_us);
387 } 381 }
382
388 } // namespace media 383 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698