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

Unified Diff: media/blink/webaudiosourceprovider_impl.h

Issue 1781043002: media::WebAudioSourceProviderImpl, add support for getting a copy of passing AudioBuses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: last round of comments from dalecurtis@ 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
« no previous file with comments | « no previous file | media/blink/webaudiosourceprovider_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webaudiosourceprovider_impl.h
diff --git a/media/blink/webaudiosourceprovider_impl.h b/media/blink/webaudiosourceprovider_impl.h
index afdf1e3ce8dc6364b5c0d3d5b80e45084a1bf2d2..7e859db150e714f0fcacae46cb8caeaf93a7a291 100644
--- a/media/blink/webaudiosourceprovider_impl.h
+++ b/media/blink/webaudiosourceprovider_impl.h
@@ -24,19 +24,28 @@ class WebAudioSourceProviderClient;
namespace media {
-// WebAudioSourceProviderImpl provides a bridge between classes:
-// blink::WebAudioSourceProvider <---> AudioRendererSink
+// WebAudioSourceProviderImpl is either one of two things (but not both):
+// - a connection between a RestartableAudioRendererSink (the |sink_|) passed in
+// constructor and an AudioRendererSink::RenderCallback passed on Initialize()
+// by means of an internal AudioRendererSink::RenderCallback.
+// - a connection between the said AudioRendererSink::RenderCallback and a
+// blink::WebAudioSourceProviderClient passed via setClient() (the |client_|),
+// again using the internal AudioRendererSink::RenderCallback. Blink calls
+// provideInput() periodically to fetch the appropriate data.
//
-// WebAudioSourceProviderImpl wraps an existing audio sink that is used unless
-// WebKit has set a client via setClient(). While a client is set WebKit will
-// periodically call provideInput() to render a certain number of audio
-// sample-frames using the sink's RenderCallback to get the data.
+// In either case, the internal RenderCallback allows for delivering a copy of
+// the data if a listener is configured. WASPImpl is also a
+// RestartableAudioRendererSink itself in order to be controlled (Play(),
+// Pause() etc).
//
// All calls are protected by a lock.
class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl
: NON_EXPORTED_BASE(public blink::WebAudioSourceProvider),
NON_EXPORTED_BASE(public RestartableAudioRendererSink) {
public:
+ using CopyAudioCB = base::Callback<
+ void(scoped_ptr<AudioBus>, uint32_t delay_milliseconds, int sample_rate)>;
+
explicit WebAudioSourceProviderImpl(
const scoped_refptr<RestartableAudioRendererSink>& sink);
@@ -55,36 +64,40 @@ class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl
void Initialize(const AudioParameters& params,
RenderCallback* renderer) override;
- protected:
- ~WebAudioSourceProviderImpl() override;
+ // These methods allow a client to get a copy of the rendered audio.
+ void SetCopyAudioCallback(const CopyAudioCB& callback);
+ void ClearCopyAudioCallback();
private:
+ friend class WebAudioSourceProviderImplTest;
+ ~WebAudioSourceProviderImpl() override;
+
// Calls setFormat() on |client_| from the Blink renderer thread.
void OnSetFormat();
- // Closure that posts a task to call OnSetFormat() on the renderer thread.
- base::Closure set_format_cb_;
+ int RenderForTesting(AudioBus* audio_bus);
- // Set to true when Initialize() is called.
- int channels_;
- int sample_rate_;
+ // Used to keep the volume across reconfigurations.
double volume_;
// Tracks the current playback state.
enum PlaybackState { kStopped, kStarted, kPlaying };
PlaybackState state_;
- // Where audio comes from.
- AudioRendererSink::RenderCallback* renderer_;
-
+ // Closure that calls OnSetFormat() on |client_| on the renderer thread.
+ base::Closure set_format_cb_;
// When set via setClient() it overrides |sink_| for consuming audio.
blink::WebAudioSourceProviderClient* client_;
// Where audio ends up unless overridden by |client_|.
base::Lock sink_lock_;
- scoped_refptr<RestartableAudioRendererSink> sink_;
+ const scoped_refptr<RestartableAudioRendererSink> sink_;
scoped_ptr<AudioBus> bus_wrapper_;
+ // An inner class acting as a T filter where actual data can be tapped.
+ class TeeFilter;
+ scoped_ptr<TeeFilter> tee_filter_;
+
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_factory_;
« no previous file with comments | « no previous file | media/blink/webaudiosourceprovider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698