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

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

Issue 23523023: Add GetOutputStreamParameters, GetAssociatedOutputDeviceID to AudioManager. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 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
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/win/audio_low_latency_output_win.h" 5 #include "media/audio/win/audio_low_latency_output_win.h"
6 6
7 #include <Functiondiscoverykeys_devpkey.h> 7 #include <Functiondiscoverykeys_devpkey.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 eRender, eConsole, &format)) ? 104 eRender, eConsole, &format)) ?
105 static_cast<int>(format.Format.nChannels) : 0; 105 static_cast<int>(format.Format.nChannels) : 0;
106 } 106 }
107 107
108 // static 108 // static
109 ChannelLayout WASAPIAudioOutputStream::HardwareChannelLayout() { 109 ChannelLayout WASAPIAudioOutputStream::HardwareChannelLayout() {
110 return ChannelConfigToChannelLayout(GetChannelConfig()); 110 return ChannelConfigToChannelLayout(GetChannelConfig());
111 } 111 }
112 112
113 // static 113 // static
114 int WASAPIAudioOutputStream::HardwareSampleRate() { 114 int WASAPIAudioOutputStream::HardwareSampleRate(const std::string& device_id) {
115 WAVEFORMATPCMEX format; 115 WAVEFORMATPCMEX format;
116 return SUCCEEDED(CoreAudioUtil::GetDefaultSharedModeMixFormat( 116 ScopedComPtr<IAudioClient> client;
117 eRender, eConsole, &format)) ? 117 if (device_id.empty()) {
118 static_cast<int>(format.Format.nSamplesPerSec) : 0; 118 client = CoreAudioUtil::CreateDefaultClient(eRender, eConsole);
119 } else {
120 ScopedComPtr<IMMDevice> device(CoreAudioUtil::CreateDevice(device_id));
121 if (!device)
122 return 0;
123 client = CoreAudioUtil::CreateClient(device);
124 }
125
126 if (!client || FAILED(CoreAudioUtil::GetSharedModeMixFormat(client, &format)))
127 return 0;
128
129 return static_cast<int>(format.Format.nSamplesPerSec);
119 } 130 }
120 131
121 WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, 132 WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager,
122 const AudioParameters& params, 133 const AudioParameters& params,
123 ERole device_role) 134 ERole device_role)
124 : creating_thread_id_(base::PlatformThread::CurrentId()), 135 : creating_thread_id_(base::PlatformThread::CurrentId()),
125 manager_(manager), 136 manager_(manager),
126 opened_(false), 137 opened_(false),
127 audio_parameters_are_valid_(false), 138 audio_parameters_are_valid_(false),
128 volume_(1.0), 139 volume_(1.0),
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 VLOG(1) << "IAudioClient::GetBufferSize: " << std::hex << hr; 687 VLOG(1) << "IAudioClient::GetBufferSize: " << std::hex << hr;
677 return hr; 688 return hr;
678 } 689 }
679 690
680 *endpoint_buffer_size = buffer_size_in_frames; 691 *endpoint_buffer_size = buffer_size_in_frames;
681 VLOG(2) << "endpoint buffer size: " << buffer_size_in_frames; 692 VLOG(2) << "endpoint buffer size: " << buffer_size_in_frames;
682 return hr; 693 return hr;
683 } 694 }
684 695
685 } // namespace media 696 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698