Index: webkit/media/webaudiosourceprovider_impl.h |
diff --git a/content/renderer/media/render_audiosourceprovider.h b/webkit/media/webaudiosourceprovider_impl.h |
similarity index 52% |
rename from content/renderer/media/render_audiosourceprovider.h |
rename to webkit/media/webaudiosourceprovider_impl.h |
index 148b11ffd1dc7d17b529b7b37becfc362701db12..888d67fc55654995a28de9cc8c199ec27edc866c 100644 |
--- a/content/renderer/media/render_audiosourceprovider.h |
+++ b/webkit/media/webaudiosourceprovider_impl.h |
@@ -1,57 +1,46 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// |
-// RenderAudioSourceProvider provides a bridge between classes: |
-// WebKit::WebAudioSourceProvider <---> media::AudioRendererSink |
-// |
-// RenderAudioSourceProvider is a "sink" of audio, and uses a default |
-// AudioOutputDevice if a client has not explicitly been set. |
-// |
-// WebKit optionally sets a client, and then periodically calls provideInput() |
-// to render a certain number of audio sample-frames. provideInput() |
-// uses the renderer to get this data, and then massages it into the form |
-// required by provideInput(). In this case, the default AudioOutputDevice |
-// is no longer used. |
-// |
-// THREAD SAFETY: |
-// It is assumed that the callers to setClient() and provideInput() |
-// implement appropriate locking for thread safety when making |
-// these calls. This happens in WebKit. |
-#ifndef CONTENT_RENDERER_MEDIA_RENDER_AUDIOSOURCEPROVIDER_H_ |
-#define CONTENT_RENDERER_MEDIA_RENDER_AUDIOSOURCEPROVIDER_H_ |
+#ifndef WEBKIT_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
+#define WEBKIT_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
#include "base/synchronization/lock.h" |
#include "media/base/audio_renderer_sink.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvider.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
namespace WebKit { |
class WebAudioSourceProviderClient; |
} |
-namespace content { |
+namespace webkit_media { |
-class RenderAudioSourceProvider |
+// WebAudioSourceProviderImpl provides a bridge between classes: |
+// WebKit::WebAudioSourceProvider <---> media::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. |
+// |
+// THREAD SAFETY: |
+// It is assumed that the callers to setClient() and provideInput() |
+// implement appropriate locking for thread safety when making |
+// these calls. This happens in WebKit. |
+class WebAudioSourceProviderImpl |
: public WebKit::WebAudioSourceProvider, |
public media::AudioRendererSink { |
public: |
- explicit RenderAudioSourceProvider(int source_render_view_id); |
+ explicit WebAudioSourceProviderImpl( |
+ const scoped_refptr<media::AudioRendererSink>& sink); |
// WebKit::WebAudioSourceProvider implementation. |
- |
- // WebKit calls setClient() if it desires to take control of the rendered |
- // audio stream. We call client's setFormat() when the audio stream format |
- // is known. |
virtual void setClient(WebKit::WebAudioSourceProviderClient* client); |
- |
- // If setClient() has been called, then WebKit calls provideInput() |
- // periodically to get the rendered audio stream. |
virtual void provideInput(const WebKit::WebVector<float*>& audio_data, |
size_t number_of_frames); |
- // AudioRendererSink implementation. |
+ // media::AudioRendererSink implementation. |
virtual void Start() OVERRIDE; |
virtual void Stop() OVERRIDE; |
virtual void Play() OVERRIDE; |
@@ -61,7 +50,7 @@ class RenderAudioSourceProvider |
RenderCallback* renderer) OVERRIDE; |
protected: |
- virtual ~RenderAudioSourceProvider(); |
+ virtual ~WebAudioSourceProviderImpl(); |
private: |
// Set to true when Initialize() is called. |
@@ -69,19 +58,22 @@ class RenderAudioSourceProvider |
int channels_; |
int sample_rate_; |
+ // Tracks if |sink_| has been instructed to consume audio. |
bool is_running_; |
+ |
+ // Where audio comes from. |
media::AudioRendererSink::RenderCallback* renderer_; |
+ |
+ // When set via setClient() it overrides |sink_| for consuming audio. |
WebKit::WebAudioSourceProviderClient* client_; |
- // Protects access to sink_ |
+ // Where audio ends up unless overridden by |client_|. |
base::Lock sink_lock_; |
+ scoped_refptr<media::AudioRendererSink> sink_; |
miu
2013/01/09 18:48:35
nit: Since sink_ is set via the ctor initializer l
|
- // default_sink_ is the default sink. |
- scoped_refptr<media::AudioRendererSink> default_sink_; |
- |
- DISALLOW_IMPLICIT_CONSTRUCTORS(RenderAudioSourceProvider); |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl); |
}; |
-} // namespace content |
+} // namespace webkit_media |
-#endif // CONTENT_RENDERER_MEDIA_RENDER_AUDIOSOURCEPROVIDER_H_ |
+#endif // WEBKIT_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |