OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base/android/audio_decoder_job.h" | 5 #include "media/base/android/audio_decoder_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "media/base/android/sdk_media_codec_bridge.h" | 10 #include "media/base/android/sdk_media_codec_bridge.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) | 179 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) |
180 ->ConfigureAndStart(audio_codec_, config_sampling_rate_, | 180 ->ConfigureAndStart(audio_codec_, config_sampling_rate_, |
181 config_num_channels_, &audio_extra_data_[0], | 181 config_num_channels_, &audio_extra_data_[0], |
182 audio_extra_data_.size(), audio_codec_delay_ns_, | 182 audio_extra_data_.size(), audio_codec_delay_ns_, |
183 audio_seek_preroll_ns_, true, | 183 audio_seek_preroll_ns_, true, |
184 GetMediaCrypto())) { | 184 GetMediaCrypto())) { |
185 media_codec_bridge_.reset(); | 185 media_codec_bridge_.reset(); |
186 return STATUS_FAILURE; | 186 return STATUS_FAILURE; |
187 } | 187 } |
188 | 188 |
| 189 // ConfigureAndStart() creates AudioTrack with |config_sampling_rate_| |
| 190 // and |config_num_channels_|. Keep |output_...| in sync to detect the changes |
| 191 // that might come with OnOutputFormatChanged(). |
| 192 output_sampling_rate_ = config_sampling_rate_; |
| 193 output_num_channels_ = config_num_channels_; |
| 194 |
189 SetVolumeInternal(); | 195 SetVolumeInternal(); |
190 | 196 |
191 // Reset values used to track codec bridge output | 197 // Reset values used to track codec bridge output |
192 frame_count_ = 0; | 198 frame_count_ = 0; |
193 ResetTimestampHelper(); | 199 ResetTimestampHelper(); |
194 | 200 |
195 return STATUS_SUCCESS; | 201 return STATUS_SUCCESS; |
196 } | 202 } |
197 | 203 |
198 void AudioDecoderJob::SetVolumeInternal() { | 204 void AudioDecoderJob::SetVolumeInternal() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 !static_cast<AudioCodecBridge*>(media_codec_bridge_.get()) | 240 !static_cast<AudioCodecBridge*>(media_codec_bridge_.get()) |
235 ->CreateAudioTrack(output_sampling_rate_, output_num_channels_)) { | 241 ->CreateAudioTrack(output_sampling_rate_, output_num_channels_)) { |
236 DLOG(ERROR) << __FUNCTION__ << ": cannot create AudioTrack"; | 242 DLOG(ERROR) << __FUNCTION__ << ": cannot create AudioTrack"; |
237 return false; | 243 return false; |
238 } | 244 } |
239 | 245 |
240 return true; | 246 return true; |
241 } | 247 } |
242 | 248 |
243 } // namespace media | 249 } // namespace media |
OLD | NEW |