OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
6 #define MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_ | 6 #define MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 25 matching lines...) Expand all Loading... |
36 // In either case, the internal RenderCallback allows for delivering a copy of | 36 // In either case, the internal RenderCallback allows for delivering a copy of |
37 // the data if a listener is configured. WASPImpl is also a | 37 // the data if a listener is configured. WASPImpl is also a |
38 // RestartableAudioRendererSink itself in order to be controlled (Play(), | 38 // RestartableAudioRendererSink itself in order to be controlled (Play(), |
39 // Pause() etc). | 39 // Pause() etc). |
40 // | 40 // |
41 // All calls are protected by a lock. | 41 // All calls are protected by a lock. |
42 class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl | 42 class MEDIA_BLINK_EXPORT WebAudioSourceProviderImpl |
43 : NON_EXPORTED_BASE(public blink::WebAudioSourceProvider), | 43 : NON_EXPORTED_BASE(public blink::WebAudioSourceProvider), |
44 NON_EXPORTED_BASE(public SwitchableAudioRendererSink) { | 44 NON_EXPORTED_BASE(public SwitchableAudioRendererSink) { |
45 public: | 45 public: |
46 using CopyAudioCB = base::Callback< | 46 using CopyAudioCB = base::Callback<void(std::unique_ptr<AudioBus>, |
47 void(scoped_ptr<AudioBus>, uint32_t delay_milliseconds, int sample_rate)>; | 47 uint32_t delay_milliseconds, |
| 48 int sample_rate)>; |
48 | 49 |
49 explicit WebAudioSourceProviderImpl( | 50 explicit WebAudioSourceProviderImpl( |
50 const scoped_refptr<SwitchableAudioRendererSink>& sink); | 51 const scoped_refptr<SwitchableAudioRendererSink>& sink); |
51 | 52 |
52 // blink::WebAudioSourceProvider implementation. | 53 // blink::WebAudioSourceProvider implementation. |
53 void setClient(blink::WebAudioSourceProviderClient* client) override; | 54 void setClient(blink::WebAudioSourceProviderClient* client) override; |
54 void provideInput(const blink::WebVector<float*>& audio_data, | 55 void provideInput(const blink::WebVector<float*>& audio_data, |
55 size_t number_of_frames) override; | 56 size_t number_of_frames) override; |
56 | 57 |
57 // RestartableAudioRendererSink implementation. | 58 // RestartableAudioRendererSink implementation. |
(...skipping 30 matching lines...) Expand all Loading... |
88 PlaybackState state_; | 89 PlaybackState state_; |
89 | 90 |
90 // Closure that calls OnSetFormat() on |client_| on the renderer thread. | 91 // Closure that calls OnSetFormat() on |client_| on the renderer thread. |
91 base::Closure set_format_cb_; | 92 base::Closure set_format_cb_; |
92 // When set via setClient() it overrides |sink_| for consuming audio. | 93 // When set via setClient() it overrides |sink_| for consuming audio. |
93 blink::WebAudioSourceProviderClient* client_; | 94 blink::WebAudioSourceProviderClient* client_; |
94 | 95 |
95 // Where audio ends up unless overridden by |client_|. | 96 // Where audio ends up unless overridden by |client_|. |
96 base::Lock sink_lock_; | 97 base::Lock sink_lock_; |
97 const scoped_refptr<SwitchableAudioRendererSink> sink_; | 98 const scoped_refptr<SwitchableAudioRendererSink> sink_; |
98 scoped_ptr<AudioBus> bus_wrapper_; | 99 std::unique_ptr<AudioBus> bus_wrapper_; |
99 | 100 |
100 // An inner class acting as a T filter where actual data can be tapped. | 101 // An inner class acting as a T filter where actual data can be tapped. |
101 class TeeFilter; | 102 class TeeFilter; |
102 scoped_ptr<TeeFilter> tee_filter_; | 103 std::unique_ptr<TeeFilter> tee_filter_; |
103 | 104 |
104 // NOTE: Weak pointers must be invalidated before all other member variables. | 105 // NOTE: Weak pointers must be invalidated before all other member variables. |
105 base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_factory_; | 106 base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_factory_; |
106 | 107 |
107 DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl); | 108 DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl); |
108 }; | 109 }; |
109 | 110 |
110 } // namespace media | 111 } // namespace media |
111 | 112 |
112 #endif // MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_ | 113 #endif // MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
OLD | NEW |