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 14ef242759a68d48db6da943ebb899b1089c3cf6..4ae006b210b324eab063ec98475f4e0a89d4cc87 100644 |
| --- a/media/audio/pulse/pulse_input.cc |
| +++ b/media/audio/pulse/pulse_input.cc |
| @@ -30,6 +30,7 @@ PulseAudioInputStream::PulseAudioInputStream(AudioManagerPulse* audio_manager, |
| channels_(0), |
| volume_(0.0), |
| stream_started_(false), |
| + muted_(false), |
| fifo_(params.channels(), |
| params.frames_per_buffer(), |
| kNumberOfBlocksBufferInFifo), |
| @@ -199,6 +200,20 @@ double PulseAudioInputStream::GetVolume() { |
| } |
| } |
| +bool PulseAudioInputStream::IsMuted() { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + AutoPulseLock auto_lock(pa_mainloop_); |
|
no longer working on chromium
2014/10/14 11:45:42
please extract these lines of code into a helper m
henrika (OOO until Aug 14)
2014/10/14 14:21:13
Done.
|
| + if (!handle_) |
| + return false; |
| + |
| + size_t index = pa_stream_get_device_index(handle_); |
| + pa_operation* operation = pa_context_get_source_info_by_index( |
| + pa_context_, index, &MuteCallback, this); |
| + WaitForOperationCompletion(pa_mainloop_, operation); |
| + |
| + return muted_; |
| +} |
| + |
| // static, used by pa_stream_set_read_callback. |
| void PulseAudioInputStream::ReadCallback(pa_stream* handle, |
| size_t length, |
| @@ -236,6 +251,21 @@ void PulseAudioInputStream::VolumeCallback(pa_context* context, |
| stream->volume_ = static_cast<double>(volume); |
| } |
| +// static, used by pa_context_get_source_info_by_index. |
| +void PulseAudioInputStream::MuteCallback(pa_context* context, |
| + const pa_source_info* info, |
| + int error, void* user_data) { |
| + PulseAudioInputStream* stream = |
| + reinterpret_cast<PulseAudioInputStream*>(user_data); |
| + |
| + if (error) { |
| + pa_threaded_mainloop_signal(stream->pa_mainloop_, 0); |
| + return; |
| + } |
| + |
| + stream->muted_ = static_cast<bool>(info->mute); |
| +} |
| + |
| // static, used by pa_stream_set_state_callback. |
| void PulseAudioInputStream::StreamNotifyCallback(pa_stream* s, |
| void* user_data) { |