Index: media/blink/webaudiosourceprovider_impl.h |
diff --git a/media/blink/webaudiosourceprovider_impl.h b/media/blink/webaudiosourceprovider_impl.h |
index afdf1e3ce8dc6364b5c0d3d5b80e45084a1bf2d2..a817a3c57990112ac2a579956343084d8bdb855a 100644 |
--- a/media/blink/webaudiosourceprovider_impl.h |
+++ b/media/blink/webaudiosourceprovider_impl.h |
@@ -24,19 +24,27 @@ class WebAudioSourceProviderClient; |
namespace media { |
-// WebAudioSourceProviderImpl provides a bridge between classes: |
-// blink::WebAudioSourceProvider <---> AudioRendererSink |
-// |
-// 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. |
+// WebAudioSourceProviderImpl is either one of two things: |
+// - a connection between a RestartableAudioRendererSink passed in constructor |
+// and an AudioRendererSink::RenderCallback passed on Initialize(), by being |
+// itself a forwarding AudioRendererSink::RenderCallback - which also |
+// eavesdrops if listeners are configured. |
+// - a connection between the said AudioRendererSink::RenderCallback and a |
+// blink::WebAudioSourceProviderClient passed via setClient(), by being itself |
+// a blink::WebAudioSourceProvider. Blink calls provideInput() periodically |
+// to fetch the appropriate data. |
+// Finally, WASPImpl is also a RestartableAudioRendererSink to be controlled by |
+// an AudioRenderer (which happens to be our AudioRendererSink::RenderCallback). |
// |
// All calls are protected by a lock. |
class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl |
: NON_EXPORTED_BASE(public blink::WebAudioSourceProvider), |
- NON_EXPORTED_BASE(public RestartableAudioRendererSink) { |
+ NON_EXPORTED_BASE(public RestartableAudioRendererSink), |
+ NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { |
DaleCurtis
2016/03/11 01:41:42
Instead of inheriting from this can you create a n
mcasas
2016/03/11 04:06:23
I think is messier but done.
Called the inner thi
|
public: |
+ using OnAudioBusCB = |
DaleCurtis
2016/03/11 01:41:42
OnAudioBusCB is a bit specific. How about somethin
mcasas
2016/03/11 04:06:23
Done
|
+ base::Callback<void(scoped_ptr<AudioBus>, uint32_t delay_milliseconds)>; |
+ |
explicit WebAudioSourceProviderImpl( |
const scoped_refptr<RestartableAudioRendererSink>& sink); |
@@ -53,7 +61,18 @@ class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl |
bool SetVolume(double volume) override; |
OutputDevice* GetOutputDevice() override; |
void Initialize(const AudioParameters& params, |
- RenderCallback* renderer) override; |
+ AudioRendererSink::RenderCallback* renderer) override; |
+ |
+ // AudioRendererSink::RenderCallback implementation. |
+ // These are forwarders to |renderer_| and are here to allow for a client to |
+ // get a copy of the rendered audio by RegisterOnAudioBusCallback(). |
+ int Render(AudioBus* audio_bus, |
+ uint32_t delay_milliseconds, |
+ uint32_t frames_skipped) override; |
+ void OnRenderError() override; |
+ |
+ void RegisterOnAudioBusCallback(const OnAudioBusCB& callback); |
+ void ResetOnAudioBusCallback(); |
protected: |
~WebAudioSourceProviderImpl() override; |
@@ -85,7 +104,11 @@ class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl |
scoped_refptr<RestartableAudioRendererSink> sink_; |
scoped_ptr<AudioBus> bus_wrapper_; |
+ OnAudioBusCB onaudiobus_callback_; |
+ |
// NOTE: Weak pointers must be invalidated before all other member variables. |
+ // TODO(mcasas): This class is ref-counted via (Restartable)AudioRendererSink. |
+ // and that does not seem to go well with this. |
base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_factory_; |
DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl); |