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

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

Issue 11233023: Handle audio device changes on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments! Created 8 years, 1 month 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>
11 #include <setupapi.h> 11 #include <setupapi.h>
12 12
13 #include "base/bind.h"
14 #include "base/bind_helpers.h"
13 #include "base/basictypes.h" 15 #include "base/basictypes.h"
14 #include "base/command_line.h" 16 #include "base/command_line.h"
15 #include "base/file_path.h" 17 #include "base/file_path.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/path_service.h" 19 #include "base/path_service.h"
18 #include "base/process_util.h" 20 #include "base/process_util.h"
19 #include "base/string_number_conversions.h" 21 #include "base/string_number_conversions.h"
20 #include "base/string_util.h" 22 #include "base/string_util.h"
21 #include "media/audio/audio_util.h" 23 #include "media/audio/audio_util.h"
22 #include "media/audio/win/audio_low_latency_input_win.h" 24 #include "media/audio/win/audio_low_latency_input_win.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 118 }
117 119
118 bool AudioManagerWin::HasAudioOutputDevices() { 120 bool AudioManagerWin::HasAudioOutputDevices() {
119 return (::waveOutGetNumDevs() != 0); 121 return (::waveOutGetNumDevs() != 0);
120 } 122 }
121 123
122 bool AudioManagerWin::HasAudioInputDevices() { 124 bool AudioManagerWin::HasAudioInputDevices() {
123 return (::waveInGetNumDevs() != 0); 125 return (::waveInGetNumDevs() != 0);
124 } 126 }
125 127
128 void AudioManagerWin::Init() {
129 AudioManagerBase::Init();
130 output_device_listener_.reset(new AudioDeviceListenerWin(this));
131 }
132
126 string16 AudioManagerWin::GetAudioInputDeviceModel() { 133 string16 AudioManagerWin::GetAudioInputDeviceModel() {
127 // Get the default audio capture device and its device interface name. 134 // Get the default audio capture device and its device interface name.
128 DWORD device_id = 0; 135 DWORD device_id = 0;
129 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER), 136 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER),
130 DRVM_MAPPER_PREFERRED_GET, 137 DRVM_MAPPER_PREFERRED_GET,
131 reinterpret_cast<DWORD_PTR>(&device_id), NULL); 138 reinterpret_cast<DWORD_PTR>(&device_id), NULL);
132 ULONG device_interface_name_size = 0; 139 ULONG device_interface_name_size = 0;
133 waveInMessage(reinterpret_cast<HWAVEIN>(device_id), 140 waveInMessage(reinterpret_cast<HWAVEIN>(device_id),
134 DRV_QUERYDEVICEINTERFACESIZE, 141 DRV_QUERYDEVICEINTERFACESIZE,
135 reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0); 142 reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 bits_per_sample = 16; 345 bits_per_sample = 16;
339 channel_layout = WASAPIAudioOutputStream::HardwareChannelLayout(); 346 channel_layout = WASAPIAudioOutputStream::HardwareChannelLayout();
340 } 347 }
341 348
342 // TODO(dalecurtis): This should include hardware bits per channel eventually. 349 // TODO(dalecurtis): This should include hardware bits per channel eventually.
343 return AudioParameters( 350 return AudioParameters(
344 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 351 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
345 sample_rate, bits_per_sample, GetAudioHardwareBufferSize()); 352 sample_rate, bits_per_sample, GetAudioHardwareBufferSize());
346 } 353 }
347 354
355 void AudioManagerWin::OnDeviceChange() {
356 GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
357 &AudioManagerWin::NotifyAllOutputDeviceChangeListeners,
358 base::Unretained(this)));
359 }
360
348 } // namespace media 361 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698