| 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/media_codec_bridge.h" | 10 #include "media/base/android/sdk_media_codec_bridge.h" |
| 11 #include "media/base/audio_timestamp_helper.h" | 11 #include "media/base/audio_timestamp_helper.h" |
| 12 #include "media/base/timestamp_constants.h" | 12 #include "media/base/timestamp_constants.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Use 16bit PCM for audio output. Keep this value in sync with the output | 16 // Use 16bit PCM for audio output. Keep this value in sync with the output |
| 17 // format we passed to AudioTrack in MediaCodecBridge. | 17 // format we passed to AudioTrack in MediaCodecBridge. |
| 18 const int kBytesPerAudioOutputSample = 2; | 18 const int kBytesPerAudioOutputSample = 2; |
| 19 } | 19 } |
| 20 | 20 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 audio_extra_data_.end(), | 154 audio_extra_data_.end(), |
| 155 configs.audio_extra_data.begin()); | 155 configs.audio_extra_data.begin()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 MediaDecoderJob::MediaDecoderJobStatus | 158 MediaDecoderJob::MediaDecoderJobStatus |
| 159 AudioDecoderJob::CreateMediaCodecBridgeInternal() { | 159 AudioDecoderJob::CreateMediaCodecBridgeInternal() { |
| 160 media_codec_bridge_.reset(AudioCodecBridge::Create(audio_codec_)); | 160 media_codec_bridge_.reset(AudioCodecBridge::Create(audio_codec_)); |
| 161 if (!media_codec_bridge_) | 161 if (!media_codec_bridge_) |
| 162 return STATUS_FAILURE; | 162 return STATUS_FAILURE; |
| 163 | 163 |
| 164 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get()))->Start( | 164 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) |
| 165 audio_codec_, config_sampling_rate_, num_channels_, &audio_extra_data_[0], | 165 ->ConfigureAndStart(audio_codec_, config_sampling_rate_, |
| 166 audio_extra_data_.size(), audio_codec_delay_ns_, audio_seek_preroll_ns_, | 166 num_channels_, &audio_extra_data_[0], |
| 167 true, GetMediaCrypto())) { | 167 audio_extra_data_.size(), audio_codec_delay_ns_, |
| 168 audio_seek_preroll_ns_, true, |
| 169 GetMediaCrypto())) { |
| 168 media_codec_bridge_.reset(); | 170 media_codec_bridge_.reset(); |
| 169 return STATUS_FAILURE; | 171 return STATUS_FAILURE; |
| 170 } | 172 } |
| 171 | 173 |
| 172 SetVolumeInternal(); | 174 SetVolumeInternal(); |
| 173 | 175 |
| 174 // Reset values used to track codec bridge output | 176 // Reset values used to track codec bridge output |
| 175 frame_count_ = 0; | 177 frame_count_ = 0; |
| 176 ResetTimestampHelper(); | 178 ResetTimestampHelper(); |
| 177 | 179 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 188 void AudioDecoderJob::OnOutputFormatChanged() { | 190 void AudioDecoderJob::OnOutputFormatChanged() { |
| 189 DCHECK(media_codec_bridge_); | 191 DCHECK(media_codec_bridge_); |
| 190 | 192 |
| 191 int old_sampling_rate = output_sampling_rate_; | 193 int old_sampling_rate = output_sampling_rate_; |
| 192 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 194 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); |
| 193 if (output_sampling_rate_ != old_sampling_rate) | 195 if (output_sampling_rate_ != old_sampling_rate) |
| 194 ResetTimestampHelper(); | 196 ResetTimestampHelper(); |
| 195 } | 197 } |
| 196 | 198 |
| 197 } // namespace media | 199 } // namespace media |
| OLD | NEW |