Pass the elapsed time from VoE to WebRtcAudioRenderer as the current time for...

Pass the elapsed time from VoE to WebRtcAudioRenderer as the current time for the audio/video element.

BUG=367161
and webrtc 3111

R=xians@chromium.org

Review URL: https://codereview.chromium.org/328493003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276673 0039d316-1c4b-4281-b951-d872f2087c98
parent 9b5b1d60
...@@ -126,7 +126,8 @@ void WebRtcAudioDeviceImpl::OnSetFormat( ...@@ -126,7 +126,8 @@ void WebRtcAudioDeviceImpl::OnSetFormat(
void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus, void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus,
int sample_rate, int sample_rate,
int audio_delay_milliseconds) { int audio_delay_milliseconds,
base::TimeDelta* current_time) {
render_buffer_.resize(audio_bus->frames() * audio_bus->channels()); render_buffer_.resize(audio_bus->frames() * audio_bus->channels());
{ {
...@@ -179,7 +180,9 @@ void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus, ...@@ -179,7 +180,9 @@ void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus,
&ntp_time_ms); &ntp_time_ms);
accumulated_audio_frames += num_audio_frames; accumulated_audio_frames += num_audio_frames;
} }
if (elapsed_time_ms >= 0) {
*current_time = base::TimeDelta::FromMilliseconds(elapsed_time_ms);
}
audio_data += bytes_per_10_ms; audio_data += bytes_per_10_ms;
} }
......
...@@ -189,7 +189,8 @@ class WebRtcAudioRendererSource { ...@@ -189,7 +189,8 @@ class WebRtcAudioRendererSource {
// Callback to get the rendered data. // Callback to get the rendered data.
virtual void RenderData(media::AudioBus* audio_bus, virtual void RenderData(media::AudioBus* audio_bus,
int sample_rate, int sample_rate,
int audio_delay_milliseconds) = 0; int audio_delay_milliseconds,
base::TimeDelta* current_time) = 0;
// Callback to notify the client that the renderer is going away. // Callback to notify the client that the renderer is going away.
virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) = 0; virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) = 0;
...@@ -390,7 +391,8 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl ...@@ -390,7 +391,8 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl
// Called on the AudioOutputDevice worker thread. // Called on the AudioOutputDevice worker thread.
virtual void RenderData(media::AudioBus* audio_bus, virtual void RenderData(media::AudioBus* audio_bus,
int sample_rate, int sample_rate,
int audio_delay_milliseconds) OVERRIDE; int audio_delay_milliseconds,
base::TimeDelta* current_time) OVERRIDE;
// Called on the main render thread. // Called on the main render thread.
virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) OVERRIDE; virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) OVERRIDE;
......
...@@ -450,7 +450,9 @@ void WebRtcAudioRenderer::SetVolume(float volume) { ...@@ -450,7 +450,9 @@ void WebRtcAudioRenderer::SetVolume(float volume) {
} }
base::TimeDelta WebRtcAudioRenderer::GetCurrentRenderTime() const { base::TimeDelta WebRtcAudioRenderer::GetCurrentRenderTime() const {
return base::TimeDelta(); DCHECK(thread_checker_.CalledOnValidThread());
base::AutoLock auto_lock(lock_);
return current_time_;
} }
bool WebRtcAudioRenderer::IsLocalRenderer() const { bool WebRtcAudioRenderer::IsLocalRenderer() const {
...@@ -495,7 +497,8 @@ void WebRtcAudioRenderer::SourceCallback( ...@@ -495,7 +497,8 @@ void WebRtcAudioRenderer::SourceCallback(
// We need to keep render data for the |source_| regardless of |state_|, // We need to keep render data for the |source_| regardless of |state_|,
// otherwise the data will be buffered up inside |source_|. // otherwise the data will be buffered up inside |source_|.
source_->RenderData(audio_bus, sink_params_.sample_rate(), source_->RenderData(audio_bus, sink_params_.sample_rate(),
output_delay_milliseconds); output_delay_milliseconds,
&current_time_);
// Avoid filling up the audio bus if we are not playing; instead // Avoid filling up the audio bus if we are not playing; instead
// return here and ensure that the returned value in Render() is 0. // return here and ensure that the returned value in Render() is 0.
......
...@@ -194,8 +194,8 @@ class CONTENT_EXPORT WebRtcAudioRenderer ...@@ -194,8 +194,8 @@ class CONTENT_EXPORT WebRtcAudioRenderer
// Audio data source from the browser process. // Audio data source from the browser process.
WebRtcAudioRendererSource* source_; WebRtcAudioRendererSource* source_;
// Protects access to |state_|, |source_| and |sink_|. // Protects access to |state_|, |source_|, |sink_| and |current_time_|.
base::Lock lock_; mutable base::Lock lock_;
// Ref count for the MediaPlayers which are playing audio. // Ref count for the MediaPlayers which are playing audio.
int play_ref_count_; int play_ref_count_;
...@@ -214,6 +214,8 @@ class CONTENT_EXPORT WebRtcAudioRenderer ...@@ -214,6 +214,8 @@ class CONTENT_EXPORT WebRtcAudioRenderer
// Delay due to the FIFO in milliseconds. // Delay due to the FIFO in milliseconds.
int fifo_delay_milliseconds_; int fifo_delay_milliseconds_;
base::TimeDelta current_time_;
// Saved volume and playing state of the root renderer. // Saved volume and playing state of the root renderer.
PlayingState playing_state_; PlayingState playing_state_;
......
...@@ -68,9 +68,10 @@ class MockAudioRendererSource : public WebRtcAudioRendererSource { ...@@ -68,9 +68,10 @@ class MockAudioRendererSource : public WebRtcAudioRendererSource {
public: public:
MockAudioRendererSource() {} MockAudioRendererSource() {}
virtual ~MockAudioRendererSource() {} virtual ~MockAudioRendererSource() {}
MOCK_METHOD3(RenderData, void(media::AudioBus* audio_bus, MOCK_METHOD4(RenderData, void(media::AudioBus* audio_bus,
int sample_rate, int sample_rate,
int audio_delay_milliseconds)); int audio_delay_milliseconds,
base::TimeDelta* current_time));
MOCK_METHOD1(RemoveAudioRenderer, void(WebRtcAudioRenderer* renderer)); MOCK_METHOD1(RemoveAudioRenderer, void(WebRtcAudioRenderer* renderer));
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment