| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/media/cma/pipeline/audio_pipeline_impl.h" | 5 #include "chromecast/media/cma/pipeline/audio_pipeline_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chromecast/media/cma/backend/audio_pipeline_device.h" | 8 #include "chromecast/media/cma/backend/audio_pipeline_device.h" |
| 9 #include "chromecast/media/cma/base/buffering_defs.h" | 9 #include "chromecast/media/cma/base/buffering_defs.h" |
| 10 #include "chromecast/media/cma/base/cma_logging.h" | 10 #include "chromecast/media/cma/base/cma_logging.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 void AudioPipelineImpl::Initialize( | 103 void AudioPipelineImpl::Initialize( |
| 104 const ::media::AudioDecoderConfig& audio_config, | 104 const ::media::AudioDecoderConfig& audio_config, |
| 105 scoped_ptr<CodedFrameProvider> frame_provider, | 105 scoped_ptr<CodedFrameProvider> frame_provider, |
| 106 const ::media::PipelineStatusCB& status_cb) { | 106 const ::media::PipelineStatusCB& status_cb) { |
| 107 CMALOG(kLogControl) << "AudioPipelineImpl::Initialize " | 107 CMALOG(kLogControl) << "AudioPipelineImpl::Initialize " |
| 108 << audio_config.AsHumanReadableString(); | 108 << audio_config.AsHumanReadableString(); |
| 109 if (frame_provider) | 109 if (frame_provider) |
| 110 SetCodedFrameProvider(frame_provider.Pass()); | 110 SetCodedFrameProvider(frame_provider.Pass()); |
| 111 | 111 |
| 112 DCHECK(audio_config.IsValidConfig()); |
| 112 if (!audio_device_->SetConfig( | 113 if (!audio_device_->SetConfig( |
| 113 DecoderConfigAdapter::ToCastAudioConfig(kPrimary, audio_config)) || | 114 DecoderConfigAdapter::ToCastAudioConfig(kPrimary, audio_config)) || |
| 114 !av_pipeline_impl_->Initialize()) { | 115 !av_pipeline_impl_->Initialize()) { |
| 115 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); | 116 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); |
| 116 return; | 117 return; |
| 117 } | 118 } |
| 118 av_pipeline_impl_->TransitionToState(AvPipelineImpl::kFlushed); | 119 av_pipeline_impl_->TransitionToState(AvPipelineImpl::kFlushed); |
| 119 status_cb.Run(::media::PIPELINE_OK); | 120 status_cb.Run(::media::PIPELINE_OK); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void AudioPipelineImpl::SetVolume(float volume) { | 123 void AudioPipelineImpl::SetVolume(float volume) { |
| 123 audio_device_->SetStreamVolumeMultiplier(volume); | 124 audio_device_->SetStreamVolumeMultiplier(volume); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void AudioPipelineImpl::OnUpdateConfig( | 127 void AudioPipelineImpl::OnUpdateConfig( |
| 127 StreamId id, | 128 StreamId id, |
| 128 const ::media::AudioDecoderConfig& audio_config, | 129 const ::media::AudioDecoderConfig& audio_config, |
| 129 const ::media::VideoDecoderConfig& video_config) { | 130 const ::media::VideoDecoderConfig& video_config) { |
| 131 DCHECK(!video_config.IsValidConfig()); |
| 130 if (audio_config.IsValidConfig()) { | 132 if (audio_config.IsValidConfig()) { |
| 131 CMALOG(kLogControl) << "AudioPipelineImpl::OnUpdateConfig id:" << id << " " | 133 CMALOG(kLogControl) << "AudioPipelineImpl::OnUpdateConfig id:" << id << " " |
| 132 << audio_config.AsHumanReadableString(); | 134 << audio_config.AsHumanReadableString(); |
| 133 | 135 |
| 134 bool success = audio_device_->SetConfig( | 136 bool success = audio_device_->SetConfig( |
| 135 DecoderConfigAdapter::ToCastAudioConfig(id, audio_config)); | 137 DecoderConfigAdapter::ToCastAudioConfig(id, audio_config)); |
| 136 if (!success && !audio_client_.playback_error_cb.is_null()) | 138 if (!success && !audio_client_.playback_error_cb.is_null()) |
| 137 audio_client_.playback_error_cb.Run(::media::PIPELINE_ERROR_DECODE); | 139 audio_client_.playback_error_cb.Run(::media::PIPELINE_ERROR_DECODE); |
| 138 } | 140 } |
| 139 } | 141 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 153 delta_stats.audio_bytes_decoded = | 155 delta_stats.audio_bytes_decoded = |
| 154 current_stats.audio_bytes_decoded - previous_stats_.audio_bytes_decoded; | 156 current_stats.audio_bytes_decoded - previous_stats_.audio_bytes_decoded; |
| 155 | 157 |
| 156 previous_stats_ = current_stats; | 158 previous_stats_ = current_stats; |
| 157 | 159 |
| 158 audio_client_.statistics_cb.Run(delta_stats); | 160 audio_client_.statistics_cb.Run(delta_stats); |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace media | 163 } // namespace media |
| 162 } // namespace chromecast | 164 } // namespace chromecast |
| OLD | NEW |