OLD | NEW |
---|---|
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // AudioRendererHost serves audio related requests from AudioRenderer which | 5 // AudioRendererHost serves audio related requests from AudioRenderer which |
6 // lives inside the render process and provide access to audio hardware. It maps | 6 // lives inside the render process and provide access to audio hardware. It maps |
7 // an internal ID to AudioRendererHost::IPCAudioSource in a map, which is the | 7 // an internal ID to AudioRendererHost::IPCAudioSource in a map, which is the |
8 // actual object providing audio packets through IPC. It creates the actual | 8 // actual object providing audio packets through IPC. It creates the actual |
9 // AudioOutputStream object when requested by the renderer provided with | 9 // AudioOutputStream object when requested by the renderer provided with |
10 // render view id and stream id. | 10 // render view id and stream id. |
(...skipping 18 matching lines...) Expand all Loading... | |
29 // which essentially post a task of OnDestroyed() on IO thread. Inside | 29 // which essentially post a task of OnDestroyed() on IO thread. Inside |
30 // OnDestroyed(), audio output streams are destroyed and Release() is called | 30 // OnDestroyed(), audio output streams are destroyed and Release() is called |
31 // which may result in self-destruction. | 31 // which may result in self-destruction. |
32 | 32 |
33 #ifndef CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ | 33 #ifndef CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ |
34 #define CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ | 34 #define CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ |
35 | 35 |
36 #include <map> | 36 #include <map> |
37 #include <deque> | 37 #include <deque> |
38 | 38 |
39 #include "base/lock.h" | |
39 #include "base/process.h" | 40 #include "base/process.h" |
40 #include "base/ref_counted.h" | 41 #include "base/ref_counted.h" |
41 #include "base/shared_memory.h" | 42 #include "base/shared_memory.h" |
42 #include "base/waitable_event.h" | 43 #include "base/waitable_event.h" |
43 #include "chrome/common/ipc_message.h" | 44 #include "chrome/common/ipc_message.h" |
44 #include "media/audio/audio_output.h" | 45 #include "media/audio/audio_output.h" |
45 | 46 |
46 class AudioManager; | 47 class AudioManager; |
47 class Lock; | |
48 class MessageLoop; | 48 class MessageLoop; |
49 struct ViewHostMsg_Audio_CreateStream; | 49 struct ViewHostMsg_Audio_CreateStream; |
50 | 50 |
51 class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> { | 51 class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> { |
52 private: | 52 private: |
53 class IPCAudioSource; | 53 class IPCAudioSource; |
54 friend class AudioRendererHost::IPCAudioSource; | 54 friend class AudioRendererHost::IPCAudioSource; |
55 public: | 55 public: |
56 // Called from UI thread from the owner of this object. | 56 // Called from UI thread from the owner of this object. |
57 explicit AudioRendererHost(MessageLoop* message_loop); | 57 explicit AudioRendererHost(MessageLoop* message_loop); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 // A helper method for calling OnDestroySource on IO thread. | 166 // A helper method for calling OnDestroySource on IO thread. |
167 void DestroySource(IPCAudioSource* source); | 167 void DestroySource(IPCAudioSource* source); |
168 | 168 |
169 MessageLoop* io_loop() { return io_loop_; } | 169 MessageLoop* io_loop() { return io_loop_; } |
170 | 170 |
171 // The container for AudioOutputStream and serves audio packet for it by IPC. | 171 // The container for AudioOutputStream and serves audio packet for it by IPC. |
172 // This class does nothing more than sending IPC when OnMoreData is called | 172 // This class does nothing more than sending IPC when OnMoreData is called |
173 // or error is received from the hardware audio thread, it also serves the | 173 // or error is received from the hardware audio thread, it also serves the |
174 // purpose of containing the audio output stream and associated information. | 174 // purpose of containing the audio output stream and associated information. |
175 // Lifetime of the audio output stream is not controlled by this class. | 175 // Lifetime of the audio output stream is not controlled by this class. |
176 class IPCAudioSource : public AudioOutputStream::AudioSourceCallback { | 176 class IPCAudioSource : public AudioOutputStream::AudioSourceCallback { |
M-A Ruel
2009/06/03 14:28:37
If you want to be zealous, move this class to audi
| |
177 public: | 177 public: |
178 // Factory method for creating an IPCAudioSource, returns NULL if failed. | 178 // Factory method for creating an IPCAudioSource, returns NULL if failed. |
179 static IPCAudioSource* CreateIPCAudioSource( | 179 static IPCAudioSource* CreateIPCAudioSource( |
180 AudioRendererHost* host, // Host of this source. | 180 AudioRendererHost* host, // Host of this source. |
181 int process_id, // Process ID of renderer. | 181 int process_id, // Process ID of renderer. |
182 int route_id, // Routing ID to RenderView. | 182 int route_id, // Routing ID to RenderView. |
183 int stream_id, // ID of this source. | 183 int stream_id, // ID of this source. |
184 base::ProcessHandle process_handle, // Process handle of renderer. | 184 base::ProcessHandle process_handle, // Process handle of renderer. |
185 AudioManager::Format format, // Format of the stream. | 185 AudioManager::Format format, // Format of the stream. |
186 int channels, // Number of channels. | 186 int channels, // Number of channels. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 typedef std::pair<int32, int32> SourceID; | 262 typedef std::pair<int32, int32> SourceID; |
263 typedef std::map<SourceID, IPCAudioSource*> SourceMap; | 263 typedef std::map<SourceID, IPCAudioSource*> SourceMap; |
264 SourceMap sources_; | 264 SourceMap sources_; |
265 | 265 |
266 MessageLoop* io_loop_; | 266 MessageLoop* io_loop_; |
267 | 267 |
268 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 268 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
269 }; | 269 }; |
270 | 270 |
271 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ | 271 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ |
OLD | NEW |