summaryrefslogtreecommitdiffstats
path: root/content/renderer/media/webrtc_local_audio_track.h
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 14:12:41 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 14:12:41 +0000
commitf269dc3c19468e46e36de8a7fd91ecd7f6de1f9d (patch)
tree39f86eb5575a2e5322b6b6d14b26fb0868bae040 /content/renderer/media/webrtc_local_audio_track.h
parentb2cad65c03de86e326cf0e62869a2bf41426347b (diff)
downloadchromium_src-f269dc3c19468e46e36de8a7fd91ecd7f6de1f9d.zip
chromium_src-f269dc3c19468e46e36de8a7fd91ecd7f6de1f9d.tar.gz
chromium_src-f269dc3c19468e46e36de8a7fd91ecd7f6de1f9d.tar.bz2
Move the SetCaptureFormat to the capture audio thread.
Before this CL, the thread model of our capture class is that they will be updated with the format in the main render thread by SetCaptureFormat() and getting the audio callback in the capture audio thread. And this complicates our code since it is required that the audio format in the data callback in the capture audio thread has to be the same as the cached format we get from the main render thread. This CL simplies the thread model by moving the SetCaptureFormat() to the capture audio thread, so the format change callback will be in the same thread as the data callback. This CL fixed the problems of https://codereview.chromium.org/76293004/ (crash when the webrtcLocalSourceProvider has not been getting the format callback before the data callback) https://codereview.chromium.org/59273005/ (WebRtcLocalAudioRenderer might get a SetCaptureFormat() after Start(), in such case we should start the sink_ in WebRtcLocalAudioRenderer to adapt to the new format) TBR=joi@chromium.org BUG=320808 TEST=content_unittests Review URL: https://codereview.chromium.org/83133002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/media/webrtc_local_audio_track.h')
-rw-r--r--content/renderer/media/webrtc_local_audio_track.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/content/renderer/media/webrtc_local_audio_track.h b/content/renderer/media/webrtc_local_audio_track.h
index eb544f6..6952722 100644
--- a/content/renderer/media/webrtc_local_audio_track.h
+++ b/content/renderer/media/webrtc_local_audio_track.h
@@ -66,6 +66,7 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack
void Stop();
// Method called by the capturer to deliver the capture data.
+ // Call on the capture audio thread.
void Capture(media::AudioBus* audio_source,
int audio_delay_milliseconds,
int volume,
@@ -73,7 +74,7 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack
// Method called by the capturer to set the audio parameters used by source
// of the capture data..
- // Can be called on different user threads.
+ // Call on the capture audio thread.
void SetCaptureFormat(const media::AudioParameters& params);
blink::WebAudioSourceProvider* audio_source_provider() const {
@@ -119,21 +120,28 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack
// A list of sinks that the audio data is fed to.
SinkList sinks_;
- // Used to DCHECK that we are called on the correct thread.
- base::ThreadChecker thread_checker_;
+ // A list of sinks that the track needs to notify the audio format has
+ // changed.
+ SinkList sinks_to_notify_format_;
+
+ // Used to DCHECK that some methods are called on the main render thread.
+ base::ThreadChecker main_render_thread_checker_;
+
+ // Used to DCHECK that some methods are called on the capture audio thread.
+ base::ThreadChecker capture_thread_checker_;
// Protects |params_| and |sinks_|.
mutable base::Lock lock_;
- // A vector of WebRtc VoE channels that the capturer sends datat to.
+ // A vector of WebRtc VoE channels that the capturer sends data to.
std::vector<int> voe_channels_;
bool need_audio_processing_;
// Buffers used for temporary storage during capture callbacks.
- // Allocated during initialization.
+ // Allocated and accessed only on the capture audio thread.
class ConfiguredBuffer;
- scoped_refptr<ConfiguredBuffer> buffer_;
+ scoped_ptr<ConfiguredBuffer> buffer_;
// The source provider to feed the track data to other clients like
// WebAudio.