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/audio_file_reader.h" | 5 #include "media/filters/audio_file_reader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <vector> | 10 #include <vector> |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if (!frame_decoded) | 173 if (!frame_decoded) |
174 continue; | 174 continue; |
175 | 175 |
176 // Determine the number of sample-frames we just decoded. Check overflow. | 176 // Determine the number of sample-frames we just decoded. Check overflow. |
177 int frames_read = av_frame->nb_samples; | 177 int frames_read = av_frame->nb_samples; |
178 if (frames_read < 0) { | 178 if (frames_read < 0) { |
179 continue_decoding = false; | 179 continue_decoding = false; |
180 break; | 180 break; |
181 } | 181 } |
182 | 182 |
183 #ifdef CHROMIUM_NO_AVFRAME_CHANNELS | |
184 int channels = | |
185 av_get_channel_layout_nb_channels(av_frame->channel_layout); | |
186 #else | |
187 int channels = av_frame->channels; | 183 int channels = av_frame->channels; |
188 #endif | |
189 if (av_frame->sample_rate != sample_rate_ || channels != channels_ || | 184 if (av_frame->sample_rate != sample_rate_ || channels != channels_ || |
190 av_frame->format != av_sample_format_) { | 185 av_frame->format != av_sample_format_) { |
191 DLOG(ERROR) << "Unsupported midstream configuration change!" | 186 DLOG(ERROR) << "Unsupported midstream configuration change!" |
192 << " Sample Rate: " << av_frame->sample_rate << " vs " | 187 << " Sample Rate: " << av_frame->sample_rate << " vs " |
193 << sample_rate_ << ", Channels: " << channels << " vs " | 188 << sample_rate_ << ", Channels: " << channels << " vs " |
194 << channels_ << ", Sample Format: " << av_frame->format | 189 << channels_ << ", Sample Format: " << av_frame->format |
195 << " vs " << av_sample_format_; | 190 << " vs " << av_sample_format_; |
196 | 191 |
197 // This is an unrecoverable error, so bail out. We'll return | 192 // This is an unrecoverable error, so bail out. We'll return |
198 // whatever we've decoded up to this point. | 193 // whatever we've decoded up to this point. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 glue_->format_context(), stream_index_, | 283 glue_->format_context(), stream_index_, |
289 ConvertToTimeBase(GetAVStreamForTesting()->time_base, seek_time), | 284 ConvertToTimeBase(GetAVStreamForTesting()->time_base, seek_time), |
290 AVSEEK_FLAG_BACKWARD) >= 0; | 285 AVSEEK_FLAG_BACKWARD) >= 0; |
291 } | 286 } |
292 | 287 |
293 const AVStream* AudioFileReader::GetAVStreamForTesting() const { | 288 const AVStream* AudioFileReader::GetAVStreamForTesting() const { |
294 return glue_->format_context()->streams[stream_index_]; | 289 return glue_->format_context()->streams[stream_index_]; |
295 } | 290 } |
296 | 291 |
297 } // namespace media | 292 } // namespace media |
OLD | NEW |