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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported."; | 162 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported."; |
163 | 163 |
164 read_cb_ = callback; | 164 read_cb_ = callback; |
165 ReadFromDemuxerStream(); | 165 ReadFromDemuxerStream(); |
166 } | 166 } |
167 | 167 |
168 void FFmpegAudioDecoder::DoDecodeBuffer(const scoped_refptr<Buffer>& input) { | 168 void FFmpegAudioDecoder::DoDecodeBuffer(const scoped_refptr<Buffer>& input) { |
169 DCHECK_EQ(MessageLoop::current(), message_loop_); | 169 DCHECK_EQ(MessageLoop::current(), message_loop_); |
170 DCHECK(!read_cb_.is_null()); | 170 DCHECK(!read_cb_.is_null()); |
171 | 171 |
| 172 if (!input) { |
| 173 // DemuxeStream::Read() was aborted so we abort the decoder's pending read. |
| 174 DeliverSamples(NULL); |
| 175 return; |
| 176 } |
| 177 |
172 // FFmpeg tends to seek Ogg audio streams in the middle of nowhere, giving us | 178 // FFmpeg tends to seek Ogg audio streams in the middle of nowhere, giving us |
173 // a whole bunch of AV_NOPTS_VALUE packets. Discard them until we find | 179 // a whole bunch of AV_NOPTS_VALUE packets. Discard them until we find |
174 // something valid. Refer to http://crbug.com/49709 | 180 // something valid. Refer to http://crbug.com/49709 |
175 if (input->GetTimestamp() == kNoTimestamp() && | 181 if (input->GetTimestamp() == kNoTimestamp() && |
176 estimated_next_timestamp_ == kNoTimestamp() && | 182 estimated_next_timestamp_ == kNoTimestamp() && |
177 !input->IsEndOfStream()) { | 183 !input->IsEndOfStream()) { |
178 ReadFromDemuxerStream(); | 184 ReadFromDemuxerStream(); |
179 return; | 185 return; |
180 } | 186 } |
181 | 187 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 291 } |
286 | 292 |
287 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { | 293 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { |
288 // Reset the callback before running to protect against reentrancy. | 294 // Reset the callback before running to protect against reentrancy. |
289 ReadCB read_cb = read_cb_; | 295 ReadCB read_cb = read_cb_; |
290 read_cb_.Reset(); | 296 read_cb_.Reset(); |
291 read_cb.Run(samples); | 297 read_cb.Run(samples); |
292 } | 298 } |
293 | 299 |
294 } // namespace media | 300 } // namespace media |
OLD | NEW |