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

Unified Diff: media/audio/pulse/pulse_input.cc

Issue 1711823004: Let default device in PulseAudio be the system default device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 9 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
Index: media/audio/pulse/pulse_input.cc
diff --git a/media/audio/pulse/pulse_input.cc b/media/audio/pulse/pulse_input.cc
index 8d4aeea2079d201a69e52fb48e4344680c467d70..627367eea38bafbf65dd2d594fbc102eff2c3c30 100644
--- a/media/audio/pulse/pulse_input.cc
+++ b/media/audio/pulse/pulse_input.cc
@@ -48,11 +48,39 @@ PulseAudioInputStream::~PulseAudioInputStream() {
DCHECK(!handle_);
}
+// static, used by pa_context_get_server_info.
+void PulseAudioInputStream::GetSystemDefaultInputDeviceCallback(
+ pa_context* context,
+ const pa_server_info* info,
+ void* user_data) {
+ PulseAudioInputStream* stream =
+ reinterpret_cast<PulseAudioInputStream*>(user_data);
+ stream->default_system_device_name_ = info->default_source_name;
Henrik Grunell 2016/03/09 00:49:17 Add setter function for |default_system_device_nam
rchtara 2016/03/09 16:16:09 Done.
+ pa_threaded_mainloop* pa_mainloop =
+ static_cast<pa_threaded_mainloop*>(stream->pa_mainloop_);
Henrik Grunell 2016/03/09 00:49:17 It doesn't look like casting is needed here.
rchtara 2016/03/09 16:16:09 Done.
+ pa_threaded_mainloop_signal(pa_mainloop, 0);
+}
+
+void PulseAudioInputStream::GetSystemDefaultInputDevice() {
+ DCHECK(pa_mainloop_);
+ DCHECK(pa_context_);
+ pa_operation* operation = pa_context_get_server_info(
+ pa_context_, PulseAudioInputStream::GetSystemDefaultInputDeviceCallback,
+ this);
+ WaitForOperationCompletion(pa_mainloop_, operation);
+}
+
bool PulseAudioInputStream::Open() {
DCHECK(thread_checker_.CalledOnValidThread());
AutoPulseLock auto_lock(pa_mainloop_);
+ std::string device_to_use_ = device_name_;
Henrik Grunell 2016/03/09 00:49:17 "device_to_use_" -> "device_name_to_use". (No trai
rchtara 2016/03/09 16:16:09 Done.
+ if (device_name_ == AudioManagerBase::kDefaultDeviceId) {
+ GetSystemDefaultInputDevice();
+ device_to_use_ = default_system_device_name_;
+ }
+
if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &handle_, params_,
- device_name_, &StreamNotifyCallback, this)) {
+ device_to_use_, &StreamNotifyCallback, this)) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698