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

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

Issue 9112029: Safe and reliable fix for 2 race conditions. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 11 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 // 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // Methods called on main render thread ------------------------------------- 95 // Methods called on main render thread -------------------------------------
96 96
97 // Minimal constructor where Initialize() must be called later. 97 // Minimal constructor where Initialize() must be called later.
98 AudioDevice(); 98 AudioDevice();
99 99
100 AudioDevice(size_t buffer_size, 100 AudioDevice(size_t buffer_size,
101 int channels, 101 int channels,
102 double sample_rate, 102 double sample_rate,
103 RenderCallback* callback); 103 RenderCallback* callback);
104 virtual ~AudioDevice();
105 104
106 void Initialize(size_t buffer_size, 105 void Initialize(size_t buffer_size,
107 int channels, 106 int channels,
108 double sample_rate, 107 double sample_rate,
109 AudioParameters::Format latency_format, 108 AudioParameters::Format latency_format,
110 RenderCallback* callback); 109 RenderCallback* callback);
111 bool IsInitialized(); 110 bool IsInitialized();
112 111
113 // Starts audio playback. 112 // Starts audio playback.
114 void Start(); 113 void Start();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 private: 170 private:
172 // Magic required by ref_counted.h to avoid any code deleting the object 171 // Magic required by ref_counted.h to avoid any code deleting the object
173 // accidently while there are references to it. 172 // accidently while there are references to it.
174 friend class base::RefCountedThreadSafe<AudioSocket>; 173 friend class base::RefCountedThreadSafe<AudioSocket>;
175 ~AudioSocket() { } 174 ~AudioSocket() { }
176 175
177 base::Lock lock_; 176 base::Lock lock_;
178 base::SyncSocket socket_; 177 base::SyncSocket socket_;
179 }; 178 };
180 179
180 // Magic required by ref_counted.h to avoid any code deleting the object
181 // accidently while there are references to it.
182 friend class base::RefCountedThreadSafe<AudioDevice>;
183 virtual ~AudioDevice();
184
181 // Methods called on IO thread ---------------------------------------------- 185 // Methods called on IO thread ----------------------------------------------
182 // The following methods are tasks posted on the IO thread that needs to 186 // The following methods are tasks posted on the IO thread that needs to
183 // be executed on that thread. They interact with AudioMessageFilter and 187 // be executed on that thread. They interact with AudioMessageFilter and
184 // sends IPC messages on that thread. 188 // sends IPC messages on that thread.
185 void InitializeOnIOThread(const AudioParameters& params); 189 void InitializeOnIOThread(const AudioParameters& params);
186 void PlayOnIOThread(); 190 void PlayOnIOThread();
187 void PauseOnIOThread(bool flush); 191 void PauseOnIOThread(bool flush);
188 void ShutDownOnIOThread(base::WaitableEvent* completion); 192 void ShutDownOnIOThread(base::WaitableEvent* completion);
189 void SetVolumeOnIOThread(double volume); 193 void SetVolumeOnIOThread(double volume);
190 194
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 256
253 // Protects lifetime of: 257 // Protects lifetime of:
254 // audio_socket_ 258 // audio_socket_
255 // audio_thread_ 259 // audio_thread_
256 base::Lock lock_; 260 base::Lock lock_;
257 261
258 DISALLOW_COPY_AND_ASSIGN(AudioDevice); 262 DISALLOW_COPY_AND_ASSIGN(AudioDevice);
259 }; 263 };
260 264
261 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ 265 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/audio_device.cc » ('j') | content/renderer/media/audio_device.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698