| 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 "content/renderer/media/webrtc_local_audio_renderer.h" | 5 #include "content/renderer/media/webrtc_local_audio_renderer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 kSinkNeverStarted, | 31 kSinkNeverStarted, |
| 32 kSinkStatesMax // Must always be last! | 32 kSinkStatesMax // Must always be last! |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 // media::AudioRendererSink::RenderCallback implementation | 37 // media::AudioRendererSink::RenderCallback implementation |
| 38 int WebRtcLocalAudioRenderer::Render(media::AudioBus* audio_bus, | 38 int WebRtcLocalAudioRenderer::Render(media::AudioBus* audio_bus, |
| 39 uint32_t audio_delay_milliseconds, | 39 uint32_t audio_delay_milliseconds, |
| 40 uint32_t frames_skipped) { | 40 uint32_t frames_skipped) { |
| 41 // NOTREACHED(); |
| 41 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::Render"); | 42 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::Render"); |
| 42 base::AutoLock auto_lock(thread_lock_); | 43 base::AutoLock auto_lock(thread_lock_); |
| 43 | 44 |
| 44 if (!playing_ || !volume_ || !audio_shifter_) { | 45 if (!playing_ || !volume_ || !audio_shifter_) { |
| 45 audio_bus->Zero(); | 46 audio_bus->Zero(); |
| 46 return 0; | 47 return 0; |
| 47 } | 48 } |
| 48 | 49 |
| 49 audio_shifter_->Pull( | 50 audio_shifter_->Pull( |
| 50 audio_bus, | 51 audio_bus, |
| 51 base::TimeTicks::Now() - | 52 base::TimeTicks::Now() - |
| 52 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds)); | 53 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds)); |
| 53 | 54 |
| 54 return audio_bus->frames(); | 55 return audio_bus->frames(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 void WebRtcLocalAudioRenderer::OnRenderError() { | 58 void WebRtcLocalAudioRenderer::OnRenderError() { |
| 58 NOTIMPLEMENTED(); | 59 NOTIMPLEMENTED(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 // content::MediaStreamAudioSink implementation | 62 // content::MediaStreamAudioSink implementation |
| 62 void WebRtcLocalAudioRenderer::OnData(const media::AudioBus& audio_bus, | 63 void WebRtcLocalAudioRenderer::OnData(const media::AudioBus& audio_bus, |
| 63 base::TimeTicks estimated_capture_time) { | 64 base::TimeTicks estimated_capture_time) { |
| 64 DCHECK(capture_thread_checker_.CalledOnValidThread()); | 65 // DCHECK(capture_thread_checker_.CalledOnValidThread()); |
| 65 DCHECK(!estimated_capture_time.is_null()); | 66 DCHECK(!estimated_capture_time.is_null()); |
| 66 | 67 |
| 67 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::CaptureData"); | 68 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::CaptureData"); |
| 68 | 69 |
| 69 base::AutoLock auto_lock(thread_lock_); | 70 base::AutoLock auto_lock(thread_lock_); |
| 70 if (!playing_ || !volume_ || !audio_shifter_) | 71 if (!playing_ || !volume_ || !audio_shifter_) |
| 71 return; | 72 return; |
| 72 | 73 |
| 73 scoped_ptr<media::AudioBus> audio_data( | 74 scoped_ptr<media::AudioBus> audio_data( |
| 74 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames())); | 75 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames())); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 WebRtcAudioRenderer::GetOptimalBufferSize(source_params_.sample_rate(), | 369 WebRtcAudioRenderer::GetOptimalBufferSize(source_params_.sample_rate(), |
| 369 hw_params.frames_per_buffer())); | 370 hw_params.frames_per_buffer())); |
| 370 } // Otherwise use source buffer size. | 371 } // Otherwise use source buffer size. |
| 371 // TODO(olka) come up with some default value of parameters in case of | 372 // TODO(olka) come up with some default value of parameters in case of |
| 372 // AUDIO_FAKE, to mix everything, since we don't care about real values in | 373 // AUDIO_FAKE, to mix everything, since we don't care about real values in |
| 373 // this case | 374 // this case |
| 374 MaybeStartSink(); | 375 MaybeStartSink(); |
| 375 } | 376 } |
| 376 | 377 |
| 377 } // namespace content | 378 } // namespace content |
| OLD | NEW |