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

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

Issue 9325044: Remove AudioDecoder from the Filter heirarchy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
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 "media/base/audio_decoder.h"
8 #include "media/base/audio_decoder_config.h" 9 #include "media/base/audio_decoder_config.h"
9 #include "media/base/data_buffer.h" 10 #include "media/base/data_buffer.h"
10 #include "media/base/demuxer.h" 11 #include "media/base/demuxer.h"
11 #include "media/base/filter_host.h"
12 #include "media/base/pipeline.h" 12 #include "media/base/pipeline.h"
13 #include "media/ffmpeg/ffmpeg_common.h" 13 #include "media/ffmpeg/ffmpeg_common.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 // Returns true if the decode result was an error. 17 // Returns true if the decode result was an error.
18 static bool IsErrorResult(int result, int decoded_size) { 18 static bool IsErrorResult(int result, int decoded_size) {
19 return result < 0 || 19 return result < 0 ||
20 decoded_size < 0 || 20 decoded_size < 0 ||
21 decoded_size > AVCODEC_MAX_AUDIO_FRAME_SIZE; 21 decoded_size > AVCODEC_MAX_AUDIO_FRAME_SIZE;
(...skipping 30 matching lines...) Expand all
52 bits_per_channel_(0), 52 bits_per_channel_(0),
53 channel_layout_(CHANNEL_LAYOUT_NONE), 53 channel_layout_(CHANNEL_LAYOUT_NONE),
54 samples_per_second_(0), 54 samples_per_second_(0),
55 decoded_audio_size_(AVCODEC_MAX_AUDIO_FRAME_SIZE), 55 decoded_audio_size_(AVCODEC_MAX_AUDIO_FRAME_SIZE),
56 decoded_audio_(static_cast<uint8*>(av_malloc(decoded_audio_size_))) { 56 decoded_audio_(static_cast<uint8*>(av_malloc(decoded_audio_size_))) {
57 } 57 }
58 58
59 FFmpegAudioDecoder::~FFmpegAudioDecoder() { 59 FFmpegAudioDecoder::~FFmpegAudioDecoder() {
60 av_free(decoded_audio_); 60 av_free(decoded_audio_);
61 61
62 // XXX: should we require Stop() to be called? this might end up getting 62 // XXX: should we require Stop() to be called? this might end up getting
scherkus (not reviewing) 2012/02/03 23:31:29 can you change this to TODO(scherkus) I use XXX a
Ami GONE FROM CHROMIUM 2012/02/04 00:10:21 Done.
63 // called on a random thread due to refcounting. 63 // called on a random thread due to refcounting.
64 if (codec_context_) { 64 if (codec_context_) {
65 av_free(codec_context_->extradata); 65 av_free(codec_context_->extradata);
66 avcodec_close(codec_context_); 66 avcodec_close(codec_context_);
67 av_free(codec_context_); 67 av_free(codec_context_);
68 } 68 }
69 } 69 }
70 70
71 void FFmpegAudioDecoder::Flush(const base::Closure& callback) {
scherkus (not reviewing) 2012/02/03 23:31:29 \o/
Ami GONE FROM CHROMIUM 2012/02/04 00:10:21 Done.
72 message_loop_->PostTask(
73 FROM_HERE,
74 base::Bind(&FFmpegAudioDecoder::DoFlush, this, callback));
75 }
76
77 void FFmpegAudioDecoder::Initialize( 71 void FFmpegAudioDecoder::Initialize(
78 DemuxerStream* stream, 72 DemuxerStream* stream,
79 const PipelineStatusCB& callback, 73 const PipelineStatusCB& callback,
80 const StatisticsCallback& stats_callback) { 74 const StatisticsCallback& stats_callback) {
81 // TODO(scherkus): change Initialize() signature to pass |stream| as a 75 // TODO(scherkus): change Initialize() signature to pass |stream| as a
82 // scoped_refptr<>. 76 // scoped_refptr<>.
83 scoped_refptr<DemuxerStream> ref_stream(stream); 77 scoped_refptr<DemuxerStream> ref_stream(stream);
84 message_loop_->PostTask( 78 message_loop_->PostTask(
85 FROM_HERE, 79 FROM_HERE,
86 base::Bind(&FFmpegAudioDecoder::DoInitialize, this, 80 base::Bind(&FFmpegAudioDecoder::DoInitialize, this,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 283 }
290 284
291 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { 285 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) {
292 // Reset the callback before running to protect against reentrancy. 286 // Reset the callback before running to protect against reentrancy.
293 ReadCB read_cb = read_cb_; 287 ReadCB read_cb = read_cb_;
294 read_cb_.Reset(); 288 read_cb_.Reset();
295 read_cb.Run(samples); 289 read_cb.Run(samples);
296 } 290 }
297 291
298 } // namespace media 292 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698