OLD | NEW |
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_config.h" | 8 #include "media/base/audio_decoder_config.h" |
9 #include "media/base/data_buffer.h" | 9 #include "media/base/data_buffer.h" |
10 #include "media/base/demuxer.h" | 10 #include "media/base/demuxer.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 callback.Run(DECODER_ERROR_NOT_SUPPORTED); | 121 callback.Run(DECODER_ERROR_NOT_SUPPORTED); |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 // Initialize AVCodecContext structure. | 125 // Initialize AVCodecContext structure. |
126 codec_context_ = avcodec_alloc_context(); | 126 codec_context_ = avcodec_alloc_context(); |
127 AudioDecoderConfigToAVCodecContext(config, codec_context_); | 127 AudioDecoderConfigToAVCodecContext(config, codec_context_); |
128 | 128 |
129 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); | 129 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); |
130 if (!codec || avcodec_open(codec_context_, codec) < 0) { | 130 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { |
131 DLOG(ERROR) << "Could not initialize audio decoder: " | 131 DLOG(ERROR) << "Could not initialize audio decoder: " |
132 << codec_context_->codec_id; | 132 << codec_context_->codec_id; |
133 | 133 |
134 callback.Run(DECODER_ERROR_NOT_SUPPORTED); | 134 callback.Run(DECODER_ERROR_NOT_SUPPORTED); |
135 return; | 135 return; |
136 } | 136 } |
137 | 137 |
138 // Success! | 138 // Success! |
139 bits_per_channel_ = config.bits_per_channel(); | 139 bits_per_channel_ = config.bits_per_channel(); |
140 channel_layout_ = config.channel_layout(); | 140 channel_layout_ = config.channel_layout(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 | 285 |
286 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { | 286 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { |
287 // Reset the callback before running to protect against reentrancy. | 287 // Reset the callback before running to protect against reentrancy. |
288 ReadCB read_cb = read_cb_; | 288 ReadCB read_cb = read_cb_; |
289 read_cb_.Reset(); | 289 read_cb_.Reset(); |
290 read_cb.Run(samples); | 290 read_cb.Run(samples); |
291 } | 291 } |
292 | 292 |
293 } // namespace media | 293 } // namespace media |
OLD | NEW |