Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.h

Issue 10662049: Move the device enumerate/open/close work to device thread from IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small changes to fix the trybots' failure Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // AudioInputRendererHost serves audio related requests from audio capturer 5 // AudioInputRendererHost serves audio related requests from audio capturer
6 // which lives inside the render process and provide access to audio hardware. 6 // which lives inside the render process and provide access to audio hardware.
7 // 7 //
8 // Create stream sequence (AudioInputController = AIC): 8 // Create stream sequence (AudioInputController = AIC):
9 // 9 //
10 // AudioInputHostMsg_CreateStream -> OnCreateStream -> AIC::CreateLowLatency -> 10 // AudioInputHostMsg_CreateStream -> OnCreateStream -> AIC::CreateLowLatency ->
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "base/process.h" 57 #include "base/process.h"
58 #include "base/sequenced_task_runner_helpers.h" 58 #include "base/sequenced_task_runner_helpers.h"
59 #include "base/shared_memory.h" 59 #include "base/shared_memory.h"
60 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h andler.h" 60 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h andler.h"
61 #include "content/public/browser/browser_message_filter.h" 61 #include "content/public/browser/browser_message_filter.h"
62 #include "content/public/browser/browser_thread.h" 62 #include "content/public/browser/browser_thread.h"
63 #include "media/audio/audio_input_controller.h" 63 #include "media/audio/audio_input_controller.h"
64 #include "media/audio/audio_io.h" 64 #include "media/audio/audio_io.h"
65 #include "media/audio/simple_sources.h" 65 #include "media/audio/simple_sources.h"
66 66
67 namespace content {
68 class ResourceContext;
69 }
70
71 namespace media { 67 namespace media {
72 class AudioManager; 68 class AudioManager;
73 class AudioParameters; 69 class AudioParameters;
74 } 70 }
75 71
72 namespace media_stream {
73 class MediaStreamManager;
74 }
75
76 class CONTENT_EXPORT AudioInputRendererHost 76 class CONTENT_EXPORT AudioInputRendererHost
77 : public content::BrowserMessageFilter, 77 : public content::BrowserMessageFilter,
78 public media::AudioInputController::EventHandler, 78 public media::AudioInputController::EventHandler,
79 public media_stream::AudioInputDeviceManagerEventHandler { 79 public media_stream::AudioInputDeviceManagerEventHandler {
80 public: 80 public:
81 struct AudioEntry { 81 struct AudioEntry {
82 AudioEntry(); 82 AudioEntry();
83 ~AudioEntry(); 83 ~AudioEntry();
84 84
85 // The AudioInputController that manages the audio input stream. 85 // The AudioInputController that manages the audio input stream.
86 scoped_refptr<media::AudioInputController> controller; 86 scoped_refptr<media::AudioInputController> controller;
87 87
88 // The audio input stream ID in the render view. 88 // The audio input stream ID in the render view.
89 int stream_id; 89 int stream_id;
90 90
91 // Shared memory for transmission of the audio data. 91 // Shared memory for transmission of the audio data.
92 base::SharedMemory shared_memory; 92 base::SharedMemory shared_memory;
93 93
94 // The synchronous writer to be used by the controller. We have the 94 // The synchronous writer to be used by the controller. We have the
95 // ownership of the writer. 95 // ownership of the writer.
96 scoped_ptr<media::AudioInputController::SyncWriter> writer; 96 scoped_ptr<media::AudioInputController::SyncWriter> writer;
97 97
98 // Set to true after we called Close() for the controller. 98 // Set to true after we called Close() for the controller.
99 bool pending_close; 99 bool pending_close;
100 }; 100 };
101 101
102 // Called from UI thread from the owner of this object. 102 // Called from UI thread from the owner of this object.
103 AudioInputRendererHost(content::ResourceContext* resource_context, 103 AudioInputRendererHost(
104 media::AudioManager* audio_manager); 104 media::AudioManager* audio_manager,
105 media_stream::MediaStreamManager* media_stream_manager);
105 106
106 // content::BrowserMessageFilter implementation. 107 // content::BrowserMessageFilter implementation.
107 virtual void OnChannelClosing() OVERRIDE; 108 virtual void OnChannelClosing() OVERRIDE;
108 virtual void OnDestruct() const OVERRIDE; 109 virtual void OnDestruct() const OVERRIDE;
109 virtual bool OnMessageReceived(const IPC::Message& message, 110 virtual bool OnMessageReceived(const IPC::Message& message,
110 bool* message_was_ok) OVERRIDE; 111 bool* message_was_ok) OVERRIDE;
111 112
112 // AudioInputController::EventHandler implementation. 113 // AudioInputController::EventHandler implementation.
113 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE; 114 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE;
114 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE; 115 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 191
191 // Search for a AudioEntry having the reference to |controller|. 192 // Search for a AudioEntry having the reference to |controller|.
192 // This method is used to look up an AudioEntry after a controller 193 // This method is used to look up an AudioEntry after a controller
193 // event is received. 194 // event is received.
194 AudioEntry* LookupByController(media::AudioInputController* controller); 195 AudioEntry* LookupByController(media::AudioInputController* controller);
195 196
196 // A helper method to look up a session identified by |stream_id|. 197 // A helper method to look up a session identified by |stream_id|.
197 // Returns 0 if not found. 198 // Returns 0 if not found.
198 int LookupSessionById(int stream_id); 199 int LookupSessionById(int stream_id);
199 200
200 // Used to get an instance of AudioInputDeviceManager. 201 // Used to create an AudioInputController.
201 content::ResourceContext* resource_context_;
202 media::AudioManager* audio_manager_; 202 media::AudioManager* audio_manager_;
203 203
204 // Used to access to AudioInputDeviceManager.
205 media_stream::MediaStreamManager* media_stream_manager_;
206
204 // A map of stream IDs to audio sources. 207 // A map of stream IDs to audio sources.
205 typedef std::map<int, AudioEntry*> AudioEntryMap; 208 typedef std::map<int, AudioEntry*> AudioEntryMap;
206 AudioEntryMap audio_entries_; 209 AudioEntryMap audio_entries_;
207 210
208 // A map of session IDs to audio session sources. 211 // A map of session IDs to audio session sources.
209 typedef std::map<int, int> SessionEntryMap; 212 typedef std::map<int, int> SessionEntryMap;
210 SessionEntryMap session_entries_; 213 SessionEntryMap session_entries_;
211 214
212 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); 215 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost);
213 }; 216 };
214 217
215 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ 218 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698