Chromium Code Reviews| 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..6b43e413c1d11d32214387f75109d9abf22858f9 100644 |
| --- a/media/audio/pulse/pulse_input.cc |
| +++ b/media/audio/pulse/pulse_input.cc |
| @@ -48,9 +48,36 @@ PulseAudioInputStream::~PulseAudioInputStream() { |
| DCHECK(!handle_); |
| } |
| +// static, used by pa_context_get_server_info. |
| +void PulseAudioInputStream::UseSystemDefaultInputDeviceCallback( |
|
Henrik Grunell
2016/03/07 11:37:17
Since this function is only used in this cc file,
rchtara
2016/03/08 17:28:16
I tried to do that by making it friend with PulseA
Henrik Grunell
2016/03/09 00:49:16
I don't understand what the problem is. Is it acce
rchtara
2016/03/09 16:16:09
If we put the function UseSystemDefaultInputDevice
|
| + pa_context* context, |
| + const pa_server_info* info, |
| + void* user_data) { |
| + PulseAudioInputStream* stream = |
| + reinterpret_cast<PulseAudioInputStream*>(user_data); |
| + stream->device_name_ = info->default_source_name; |
|
Henrik Grunell
2016/03/07 11:37:17
Same here as for output (see that comment), add a
rchtara
2016/03/08 17:28:16
Done.
|
| + pa_threaded_mainloop* pa_mainloop = |
| + static_cast<pa_threaded_mainloop*>(stream->pa_mainloop_); |
| + pa_threaded_mainloop_signal(pa_mainloop, 0); |
| +} |
| + |
| +void PulseAudioInputStream::UseSystemDefaultInputDevice() { |
| + DCHECK(pa_mainloop_); |
| + DCHECK(pa_context_); |
| + pa_operation* operation = pa_context_get_server_info( |
| + pa_context_, PulseAudioInputStream::UseSystemDefaultInputDeviceCallback, |
| + this); |
| + WaitForOperationCompletion(pa_mainloop_, operation); |
| +} |
| + |
| bool PulseAudioInputStream::Open() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| AutoPulseLock auto_lock(pa_mainloop_); |
| + |
| + if (device_name_ == AudioManagerBase::kDefaultDeviceId) { |
| + UseSystemDefaultInputDevice(); |
|
Henrik Grunell
2016/03/07 11:37:17
Should this function be called under the lock?
rchtara
2016/03/08 17:28:16
I'm not sure, it works even the lock is completely
|
| + } |
| + |
| if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &handle_, params_, |
| device_name_, &StreamNotifyCallback, this)) { |
| return false; |