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

Unified Diff: media/audio/win/audio_low_latency_output_win.cc

Issue 23466008: Wire up the output device id and provide an implementation on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/win/audio_low_latency_output_win.h ('k') | media/audio/win/audio_manager_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_low_latency_output_win.cc
diff --git a/media/audio/win/audio_low_latency_output_win.cc b/media/audio/win/audio_low_latency_output_win.cc
index f2214707762f0fb0286f645e67decf9ad93f4bca..c889c03ef2cab02b4fbcc74fdedb35dc1c4df268 100644
--- a/media/audio/win/audio_low_latency_output_win.cc
+++ b/media/audio/win/audio_low_latency_output_win.cc
@@ -130,6 +130,7 @@ int WASAPIAudioOutputStream::HardwareSampleRate(const std::string& device_id) {
}
WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager,
+ const std::string& device_id,
const AudioParameters& params,
ERole device_role)
: creating_thread_id_(base::PlatformThread::CurrentId()),
@@ -138,6 +139,7 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager,
audio_parameters_are_valid_(false),
volume_(1.0),
endpoint_buffer_size_frames_(0),
+ device_id_(device_id),
device_role_(device_role),
share_mode_(GetShareMode()),
num_written_frames_(0),
@@ -153,12 +155,16 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager,
// channel count are excluded) to the preferred (native) audio parameters.
// Open() will fail if this is not the case.
AudioParameters preferred_params;
- HRESULT hr = CoreAudioUtil::GetPreferredAudioParameters(
- eRender, device_role, &preferred_params);
+ HRESULT hr = device_id_.empty() ?
+ CoreAudioUtil::GetPreferredAudioParameters(eRender, device_role,
+ &preferred_params) :
+ CoreAudioUtil::GetPreferredAudioParameters(device_id_,
+ &preferred_params);
audio_parameters_are_valid_ = SUCCEEDED(hr) &&
CompareAudioParametersNoBitDepthOrChannels(params, preferred_params);
LOG_IF(WARNING, !audio_parameters_are_valid_)
- << "Input and preferred parameters are not identical.";
+ << "Input and preferred parameters are not identical. "
+ << "Device id: " << device_id_;
}
// Load the Avrt DLL if not already loaded. Required to support MMCSS.
@@ -214,7 +220,6 @@ bool WASAPIAudioOutputStream::Open() {
if (opened_)
return true;
-
// Audio parameters must be identical to the preferred set of parameters
// if shared mode (default) is utilized.
if (share_mode_ == AUDCLNT_SHAREMODE_SHARED) {
@@ -225,8 +230,16 @@ bool WASAPIAudioOutputStream::Open() {
}
// Create an IAudioClient interface for the default rendering IMMDevice.
- ScopedComPtr<IAudioClient> audio_client =
- CoreAudioUtil::CreateDefaultClient(eRender, device_role_);
+ ScopedComPtr<IAudioClient> audio_client;
+ if (device_id_.empty()) {
+ audio_client = CoreAudioUtil::CreateDefaultClient(eRender, device_role_);
+ } else {
+ ScopedComPtr<IMMDevice> device(CoreAudioUtil::CreateDevice(device_id_));
+ DLOG_IF(ERROR, !device) << "Failed to open device: " << device_id_;
+ if (device)
+ audio_client = CoreAudioUtil::CreateClient(device);
+ }
+
if (!audio_client)
return false;
« no previous file with comments | « media/audio/win/audio_low_latency_output_win.h ('k') | media/audio/win/audio_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698