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 CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 virtual void Initialize(const media::AudioParameters& params, | 49 virtual void Initialize(const media::AudioParameters& params, |
50 RenderCallback* renderer) OVERRIDE; | 50 RenderCallback* renderer) OVERRIDE; |
51 | 51 |
52 protected: | 52 protected: |
53 virtual ~WebAudioSourceProviderImpl(); | 53 virtual ~WebAudioSourceProviderImpl(); |
54 | 54 |
55 private: | 55 private: |
56 // Calls setFormat() on |client_| from the Blink renderer thread. | 56 // Calls setFormat() on |client_| from the Blink renderer thread. |
57 void OnSetFormat(); | 57 void OnSetFormat(); |
58 | 58 |
59 base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_this_; | |
60 | |
61 // Closure that posts a task to call OnSetFormat() on the renderer thread. | 59 // Closure that posts a task to call OnSetFormat() on the renderer thread. |
62 base::Closure set_format_cb_; | 60 base::Closure set_format_cb_; |
63 | 61 |
64 // Set to true when Initialize() is called. | 62 // Set to true when Initialize() is called. |
65 int channels_; | 63 int channels_; |
66 int sample_rate_; | 64 int sample_rate_; |
67 double volume_; | 65 double volume_; |
68 | 66 |
69 // Tracks the current playback state. | 67 // Tracks the current playback state. |
70 enum PlaybackState { kStopped, kStarted, kPlaying }; | 68 enum PlaybackState { kStopped, kStarted, kPlaying }; |
71 PlaybackState state_; | 69 PlaybackState state_; |
72 | 70 |
73 // Where audio comes from. | 71 // Where audio comes from. |
74 media::AudioRendererSink::RenderCallback* renderer_; | 72 media::AudioRendererSink::RenderCallback* renderer_; |
75 | 73 |
76 // When set via setClient() it overrides |sink_| for consuming audio. | 74 // When set via setClient() it overrides |sink_| for consuming audio. |
77 blink::WebAudioSourceProviderClient* client_; | 75 blink::WebAudioSourceProviderClient* client_; |
78 | 76 |
79 // Where audio ends up unless overridden by |client_|. | 77 // Where audio ends up unless overridden by |client_|. |
80 base::Lock sink_lock_; | 78 base::Lock sink_lock_; |
81 scoped_refptr<media::AudioRendererSink> sink_; | 79 scoped_refptr<media::AudioRendererSink> sink_; |
82 scoped_ptr<media::AudioBus> bus_wrapper_; | 80 scoped_ptr<media::AudioBus> bus_wrapper_; |
83 | 81 |
| 82 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 83 base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_factory_; |
| 84 |
84 DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl); | 85 DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace content | 88 } // namespace content |
88 | 89 |
89 #endif // CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ | 90 #endif // CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
OLD | NEW |