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

Side by Side Diff: media/audio/win/audio_low_latency_input_win.h

Issue 10909271: Adds COM init to AudioManager thread for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed Stop() call in ctor Created 8 years, 3 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
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/win/audio_low_latency_input_win.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) 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 // Implementation of AudioInputStream for Windows using Windows Core Audio 5 // Implementation of AudioInputStream for Windows using Windows Core Audio
6 // WASAPI for low latency capturing. 6 // WASAPI for low latency capturing.
7 // 7 //
8 // Overview of operation: 8 // Overview of operation:
9 // 9 //
10 // - An object of WASAPIAudioInputStream is created by the AudioManager 10 // - An object of WASAPIAudioInputStream is created by the AudioManager
(...skipping 17 matching lines...) Expand all
28 // - This implementation is single-threaded, hence: 28 // - This implementation is single-threaded, hence:
29 // o Construction and destruction must take place from the same thread. 29 // o Construction and destruction must take place from the same thread.
30 // o It is recommended to call all APIs from the same thread as well. 30 // o It is recommended to call all APIs from the same thread as well.
31 // - It is recommended to first acquire the native sample rate of the default 31 // - It is recommended to first acquire the native sample rate of the default
32 // input device and then use the same rate when creating this object. Use 32 // input device and then use the same rate when creating this object. Use
33 // WASAPIAudioInputStream::HardwareSampleRate() to retrieve the sample rate. 33 // WASAPIAudioInputStream::HardwareSampleRate() to retrieve the sample rate.
34 // - Calling Close() also leads to self destruction. 34 // - Calling Close() also leads to self destruction.
35 // 35 //
36 // Core Audio API details: 36 // Core Audio API details:
37 // 37 //
38 // - CoInitializeEx() is called on the creating thread and on the internal
39 // capture thread. Each thread's concurrency model and apartment is set
40 // to multi-threaded (MTA). CHECK() is called to ensure that we crash if
41 // CoInitializeEx(MTA) fails.
42 // - Utilized MMDevice interfaces: 38 // - Utilized MMDevice interfaces:
43 // o IMMDeviceEnumerator 39 // o IMMDeviceEnumerator
44 // o IMMDevice 40 // o IMMDevice
45 // - Utilized WASAPI interfaces: 41 // - Utilized WASAPI interfaces:
46 // o IAudioClient 42 // o IAudioClient
47 // o IAudioCaptureClient 43 // o IAudioCaptureClient
48 // - The stream is initialized in shared mode and the processing of the 44 // - The stream is initialized in shared mode and the processing of the
49 // audio buffer is event driven. 45 // audio buffer is event driven.
50 // - The Multimedia Class Scheduler service (MMCSS) is utilized to boost 46 // - The Multimedia Class Scheduler service (MMCSS) is utilized to boost
51 // the priority of the capture thread. 47 // the priority of the capture thread.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 HRESULT ActivateCaptureDevice(); 123 HRESULT ActivateCaptureDevice();
128 HRESULT GetAudioEngineStreamFormat(); 124 HRESULT GetAudioEngineStreamFormat();
129 bool DesiredFormatIsSupported(); 125 bool DesiredFormatIsSupported();
130 HRESULT InitializeAudioEngine(); 126 HRESULT InitializeAudioEngine();
131 127
132 // Retrieves the stream format that the audio engine uses for its internal 128 // Retrieves the stream format that the audio engine uses for its internal
133 // processing/mixing of shared-mode streams. 129 // processing/mixing of shared-mode streams.
134 static HRESULT GetMixFormat(const std::string& device_id, 130 static HRESULT GetMixFormat(const std::string& device_id,
135 WAVEFORMATEX** device_format); 131 WAVEFORMATEX** device_format);
136 132
137 // Initializes the COM library for use by the calling thread and set the
138 // thread's concurrency model to multi-threaded.
139 base::win::ScopedCOMInitializer com_init_;
140
141 // Our creator, the audio manager needs to be notified when we close. 133 // Our creator, the audio manager needs to be notified when we close.
142 AudioManagerWin* manager_; 134 AudioManagerWin* manager_;
143 135
144 // Capturing is driven by this thread (which has no message loop). 136 // Capturing is driven by this thread (which has no message loop).
145 // All OnData() callbacks will be called from this thread. 137 // All OnData() callbacks will be called from this thread.
146 base::DelegateSimpleThread* capture_thread_; 138 base::DelegateSimpleThread* capture_thread_;
147 139
148 // Contains the desired audio format which is set up at construction. 140 // Contains the desired audio format which is set up at construction.
149 WAVEFORMATEX format_; 141 WAVEFORMATEX format_;
150 142
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 200
209 // This event will be signaled when capturing shall stop. 201 // This event will be signaled when capturing shall stop.
210 base::win::ScopedHandle stop_capture_event_; 202 base::win::ScopedHandle stop_capture_event_;
211 203
212 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioInputStream); 204 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioInputStream);
213 }; 205 };
214 206
215 } // namespace media 207 } // namespace media
216 208
217 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_INPUT_WIN_H_ 209 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_INPUT_WIN_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/win/audio_low_latency_input_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698