Chromium Code Reviews| 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/audio/audio_output_device.h" | 5 #include "media/audio/audio_output_device.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "media/audio/audio_output_controller.h" | 11 #include "media/audio/audio_output_controller.h" |
| 12 #include "media/base/limits.h" | 12 #include "media/base/limits.h" |
| 13 #include "media/base/scoped_histogram_timer.h" | |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 | 16 |
| 16 // Takes care of invoking the render callback on the audio thread. | 17 // Takes care of invoking the render callback on the audio thread. |
| 17 // An instance of this class is created for each capture stream in | 18 // An instance of this class is created for each capture stream in |
| 18 // OnStreamCreated(). | 19 // OnStreamCreated(). |
| 19 class AudioOutputDevice::AudioThreadCallback | 20 class AudioOutputDevice::AudioThreadCallback |
| 20 : public AudioDeviceThread::Callback { | 21 : public AudioDeviceThread::Callback { |
| 21 public: | 22 public: |
| 22 AudioThreadCallback(const AudioParameters& audio_parameters, | 23 AudioThreadCallback(const AudioParameters& audio_parameters, |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 output_bus_ = | 284 output_bus_ = |
| 284 AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory()); | 285 AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory()); |
| 285 } | 286 } |
| 286 | 287 |
| 287 // Called whenever we receive notifications about pending data. | 288 // Called whenever we receive notifications about pending data. |
| 288 void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) { | 289 void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) { |
| 289 // Negative |pending_data| indicates the browser side stream has stopped. | 290 // Negative |pending_data| indicates the browser side stream has stopped. |
| 290 if (pending_data < 0) | 291 if (pending_data < 0) |
| 291 return; | 292 return; |
| 292 | 293 |
| 294 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputDevice.ProcessTime"); | |
|
no longer working on chromium
2014/09/17 14:54:50
I would suggest moving the code to webrtc_audio_re
henrika (OOO until Aug 14)
2014/09/18 10:56:47
I could move it but AFAIK it is not possible to lo
henrika (OOO until Aug 14)
2014/09/18 11:03:16
Let me see if I can do something without the macro
| |
| 295 | |
| 293 // Convert the number of pending bytes in the render buffer into milliseconds. | 296 // Convert the number of pending bytes in the render buffer into milliseconds. |
| 294 int audio_delay_milliseconds = pending_data / bytes_per_ms_; | 297 int audio_delay_milliseconds = pending_data / bytes_per_ms_; |
| 295 | 298 |
| 296 TRACE_EVENT0("audio", "AudioOutputDevice::FireRenderCallback"); | 299 TRACE_EVENT0("audio", "AudioOutputDevice::FireRenderCallback"); |
| 297 | 300 |
| 298 // Update the audio-delay measurement then ask client to render audio. Since | 301 // Update the audio-delay measurement then ask client to render audio. Since |
| 299 // |output_bus_| is wrapping the shared memory the Render() call is writing | 302 // |output_bus_| is wrapping the shared memory the Render() call is writing |
| 300 // directly into the shared memory. | 303 // directly into the shared memory. |
| 301 render_callback_->Render(output_bus_.get(), audio_delay_milliseconds); | 304 render_callback_->Render(output_bus_.get(), audio_delay_milliseconds); |
| 302 } | 305 } |
| 303 | 306 |
| 304 } // namespace media. | 307 } // namespace media. |
| OLD | NEW |