Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chromecast/media/audio/cast_audio_output_stream.cc

Issue 1365173005: [Chromecast] Move audio logging from PushFrame to Start. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/audio/cast_audio_output_stream.h" 5 #include "chromecast/media/audio/cast_audio_output_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "chromecast/base/metrics/cast_metrics_helper.h" 9 #include "chromecast/base/metrics/cast_metrics_helper.h"
10 #include "chromecast/media/audio/cast_audio_manager.h" 10 #include "chromecast/media/audio/cast_audio_manager.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 AudioPipelineDevice* audio_device = media_pipeline_backend_->GetAudio(); 145 AudioPipelineDevice* audio_device = media_pipeline_backend_->GetAudio();
146 DCHECK(audio_device); 146 DCHECK(audio_device);
147 if (!audio_device->SetState(AudioPipelineDevice::kStateRunning)) { 147 if (!audio_device->SetState(AudioPipelineDevice::kStateRunning)) {
148 LOG(WARNING) << "Failed to run audio device."; 148 LOG(WARNING) << "Failed to run audio device.";
149 return; 149 return;
150 } 150 }
151 151
152 VLOG(1) << __FUNCTION__ << " : " << this; 152 VLOG(1) << __FUNCTION__ << " : " << this;
153 audio_worker_->Start(base::Bind(&CastAudioOutputStream::PushFrame, 153 audio_worker_->Start(base::Bind(&CastAudioOutputStream::PushFrame,
154 weak_factory_.GetWeakPtr(), source_callback)); 154 weak_factory_.GetWeakPtr(), source_callback));
155
156 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstAudio();
155 } 157 }
156 158
157 void CastAudioOutputStream::Stop() { 159 void CastAudioOutputStream::Stop() {
158 VLOG(1) << __FUNCTION__ << " : " << this; 160 VLOG(1) << __FUNCTION__ << " : " << this;
159 161
160 MediaClockDevice* clock_device = media_pipeline_backend_->GetClock(); 162 MediaClockDevice* clock_device = media_pipeline_backend_->GetClock();
161 DCHECK(clock_device); 163 DCHECK(clock_device);
162 clock_device->SetState(MediaClockDevice::kStateIdle); 164 clock_device->SetState(MediaClockDevice::kStateIdle);
163 clock_device->SetRate(0.0f); 165 clock_device->SetRate(0.0f);
164 166
(...skipping 17 matching lines...) Expand all
182 184
183 void CastAudioOutputStream::PushFrame(AudioSourceCallback* source_callback) { 185 void CastAudioOutputStream::PushFrame(AudioSourceCallback* source_callback) {
184 DCHECK(source_callback); 186 DCHECK(source_callback);
185 if (audio_device_busy_) { 187 if (audio_device_busy_) {
186 // Skip pulling data if audio device is still busy. 188 // Skip pulling data if audio device is still busy.
187 LOG(WARNING) << __FUNCTION__ << " : " << this 189 LOG(WARNING) << __FUNCTION__ << " : " << this
188 << " skipped because audio device is busy."; 190 << " skipped because audio device is busy.";
189 return; 191 return;
190 } 192 }
191 193
192 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstAudio();
193
194 int frame_count = source_callback->OnMoreData(audio_bus_.get(), 0); 194 int frame_count = source_callback->OnMoreData(audio_bus_.get(), 0);
195 DCHECK_EQ(frame_count, audio_bus_->frames()); 195 DCHECK_EQ(frame_count, audio_bus_->frames());
196 int buffer_size = frame_count * audio_params_.GetBytesPerFrame(); 196 int buffer_size = frame_count * audio_params_.GetBytesPerFrame();
197 scoped_refptr<::media::DecoderBuffer> decoder_buffer( 197 scoped_refptr<::media::DecoderBuffer> decoder_buffer(
198 new ::media::DecoderBuffer(buffer_size)); 198 new ::media::DecoderBuffer(buffer_size));
199 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, 199 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8,
200 decoder_buffer->writable_data()); 200 decoder_buffer->writable_data());
201 201
202 AudioPipelineDevice* audio_device = media_pipeline_backend_->GetAudio(); 202 AudioPipelineDevice* audio_device = media_pipeline_backend_->GetAudio();
203 DCHECK(audio_device); 203 DCHECK(audio_device);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 void CastAudioOutputStream::OnPushFrameError( 235 void CastAudioOutputStream::OnPushFrameError(
236 AudioSourceCallback* source_callback) { 236 AudioSourceCallback* source_callback) {
237 LOG(WARNING) << __FUNCTION__ << " : " << this; 237 LOG(WARNING) << __FUNCTION__ << " : " << this;
238 // Inform audio source about the error and stop pulling data. 238 // Inform audio source about the error and stop pulling data.
239 audio_worker_->Stop(); 239 audio_worker_->Stop();
240 source_callback->OnError(this); 240 source_callback->OnError(this);
241 } 241 }
242 242
243 } // namespace media 243 } // namespace media
244 } // namespace chromecast 244 } // namespace chromecast
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698