Chromium Code Reviews| Index: extensions/browser/api/audio/audio_service_chromeos.cc |
| diff --git a/extensions/browser/api/audio/audio_service_chromeos.cc b/extensions/browser/api/audio/audio_service_chromeos.cc |
| index 181900aab57dd8c48f4f3a61802b3be7fd1239aa..f24df7d04f198992b2c3d1578402bf7638c008c5 100644 |
| --- a/extensions/browser/api/audio/audio_service_chromeos.cc |
| +++ b/extensions/browser/api/audio/audio_service_chromeos.cc |
| @@ -48,10 +48,12 @@ class AudioServiceImpl : public AudioService, |
| // Start to query audio device information. |
| bool GetInfo(OutputInfo* output_info_out, InputInfo* input_info_out) override; |
| void SetActiveDevices(const DeviceIdList& device_list) override; |
| - bool SetDeviceProperties(const std::string& device_id, |
| - bool muted, |
| + bool SetDeviceSoundLevel(const std::string& device_id, |
| int volume, |
| int gain) override; |
| + bool SetMuteForDevice(const std::string& device_id, bool value) override; |
| + bool SetMute(bool is_input, bool value) override; |
| + bool GetMute(bool is_input, bool* value) override; |
| protected: |
| // chromeos::CrasAudioHandler::AudioObserver overrides. |
| @@ -158,8 +160,7 @@ void AudioServiceImpl::SetActiveDevices(const DeviceIdList& device_list) { |
| cras_audio_handler_->ChangeActiveNodes(id_list); |
| } |
| -bool AudioServiceImpl::SetDeviceProperties(const std::string& device_id, |
| - bool muted, |
| +bool AudioServiceImpl::SetDeviceSoundLevel(const std::string& device_id, |
| int volume, |
| int gain) { |
| DCHECK(cras_audio_handler_); |
| @@ -171,8 +172,6 @@ bool AudioServiceImpl::SetDeviceProperties(const std::string& device_id, |
| if (!found) |
| return false; |
| - cras_audio_handler_->SetMuteForDevice(device.id, muted); |
| - |
| if (!device.is_input && volume != -1) { |
| cras_audio_handler_->SetVolumeGainPercentForDevice(device.id, volume); |
| return true; |
| @@ -184,6 +183,47 @@ bool AudioServiceImpl::SetDeviceProperties(const std::string& device_id, |
| return false; |
| } |
| +bool AudioServiceImpl::SetMuteForDevice(const std::string& device_id, |
| + bool value) { |
| + DCHECK(cras_audio_handler_); |
| + if (!cras_audio_handler_) |
| + return false; |
| + |
| + chromeos::AudioDevice device; |
| + bool found = FindDevice(GetIdFromStr(device_id), &device); |
| + if (!found) |
| + return false; |
|
jennyz
2017/01/10 00:47:53
Combined into one line, no need to use bool found.
tbarzic
2017/01/11 00:47:03
Done.
|
| + |
| + cras_audio_handler_->SetMuteForDevice(device.id, value); |
| + return true; |
| +} |
| + |
| +bool AudioServiceImpl::SetMute(bool is_input, bool value) { |
| + DCHECK(cras_audio_handler_); |
| + if (!cras_audio_handler_) |
| + return false; |
| + |
| + if (is_input) { |
|
jennyz
2017/01/10 00:47:53
Don't need "{" for one line if or else block.
tbarzic
2017/01/11 00:47:03
Done.
|
| + cras_audio_handler_->SetInputMute(value); |
| + } else { |
| + cras_audio_handler_->SetOutputMute(value); |
| + } |
| + return true; |
| +} |
| + |
| +bool AudioServiceImpl::GetMute(bool is_input, bool* value) { |
| + DCHECK(cras_audio_handler_); |
| + if (!cras_audio_handler_) |
| + return false; |
| + |
| + if (is_input) { |
|
jennyz
2017/01/10 00:47:53
ditto
tbarzic
2017/01/11 00:47:03
Done.
|
| + *value = cras_audio_handler_->IsInputMuted(); |
| + } else { |
| + *value = cras_audio_handler_->IsOutputMuted(); |
| + } |
| + return true; |
| +} |
| + |
| bool AudioServiceImpl::FindDevice(uint64_t id, chromeos::AudioDevice* device) { |
| chromeos::AudioDeviceList devices; |
| cras_audio_handler_->GetAudioDevices(&devices); |
| @@ -266,6 +306,9 @@ void AudioServiceImpl::NotifyDevicesChanged() { |
| for (size_t i = 0; i < devices.size(); ++i) { |
| AudioDeviceInfo info; |
| info.id = base::Uint64ToString(devices[i].id); |
| + info.stream_type = devices[i].is_input |
| + ? extensions::api::audio::STREAM_TYPE_INPUT |
| + : extensions::api::audio::STREAM_TYPE_OUTPUT; |
| info.is_input = devices[i].is_input; |
| info.device_type = chromeos::AudioDevice::GetTypeString(devices[i].type); |
| info.display_name = devices[i].display_name; |