Chromium Code Reviews| Index: device/bluetooth/bluetooth_audio_sink_chromeos.cc |
| diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.cc b/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e503f508d7a0d403a92109c76d6b2c3777289faa |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
| @@ -0,0 +1,135 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "device/bluetooth/bluetooth_audio_sink.h" |
|
armansito
2014/12/09 00:30:28
You don't need to include this, bluetooth_audio_si
Miao
2014/12/10 04:07:19
Done.
|
| +#include "device/bluetooth/bluetooth_audio_sink_chromeos.h" |
| + |
| +namespace chromeos { |
| + |
| +void BluetoothAudioSinkChromeOS::AddObserver( |
|
Ben Chan
2014/12/09 15:28:37
nit: try to keep the method definitions and declar
|
| + device::BluetoothAudioSink::Observer* observer) { |
| + DCHECK(observer); |
| + observers_.AddObserver(observer); |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::RemoveObserver( |
| + device::BluetoothAudioSink::Observer* observer) { |
| + DCHECK(observer); |
| + observers_.RemoveObserver(observer); |
| +} |
| + |
| +device::BluetoothAudioSink::State BluetoothAudioSinkChromeOS::GetState() const { |
| + return state_; |
| +} |
| + |
| +uint16_t BluetoothAudioSinkChromeOS::GetVolume() const { |
| + return volume_; |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::AdapterPresentChanged( |
| + device::BluetoothAdapter* adapter, |
| + bool present) { |
| + // If |persent| is true, change state to |STATE_DISCONNECTED| and call |
|
armansito
2014/12/09 00:30:28
Precede all of your comments below with a TODO and
Miao
2014/12/10 04:07:19
Done.
|
| + // StateChanged(). Otherwise, change state to |STATE_INVALID| and call |
| + // StateChanged. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( |
| + device::BluetoothAdapter* adapter, |
| + bool powered) { |
| + // If |powered| is true, change state to |STATE_DISCONNECTED| and call |
| + // StateChanged(). Otherwise, change state to |STATE_INVALID| and call |
| + // StateChanged. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::MediaAdded( |
| + const dbus::ObjectPath& object_path) { |
| + // Do nothing for now. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::MediaRemoved( |
| + const dbus::ObjectPath& object_path) { |
| + // Check if |object_path| equals to |media_path_|. If true, change the state |
| + // of the audio sink, call StateChanged and reset the audio sink. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::MediaTransportAdded( |
| + const dbus::ObjectPath& object_path) { |
| + // Do nothing for now. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::MediaTransportRemoved( |
| + const dbus::ObjectPath& object_path) { |
| + // Check if |object_path| equals to |transport_path_|. If true, change the |
| + // state of the audio sink, call StateChanged and reset the audio sink. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( |
| + const dbus::ObjectPath& object_path, |
| + const std::string& property_name) { |
| + // Call StateChanged and VolumeChanged accordingly if there is any change on |
| + // state/volume. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::SetConfiguration( |
| + const dbus::ObjectPath& transport_path, |
| + const dbus::MessageReader& properties) { |
| + // Update |transport_path_| and store properties if needed. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::SelectConfiguration( |
| + const std::vector<uint8_t>& capabilities, |
| + const SelectConfigurationCallback& callback) { |
| + // Use SelectConfigurationCallback to return the agreed capabilities. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::ClearConfiguration( |
| + const dbus::ObjectPath& transport_path) { |
| + // Reset the configuration to the default one and close IOBuffer. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::Release() { |
| + // Let the audio sink does the clean-up and do nothing here. |
| +} |
| + |
| +void Register( |
| + const device::BluetoothAudioSink::Options& options, |
| + const device::BluetoothAudioSink::AudioSinkAcquiredCallback& callback, |
| + const device::BluetoothAudioSink::ErrorCallback& error_callback) { |
| + // Get Media object, initiate an Media Endpoint with options, and return the |
| + // audio sink via callback. |
| +} |
| + |
| +void Unregister( |
| + const base::Closure& callback, |
| + const device::BluetoothAudioSink::ErrorCallback& error_callback) { |
| + // Clean |observers_| and transport_path_ and reset state_ and volume. |
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::StateChanged( |
| + const dbus::ObjectPath& object_path, |
| + device::BluetoothAudioSink::State state) { |
| + VLOG(1) << "Bluetooth audio sink state changed"; |
|
armansito
2014/12/09 00:30:28
Log the state?
Miao
2014/12/10 04:07:19
Done.
|
| + state_ = state; |
|
armansito
2014/12/09 00:30:28
I'd notify the observers only if the state actuall
Miao
2014/12/10 04:07:19
Will put a DCHECK_NQ here before notifying observe
|
| + FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_, |
| + BluetoothAudioSinkStateChanged(this, state_)); |
|
armansito
2014/12/09 00:30:28
I'd notify the observers only if the state actuall
|
| +} |
| + |
| +void BluetoothAudioSinkChromeOS::VolumeChanged( |
| + const dbus::ObjectPath& object_path, |
| + uint16_t volume) { |
| + VLOG(1) << "Bluetooth audio sink volume changed"; |
|
armansito
2014/12/09 00:30:28
Log the volume?
Miao
2014/12/10 04:07:19
Done.
|
| + volume_ = volume; |
|
armansito
2014/12/09 00:30:28
I'd notify the observers only if the volume actual
Miao
2014/12/10 04:07:19
The same as StateChanged.
|
| + FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_, |
| + BluetoothAudioSinkVolumeChanged(this, volume_)); |
| +} |
| + |
| +BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS() |
| + : state_(device::BluetoothAudioSink::STATE_INVALID), volume_(0) { |
|
armansito
2014/12/09 00:30:28
nit: each variable in its own line.
Miao
2014/12/10 04:07:19
Done.
|
| +} |
| + |
| +BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { |
| +} |
|
armansito
2014/12/09 00:30:28
Move the declarations of ctor/dtor before all the
Miao
2014/12/10 04:07:19
Done.
|
| + |
| +} // namespace chromeos |