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

Side by Side Diff: content/renderer/media/audio_input_device.h

Issue 8659040: There is a racing between SyncSocket::Receive in audio_thread_ and SyncSocket::Close in renderer ... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: update Created 9 years 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
« no previous file with comments | « content/renderer/media/audio_device.cc ('k') | content/renderer/media/audio_input_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 capturing unit utilizing audio input stream provided 5 // Low-latency audio capturing unit utilizing audio input 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 // AudioInputController AudioInputDevice 10 // AudioInputController AudioInputDevice
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Specify the |session_id| to query which device to use. This method is 124 // Specify the |session_id| to query which device to use. This method is
125 // asynchronous/non-blocking. 125 // asynchronous/non-blocking.
126 // Start() will use the second sequence if this method is called before. 126 // Start() will use the second sequence if this method is called before.
127 void SetDevice(int session_id); 127 void SetDevice(int session_id);
128 128
129 // Starts audio capturing. This method is asynchronous/non-blocking. 129 // Starts audio capturing. This method is asynchronous/non-blocking.
130 // TODO(henrika): add support for notification when recording has started. 130 // TODO(henrika): add support for notification when recording has started.
131 void Start(); 131 void Start();
132 132
133 // Stops audio capturing. This method is synchronous/blocking. 133 // Stops audio capturing. This method is synchronous/blocking.
134 // Returns |true| on success.
135 // TODO(henrika): add support for notification when recording has stopped. 134 // TODO(henrika): add support for notification when recording has stopped.
136 bool Stop(); 135 void Stop();
137 136
138 // Sets the capture volume scaling, with range [0.0, 1.0] inclusive. 137 // Sets the capture volume scaling, with range [0.0, 1.0] inclusive.
139 // Returns |true| on success. 138 // Returns |true| on success.
140 bool SetVolume(double volume); 139 bool SetVolume(double volume);
141 140
142 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive. 141 // Gets the capture volume scaling, with range [0.0, 1.0] inclusive.
143 // Returns |true| on success. 142 // Returns |true| on success.
144 bool GetVolume(double* volume); 143 bool GetVolume(double* volume);
145 144
146 double sample_rate() const { return audio_parameters_.sample_rate; } 145 double sample_rate() const { return audio_parameters_.sample_rate; }
(...skipping 16 matching lines...) Expand all
163 void InitializeOnIOThread(); 162 void InitializeOnIOThread();
164 void SetSessionIdOnIOThread(int session_id); 163 void SetSessionIdOnIOThread(int session_id);
165 void StartOnIOThread(); 164 void StartOnIOThread();
166 void ShutDownOnIOThread(base::WaitableEvent* completion); 165 void ShutDownOnIOThread(base::WaitableEvent* completion);
167 void SetVolumeOnIOThread(double volume); 166 void SetVolumeOnIOThread(double volume);
168 167
169 void Send(IPC::Message* message); 168 void Send(IPC::Message* message);
170 169
171 // Method called on the audio thread ---------------------------------------- 170 // Method called on the audio thread ----------------------------------------
172 // Calls the client's callback for capturing audio. 171 // Calls the client's callback for capturing audio.
173 void FireCaptureCallback(); 172 void FireCaptureCallback(int16* input_audio);
174 173
175 // DelegateSimpleThread::Delegate implementation. 174 // DelegateSimpleThread::Delegate implementation.
176 virtual void Run() OVERRIDE; 175 virtual void Run() OVERRIDE;
177 176
178 // Format 177 // Format
179 AudioParameters audio_parameters_; 178 AudioParameters audio_parameters_;
180 179
181 CaptureCallback* callback_; 180 CaptureCallback* callback_;
182 CaptureEventHandler* event_handler_; 181 CaptureEventHandler* event_handler_;
183 182
184 // The client callback receives captured audio here. 183 // The client callback receives captured audio here.
185 std::vector<float*> audio_data_; 184 std::vector<float*> audio_data_;
186 185
187 // The client stores the last reported audio delay in this member. 186 // The client stores the last reported audio delay in this member.
188 // The delay shall reflect the amount of audio which still resides in 187 // The delay shall reflect the amount of audio which still resides in
189 // the input buffer, i.e., the expected audio input delay. 188 // the input buffer, i.e., the expected audio input delay.
190 int audio_delay_milliseconds_; 189 int audio_delay_milliseconds_;
191 190
192 // The current volume scaling [0.0, 1.0] of the audio stream. 191 // The current volume scaling [0.0, 1.0] of the audio stream.
193 double volume_; 192 double volume_;
194 193
195 // Callbacks for capturing audio occur on this thread. 194 // Callbacks for capturing audio occur on this thread.
196 scoped_ptr<base::DelegateSimpleThread> audio_thread_; 195 scoped_ptr<base::DelegateSimpleThread> audio_thread_;
197 196
198 // IPC message stuff.
199 base::SharedMemory* shared_memory() { return shared_memory_.get(); }
200 base::SyncSocket* socket() { return socket_.get(); }
201 void* shared_memory_data() { return shared_memory()->memory(); }
202
203 // Cached audio input message filter (lives on the main render thread). 197 // Cached audio input message filter (lives on the main render thread).
204 scoped_refptr<AudioInputMessageFilter> filter_; 198 scoped_refptr<AudioInputMessageFilter> filter_;
205 199
206 // Our stream ID on the message filter. Only modified on the IO thread. 200 // Our stream ID on the message filter. Only modified on the IO thread.
207 int32 stream_id_; 201 int32 stream_id_;
208 202
209 // The media session ID used to identify which input device to be started. 203 // The media session ID used to identify which input device to be started.
210 // Only modified on the IO thread. 204 // Only modified on the IO thread.
211 int session_id_; 205 int session_id_;
212 206
213 // State variable used to indicate it is waiting for a OnDeviceReady() 207 // State variable used to indicate it is waiting for a OnDeviceReady()
214 // callback. Only modified on the IO thread. 208 // callback. Only modified on the IO thread.
215 bool pending_device_ready_; 209 bool pending_device_ready_;
216 210
217 scoped_ptr<base::SharedMemory> shared_memory_; 211 base::SharedMemoryHandle shared_memory_handle_;
218 scoped_ptr<base::SyncSocket> socket_; 212 base::SyncSocket::Handle socket_handle_;
213 int memory_length_;
219 214
220 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); 215 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice);
221 }; 216 };
222 217
223 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ 218 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/audio_device.cc ('k') | content/renderer/media/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698