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

Unified Diff: content/renderer/media/webaudio_capturer_source.h

Issue 1780653002: Revert of MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webaudio_capturer_source.h
diff --git a/content/renderer/media/webaudio_capturer_source.h b/content/renderer/media/webaudio_capturer_source.h
index f127de3aa2fbdc1f753fb89e4e698be283c04ad2..d5b3bb5b554514d8d75ee909bf8ab23f63914279 100644
--- a/content/renderer/media/webaudio_capturer_source.h
+++ b/content/renderer/media/webaudio_capturer_source.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
@@ -30,11 +31,12 @@
// (channels, and sample-rate).
// 2. consumeAudio() is called periodically by WebKit which dispatches the
// audio stream to the WebRtcLocalAudioTrack::Capture() method.
-class WebAudioCapturerSource : public blink::WebAudioDestinationConsumer {
+class WebAudioCapturerSource
+ : public base::RefCountedThreadSafe<WebAudioCapturerSource>,
+ public blink::WebAudioDestinationConsumer {
public:
- explicit WebAudioCapturerSource(blink::WebMediaStreamSource* blink_source);
-
- ~WebAudioCapturerSource() override;
+ explicit WebAudioCapturerSource(
+ const blink::WebMediaStreamSource& blink_source);
// WebAudioDestinationConsumer implementation.
// setFormat() is called early on, so that we can configure the audio track.
@@ -45,12 +47,17 @@
size_t number_of_frames) override;
// Called when the WebAudioCapturerSource is hooking to a media audio track.
- // |track| is the sink of the data flow and must remain alive until Stop() is
- // called.
+ // |track| is the sink of the data flow. |source_provider| is the source of
+ // the data flow where stream information like delay, volume, key_pressed,
+ // is stored.
void Start(WebRtcLocalAudioTrack* track);
// Called when the media audio track is stopping.
void Stop();
+
+ protected:
+ friend class base::RefCountedThreadSafe<WebAudioCapturerSource>;
+ ~WebAudioCapturerSource() override;
private:
// Called by AudioPushFifo zero or more times during the call to
@@ -59,13 +66,16 @@
void DeliverRebufferedAudio(const media::AudioBus& audio_bus,
int frame_delay);
- // Deregisters this object from its blink::WebMediaStreamSource.
- void DeregisterFromBlinkSource();
+ // Removes this object from a blink::WebMediaStreamSource with which it
+ // might be registered. The goal is to avoid dangling pointers.
+ void removeFromBlinkSource();
// Used to DCHECK that some methods are called on the correct thread.
base::ThreadChecker thread_checker_;
// The audio track this WebAudioCapturerSource is feeding data to.
+ // WebRtcLocalAudioTrack is reference counted, and owning this object.
+ // To avoid circular reference, a raw pointer is kept here.
WebRtcLocalAudioTrack* track_;
media::AudioParameters params_;
« no previous file with comments | « content/renderer/media/user_media_client_impl_unittest.cc ('k') | content/renderer/media/webaudio_capturer_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698