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

Side by Side Diff: media/audio/win/audio_manager_win.cc

Issue 66183002: Replace MessageLoopProxy with SingleThreadTaskRunner for the rest of media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win and audio tests Created 6 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 #include "media/audio/audio_io.h" 5 #include "media/audio/audio_io.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <objbase.h> // This has to be before initguid.h 8 #include <objbase.h> // This has to be before initguid.h
9 #include <initguid.h> 9 #include <initguid.h>
10 #include <mmsystem.h> 10 #include <mmsystem.h>
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 enumeration_type_ = kWaveEnumeration; 134 enumeration_type_ = kWaveEnumeration;
135 } else { 135 } else {
136 // Use the MMDevice API for device enumeration if Vista or higher. 136 // Use the MMDevice API for device enumeration if Vista or higher.
137 enumeration_type_ = kMMDeviceEnumeration; 137 enumeration_type_ = kMMDeviceEnumeration;
138 } 138 }
139 139
140 SetMaxOutputStreamsAllowed(kMaxOutputStreams); 140 SetMaxOutputStreamsAllowed(kMaxOutputStreams);
141 141
142 // Task must be posted last to avoid races from handing out "this" to the 142 // Task must be posted last to avoid races from handing out "this" to the
143 // audio thread. 143 // audio thread.
144 GetMessageLoop()->PostTask(FROM_HERE, base::Bind( 144 GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
145 &AudioManagerWin::CreateDeviceListener, base::Unretained(this))); 145 &AudioManagerWin::CreateDeviceListener, base::Unretained(this)));
146 } 146 }
147 147
148 AudioManagerWin::~AudioManagerWin() { 148 AudioManagerWin::~AudioManagerWin() {
149 // It's safe to post a task here since Shutdown() will wait for all tasks to 149 // It's safe to post a task here since Shutdown() will wait for all tasks to
150 // complete before returning. 150 // complete before returning.
151 GetMessageLoop()->PostTask(FROM_HERE, base::Bind( 151 GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
152 &AudioManagerWin::DestroyDeviceListener, base::Unretained(this))); 152 &AudioManagerWin::DestroyDeviceListener, base::Unretained(this)));
153 Shutdown(); 153 Shutdown();
154 } 154 }
155 155
156 bool AudioManagerWin::HasAudioOutputDevices() { 156 bool AudioManagerWin::HasAudioOutputDevices() {
157 return (::waveOutGetNumDevs() != 0); 157 return (::waveOutGetNumDevs() != 0);
158 } 158 }
159 159
160 bool AudioManagerWin::HasAudioInputDevices() { 160 bool AudioManagerWin::HasAudioInputDevices() {
161 return (::waveInGetNumDevs() != 0); 161 return (::waveInGetNumDevs() != 0);
162 } 162 }
163 163
164 void AudioManagerWin::CreateDeviceListener() { 164 void AudioManagerWin::CreateDeviceListener() {
165 // AudioDeviceListenerWin must be initialized on a COM thread and should only 165 // AudioDeviceListenerWin must be initialized on a COM thread and should only
166 // be used if WASAPI / Core Audio is supported. 166 // be used if WASAPI / Core Audio is supported.
167 if (CoreAudioUtil::IsSupported()) { 167 if (CoreAudioUtil::IsSupported()) {
168 output_device_listener_.reset(new AudioDeviceListenerWin(BindToLoop( 168 output_device_listener_.reset(new AudioDeviceListenerWin(BindToLoop(
169 GetMessageLoop(), base::Bind( 169 GetTaskRunner(), base::Bind(
170 &AudioManagerWin::NotifyAllOutputDeviceChangeListeners, 170 &AudioManagerWin::NotifyAllOutputDeviceChangeListeners,
171 base::Unretained(this))))); 171 base::Unretained(this)))));
172 } 172 }
173 } 173 }
174 174
175 void AudioManagerWin::DestroyDeviceListener() { 175 void AudioManagerWin::DestroyDeviceListener() {
176 output_device_listener_.reset(); 176 output_device_listener_.reset();
177 } 177 }
178 178
179 base::string16 AudioManagerWin::GetAudioInputDeviceModel() { 179 base::string16 AudioManagerWin::GetAudioInputDeviceModel() {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 523 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
524 xp_device_id); 524 xp_device_id);
525 } 525 }
526 526
527 /// static 527 /// static
528 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { 528 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
529 return new AudioManagerWin(audio_log_factory); 529 return new AudioManagerWin(audio_log_factory);
530 } 530 }
531 531
532 } // namespace media 532 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/virtual_audio_output_stream_unittest.cc ('k') | media/base/bind_to_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698