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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 callback.Run(DECODER_ERROR_NOT_SUPPORTED); | 126 callback.Run(DECODER_ERROR_NOT_SUPPORTED); |
127 return; | 127 return; |
128 } | 128 } |
129 | 129 |
130 // Initialize AVCodecContext structure. | 130 // Initialize AVCodecContext structure. |
131 codec_context_ = avcodec_alloc_context(); | 131 codec_context_ = avcodec_alloc_context(); |
132 AudioDecoderConfigToAVCodecContext(config, codec_context_); | 132 AudioDecoderConfigToAVCodecContext(config, codec_context_); |
133 | 133 |
134 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); | 134 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); |
135 if (!codec || avcodec_open(codec_context_, codec) < 0) { | 135 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { |
136 DLOG(ERROR) << "Could not initialize audio decoder: " | 136 DLOG(ERROR) << "Could not initialize audio decoder: " |
137 << codec_context_->codec_id; | 137 << codec_context_->codec_id; |
138 | 138 |
139 callback.Run(DECODER_ERROR_NOT_SUPPORTED); | 139 callback.Run(DECODER_ERROR_NOT_SUPPORTED); |
140 return; | 140 return; |
141 } | 141 } |
142 | 142 |
143 // Success! | 143 // Success! |
144 bits_per_channel_ = config.bits_per_channel(); | 144 bits_per_channel_ = config.bits_per_channel(); |
145 channel_layout_ = config.channel_layout(); | 145 channel_layout_ = config.channel_layout(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 | 290 |
291 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { | 291 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { |
292 // Reset the callback before running to protect against reentrancy. | 292 // Reset the callback before running to protect against reentrancy. |
293 ReadCB read_cb = read_cb_; | 293 ReadCB read_cb = read_cb_; |
294 read_cb_.Reset(); | 294 read_cb_.Reset(); |
295 read_cb.Run(samples); | 295 read_cb.Run(samples); |
296 } | 296 } |
297 | 297 |
298 } // namespace media | 298 } // namespace media |
OLD | NEW |