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

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: 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
« no previous file with comments | « media/audio/pulse/pulse_input.h ('k') | media/audio/pulse/pulse_output.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..db13935d23aad80b3d34e1d94f851ba99a22f148 100644
--- a/media/audio/pulse/pulse_input.cc
+++ b/media/audio/pulse/pulse_input.cc
@@ -51,8 +51,15 @@ PulseAudioInputStream::~PulseAudioInputStream() {
bool PulseAudioInputStream::Open() {
DCHECK(thread_checker_.CalledOnValidThread());
AutoPulseLock auto_lock(pa_mainloop_);
+ std::string device_name_to_use = device_name_;
+ if (device_name_ == AudioManagerBase::kDefaultDeviceId) {
+ GetSystemDefaultInputDevice();
+ device_name_to_use = default_system_device_name_;
+ }
+
if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &handle_, params_,
- device_name_, &StreamNotifyCallback, this)) {
+ device_name_to_use, &StreamNotifyCallback,
+ this)) {
return false;
}
@@ -268,6 +275,26 @@ void PulseAudioInputStream::StreamNotifyCallback(pa_stream* s,
pa_threaded_mainloop_signal(stream->pa_mainloop_, 0);
}
+// static, used by pa_context_get_server_info.
+void PulseAudioInputStream::GetSystemDefaultInputDeviceCallback(
+ pa_context* context,
+ const pa_server_info* info,
+ void* user_data) {
+ media::PulseAudioInputStream* stream =
+ static_cast<media::PulseAudioInputStream*>(user_data);
+ stream->default_system_device_name_ = info->default_source_name;
+ pa_threaded_mainloop_signal(stream->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);
+}
+
void PulseAudioInputStream::ReadData() {
uint32_t hardware_delay = pulse::GetHardwareLatencyInBytes(
handle_, params_.sample_rate(), params_.GetBytesPerFrame());
« no previous file with comments | « media/audio/pulse/pulse_input.h ('k') | media/audio/pulse/pulse_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698