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 // 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. | 6 // lives inside the render process and provide access to audio hardware. |
7 // | 7 // |
8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI | 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI |
9 // thread, but all other operations and method calls happen on IO thread, so we | 9 // thread, but all other operations and method calls happen on IO thread, so we |
10 // need to be extra careful about the lifetime of this object. AudioManager is a | 10 // need to be extra careful about the lifetime of this object. AudioManager is a |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 struct AudioEntry { | 69 struct AudioEntry { |
70 AudioEntry(); | 70 AudioEntry(); |
71 ~AudioEntry(); | 71 ~AudioEntry(); |
72 | 72 |
73 // The AudioOutputController that manages the audio stream. | 73 // The AudioOutputController that manages the audio stream. |
74 scoped_refptr<media::AudioOutputController> controller; | 74 scoped_refptr<media::AudioOutputController> controller; |
75 | 75 |
76 // The audio stream ID. | 76 // The audio stream ID. |
77 int stream_id; | 77 int stream_id; |
78 | 78 |
| 79 // The render view ID. |
| 80 int render_view_id; |
| 81 |
79 // Shared memory for transmission of the audio data. | 82 // Shared memory for transmission of the audio data. |
80 base::SharedMemory shared_memory; | 83 base::SharedMemory shared_memory; |
81 | 84 |
82 // The synchronous reader to be used by the controller. We have the | 85 // The synchronous reader to be used by the controller. We have the |
83 // ownership of the reader. | 86 // ownership of the reader. |
84 scoped_ptr<media::AudioOutputController::SyncReader> reader; | 87 scoped_ptr<media::AudioOutputController::SyncReader> reader; |
85 | 88 |
86 // Set to true after we called Close() for the controller. | 89 // Set to true after we called Close() for the controller. |
87 bool pending_close; | 90 bool pending_close; |
88 }; | 91 }; |
89 | 92 |
90 typedef std::map<int, AudioEntry*> AudioEntryMap; | 93 typedef std::map<int, AudioEntry*> AudioEntryMap; |
91 | 94 |
92 // Called from UI thread from the owner of this object. | 95 // Called from UI thread from the owner of this object. |
93 AudioRendererHost(media::AudioManager* audio_manager, | 96 AudioRendererHost(int render_process_id, |
| 97 media::AudioManager* audio_manager, |
94 content::MediaObserver* media_observer); | 98 content::MediaObserver* media_observer); |
95 | 99 |
96 // content::BrowserMessageFilter implementation. | 100 // content::BrowserMessageFilter implementation. |
97 virtual void OnChannelClosing() OVERRIDE; | 101 virtual void OnChannelClosing() OVERRIDE; |
98 virtual void OnDestruct() const OVERRIDE; | 102 virtual void OnDestruct() const OVERRIDE; |
99 virtual bool OnMessageReceived(const IPC::Message& message, | 103 virtual bool OnMessageReceived(const IPC::Message& message, |
100 bool* message_was_ok) OVERRIDE; | 104 bool* message_was_ok) OVERRIDE; |
101 | 105 |
102 // AudioOutputController::EventHandler implementations. | 106 // AudioOutputController::EventHandler implementations. |
103 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE; | 107 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 175 |
172 // A helper method to look up a AudioEntry identified by |stream_id|. | 176 // A helper method to look up a AudioEntry identified by |stream_id|. |
173 // Returns NULL if not found. | 177 // Returns NULL if not found. |
174 AudioEntry* LookupById(int stream_id); | 178 AudioEntry* LookupById(int stream_id); |
175 | 179 |
176 // Search for a AudioEntry having the reference to |controller|. | 180 // Search for a AudioEntry having the reference to |controller|. |
177 // This method is used to look up an AudioEntry after a controller | 181 // This method is used to look up an AudioEntry after a controller |
178 // event is received. | 182 // event is received. |
179 AudioEntry* LookupByController(media::AudioOutputController* controller); | 183 AudioEntry* LookupByController(media::AudioOutputController* controller); |
180 | 184 |
| 185 int render_process_id_; |
| 186 |
181 // A map of stream IDs to audio sources. | 187 // A map of stream IDs to audio sources. |
182 AudioEntryMap audio_entries_; | 188 AudioEntryMap audio_entries_; |
183 | 189 |
184 media::AudioManager* audio_manager_; | 190 media::AudioManager* audio_manager_; |
185 content::MediaObserver* media_observer_; | 191 content::MediaObserver* media_observer_; |
186 | 192 |
187 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 193 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
188 }; | 194 }; |
189 | 195 |
190 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 196 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
OLD | NEW |