OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // RenderAudioSourceProvider provides a bridge between classes: | 5 // RenderAudioSourceProvider provides a bridge between classes: |
6 // WebKit::WebAudioSourceProvider <---> media::AudioRendererSink | 6 // WebKit::WebAudioSourceProvider <---> media::AudioRendererSink |
7 // | 7 // |
8 // RenderAudioSourceProvider is a "sink" of audio, and uses a default | 8 // RenderAudioSourceProvider is a "sink" of audio, and uses a default |
9 // AudioDevice if a client has not explicitly been set. | 9 // AudioDevice if a client has not explicitly been set. |
10 // | 10 // |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 namespace WebKit { | 32 namespace WebKit { |
33 class WebAudioSourceProviderClient; | 33 class WebAudioSourceProviderClient; |
34 } | 34 } |
35 | 35 |
36 class RenderAudioSourceProvider | 36 class RenderAudioSourceProvider |
37 : public WebKit::WebAudioSourceProvider, | 37 : public WebKit::WebAudioSourceProvider, |
38 public media::AudioRendererSink { | 38 public media::AudioRendererSink { |
39 public: | 39 public: |
40 RenderAudioSourceProvider(); | 40 RenderAudioSourceProvider(); |
41 virtual ~RenderAudioSourceProvider(); | |
42 | 41 |
43 // WebKit::WebAudioSourceProvider implementation. | 42 // WebKit::WebAudioSourceProvider implementation. |
44 | 43 |
45 // WebKit calls setClient() if it desires to take control of the rendered | 44 // WebKit calls setClient() if it desires to take control of the rendered |
46 // audio stream. We call client's setFormat() when the audio stream format | 45 // audio stream. We call client's setFormat() when the audio stream format |
47 // is known. | 46 // is known. |
48 virtual void setClient(WebKit::WebAudioSourceProviderClient* client); | 47 virtual void setClient(WebKit::WebAudioSourceProviderClient* client); |
49 | 48 |
50 // If setClient() has been called, then WebKit calls provideInput() | 49 // If setClient() has been called, then WebKit calls provideInput() |
51 // periodically to get the rendered audio stream. | 50 // periodically to get the rendered audio stream. |
52 virtual void provideInput(const WebKit::WebVector<float*>& audio_data, | 51 virtual void provideInput(const WebKit::WebVector<float*>& audio_data, |
53 size_t number_of_frames); | 52 size_t number_of_frames); |
54 | 53 |
55 // AudioRendererSink implementation. | 54 // AudioRendererSink implementation. |
56 virtual void Start() OVERRIDE; | 55 virtual void Start() OVERRIDE; |
57 virtual void Stop() OVERRIDE; | 56 virtual void Stop() OVERRIDE; |
58 virtual void Play() OVERRIDE; | 57 virtual void Play() OVERRIDE; |
59 virtual void Pause(bool flush) OVERRIDE; | 58 virtual void Pause(bool flush) OVERRIDE; |
60 virtual void SetPlaybackRate(float rate) OVERRIDE; | 59 virtual void SetPlaybackRate(float rate) OVERRIDE; |
61 virtual bool SetVolume(double volume) OVERRIDE; | 60 virtual bool SetVolume(double volume) OVERRIDE; |
62 virtual void GetVolume(double* volume) OVERRIDE; | 61 virtual void GetVolume(double* volume) OVERRIDE; |
63 virtual void Initialize( | 62 virtual void Initialize(const media::AudioParameters& params, |
64 const media::AudioParameters& params, RenderCallback* renderer) OVERRIDE; | 63 RenderCallback* renderer) OVERRIDE; |
| 64 |
| 65 protected: |
| 66 virtual ~RenderAudioSourceProvider(); |
65 | 67 |
66 private: | 68 private: |
67 // Set to true when Initialize() is called. | 69 // Set to true when Initialize() is called. |
68 bool is_initialized_; | 70 bool is_initialized_; |
69 int channels_; | 71 int channels_; |
70 int sample_rate_; | 72 int sample_rate_; |
71 | 73 |
72 bool is_running_; | 74 bool is_running_; |
73 double volume_; | 75 double volume_; |
74 media::AudioRendererSink::RenderCallback* renderer_; | 76 media::AudioRendererSink::RenderCallback* renderer_; |
75 WebKit::WebAudioSourceProviderClient* client_; | 77 WebKit::WebAudioSourceProviderClient* client_; |
76 | 78 |
77 // Protects access to sink_ | 79 // Protects access to sink_ |
78 base::Lock sink_lock_; | 80 base::Lock sink_lock_; |
79 | 81 |
80 // default_sink_ is the default sink. | 82 // default_sink_ is the default sink. |
81 scoped_refptr<media::AudioRendererSink> default_sink_; | 83 scoped_refptr<media::AudioRendererSink> default_sink_; |
82 | 84 |
83 DISALLOW_COPY_AND_ASSIGN(RenderAudioSourceProvider); | 85 DISALLOW_COPY_AND_ASSIGN(RenderAudioSourceProvider); |
84 }; | 86 }; |
85 | 87 |
86 #endif // CONTENT_RENDERER_MEDIA_RENDER_AUDIOSOURCEPROVIDER_H_ | 88 #endif // CONTENT_RENDERER_MEDIA_RENDER_AUDIOSOURCEPROVIDER_H_ |
OLD | NEW |