OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Low-latency audio rendering unit utilizing audio output stream provided | 5 // Low-latency audio rendering unit utilizing audio output stream provided |
6 // by browser process through IPC. | 6 // by browser process through IPC. |
7 // | 7 // |
8 // Relationship of classes. | 8 // Relationship of classes. |
9 // | 9 // |
10 // AudioOutputController AudioDevice | 10 // AudioOutputController AudioDevice |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 #include "content/renderer/media/audio_message_filter.h" | 74 #include "content/renderer/media/audio_message_filter.h" |
75 #include "media/audio/audio_parameters.h" | 75 #include "media/audio/audio_parameters.h" |
76 | 76 |
77 class CONTENT_EXPORT AudioDevice | 77 class CONTENT_EXPORT AudioDevice |
78 : public AudioMessageFilter::Delegate, | 78 : public AudioMessageFilter::Delegate, |
79 public base::DelegateSimpleThread::Delegate, | 79 public base::DelegateSimpleThread::Delegate, |
80 public base::RefCountedThreadSafe<AudioDevice> { | 80 public base::RefCountedThreadSafe<AudioDevice> { |
81 public: | 81 public: |
82 class CONTENT_EXPORT RenderCallback { | 82 class CONTENT_EXPORT RenderCallback { |
83 public: | 83 public: |
84 virtual void Render(const std::vector<float*>& audio_data, | 84 // Fills entire buffer, returns actual number of frames it got from source. |
85 size_t number_of_frames, | 85 virtual size_t Render(const std::vector<float*>& audio_data, |
Chris Rogers
2011/12/14 20:48:35
probably should add comment about the return value
enal1
2011/12/14 22:14:54
Made existing comment more clear.
| |
86 size_t audio_delay_milliseconds) = 0; | 86 size_t number_of_frames, |
87 size_t audio_delay_milliseconds) = 0; | |
87 protected: | 88 protected: |
88 virtual ~RenderCallback() {} | 89 virtual ~RenderCallback() {} |
89 }; | 90 }; |
90 | 91 |
91 // Methods called on main render thread ------------------------------------- | 92 // Methods called on main render thread ------------------------------------- |
92 | 93 |
93 // Minimal constructor where Initialize() must be called later. | 94 // Minimal constructor where Initialize() must be called later. |
94 AudioDevice(); | 95 AudioDevice(); |
95 | 96 |
96 AudioDevice(size_t buffer_size, | 97 AudioDevice(size_t buffer_size, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 void PlayOnIOThread(); | 156 void PlayOnIOThread(); |
156 void PauseOnIOThread(bool flush); | 157 void PauseOnIOThread(bool flush); |
157 void ShutDownOnIOThread(base::WaitableEvent* completion); | 158 void ShutDownOnIOThread(base::WaitableEvent* completion); |
158 void SetVolumeOnIOThread(double volume); | 159 void SetVolumeOnIOThread(double volume); |
159 | 160 |
160 void Send(IPC::Message* message); | 161 void Send(IPC::Message* message); |
161 | 162 |
162 // Method called on the audio thread (+ one call on the IO thread) ---------- | 163 // Method called on the audio thread (+ one call on the IO thread) ---------- |
163 // Calls the client's callback for rendering audio. There will also be one | 164 // Calls the client's callback for rendering audio. There will also be one |
164 // initial call on the IO thread before the audio thread has been created. | 165 // initial call on the IO thread before the audio thread has been created. |
165 void FireRenderCallback(int16* data); | 166 // Returns actual number of filled frames. |
167 size_t FireRenderCallback(int16* data); | |
Chris Rogers
2011/12/14 20:48:35
comment about return value
enal1
2011/12/14 22:14:54
Done.
| |
166 | 168 |
167 // DelegateSimpleThread::Delegate implementation. | 169 // DelegateSimpleThread::Delegate implementation. |
168 virtual void Run() OVERRIDE; | 170 virtual void Run() OVERRIDE; |
169 | 171 |
170 // Closes socket and joins with the audio thread. | 172 // Closes socket and joins with the audio thread. |
171 void ShutDownAudioThread(); | 173 void ShutDownAudioThread(); |
172 | 174 |
173 // Format | 175 // Format |
174 size_t buffer_size_; // in sample-frames | 176 size_t buffer_size_; // in sample-frames |
175 int channels_; | 177 int channels_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 | 220 |
219 // Protects lifetime of: | 221 // Protects lifetime of: |
220 // socket_handle_ | 222 // socket_handle_ |
221 // audio_thread_ | 223 // audio_thread_ |
222 base::Lock lock_; | 224 base::Lock lock_; |
223 | 225 |
224 DISALLOW_COPY_AND_ASSIGN(AudioDevice); | 226 DISALLOW_COPY_AND_ASSIGN(AudioDevice); |
225 }; | 227 }; |
226 | 228 |
227 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ | 229 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ |
OLD | NEW |