Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #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.
| |
| 6 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h" | |
| 7 | |
| 8 namespace chromeos { | |
| 9 | |
| 10 void BluetoothAudioSinkChromeOS::AddObserver( | |
|
Ben Chan
2014/12/09 15:28:37
nit: try to keep the method definitions and declar
| |
| 11 device::BluetoothAudioSink::Observer* observer) { | |
| 12 DCHECK(observer); | |
| 13 observers_.AddObserver(observer); | |
| 14 } | |
| 15 | |
| 16 void BluetoothAudioSinkChromeOS::RemoveObserver( | |
| 17 device::BluetoothAudioSink::Observer* observer) { | |
| 18 DCHECK(observer); | |
| 19 observers_.RemoveObserver(observer); | |
| 20 } | |
| 21 | |
| 22 device::BluetoothAudioSink::State BluetoothAudioSinkChromeOS::GetState() const { | |
| 23 return state_; | |
| 24 } | |
| 25 | |
| 26 uint16_t BluetoothAudioSinkChromeOS::GetVolume() const { | |
| 27 return volume_; | |
| 28 } | |
| 29 | |
| 30 void BluetoothAudioSinkChromeOS::AdapterPresentChanged( | |
| 31 device::BluetoothAdapter* adapter, | |
| 32 bool present) { | |
| 33 // 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.
| |
| 34 // StateChanged(). Otherwise, change state to |STATE_INVALID| and call | |
| 35 // StateChanged. | |
| 36 } | |
| 37 | |
| 38 void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( | |
| 39 device::BluetoothAdapter* adapter, | |
| 40 bool powered) { | |
| 41 // If |powered| is true, change state to |STATE_DISCONNECTED| and call | |
| 42 // StateChanged(). Otherwise, change state to |STATE_INVALID| and call | |
| 43 // StateChanged. | |
| 44 } | |
| 45 | |
| 46 void BluetoothAudioSinkChromeOS::MediaAdded( | |
| 47 const dbus::ObjectPath& object_path) { | |
| 48 // Do nothing for now. | |
| 49 } | |
| 50 | |
| 51 void BluetoothAudioSinkChromeOS::MediaRemoved( | |
| 52 const dbus::ObjectPath& object_path) { | |
| 53 // Check if |object_path| equals to |media_path_|. If true, change the state | |
| 54 // of the audio sink, call StateChanged and reset the audio sink. | |
| 55 } | |
| 56 | |
| 57 void BluetoothAudioSinkChromeOS::MediaTransportAdded( | |
| 58 const dbus::ObjectPath& object_path) { | |
| 59 // Do nothing for now. | |
| 60 } | |
| 61 | |
| 62 void BluetoothAudioSinkChromeOS::MediaTransportRemoved( | |
| 63 const dbus::ObjectPath& object_path) { | |
| 64 // Check if |object_path| equals to |transport_path_|. If true, change the | |
| 65 // state of the audio sink, call StateChanged and reset the audio sink. | |
| 66 } | |
| 67 | |
| 68 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( | |
| 69 const dbus::ObjectPath& object_path, | |
| 70 const std::string& property_name) { | |
| 71 // Call StateChanged and VolumeChanged accordingly if there is any change on | |
| 72 // state/volume. | |
| 73 } | |
| 74 | |
| 75 void BluetoothAudioSinkChromeOS::SetConfiguration( | |
| 76 const dbus::ObjectPath& transport_path, | |
| 77 const dbus::MessageReader& properties) { | |
| 78 // Update |transport_path_| and store properties if needed. | |
| 79 } | |
| 80 | |
| 81 void BluetoothAudioSinkChromeOS::SelectConfiguration( | |
| 82 const std::vector<uint8_t>& capabilities, | |
| 83 const SelectConfigurationCallback& callback) { | |
| 84 // Use SelectConfigurationCallback to return the agreed capabilities. | |
| 85 } | |
| 86 | |
| 87 void BluetoothAudioSinkChromeOS::ClearConfiguration( | |
| 88 const dbus::ObjectPath& transport_path) { | |
| 89 // Reset the configuration to the default one and close IOBuffer. | |
| 90 } | |
| 91 | |
| 92 void BluetoothAudioSinkChromeOS::Release() { | |
| 93 // Let the audio sink does the clean-up and do nothing here. | |
| 94 } | |
| 95 | |
| 96 void Register( | |
| 97 const device::BluetoothAudioSink::Options& options, | |
| 98 const device::BluetoothAudioSink::AudioSinkAcquiredCallback& callback, | |
| 99 const device::BluetoothAudioSink::ErrorCallback& error_callback) { | |
| 100 // Get Media object, initiate an Media Endpoint with options, and return the | |
| 101 // audio sink via callback. | |
| 102 } | |
| 103 | |
| 104 void Unregister( | |
| 105 const base::Closure& callback, | |
| 106 const device::BluetoothAudioSink::ErrorCallback& error_callback) { | |
| 107 // Clean |observers_| and transport_path_ and reset state_ and volume. | |
| 108 } | |
| 109 | |
| 110 void BluetoothAudioSinkChromeOS::StateChanged( | |
| 111 const dbus::ObjectPath& object_path, | |
| 112 device::BluetoothAudioSink::State state) { | |
| 113 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.
| |
| 114 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
| |
| 115 FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_, | |
| 116 BluetoothAudioSinkStateChanged(this, state_)); | |
|
armansito
2014/12/09 00:30:28
I'd notify the observers only if the state actuall
| |
| 117 } | |
| 118 | |
| 119 void BluetoothAudioSinkChromeOS::VolumeChanged( | |
| 120 const dbus::ObjectPath& object_path, | |
| 121 uint16_t volume) { | |
| 122 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.
| |
| 123 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.
| |
| 124 FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_, | |
| 125 BluetoothAudioSinkVolumeChanged(this, volume_)); | |
| 126 } | |
| 127 | |
| 128 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS() | |
| 129 : 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.
| |
| 130 } | |
| 131 | |
| 132 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { | |
| 133 } | |
|
armansito
2014/12/09 00:30:28
Move the declarations of ctor/dtor before all the
Miao
2014/12/10 04:07:19
Done.
| |
| 134 | |
| 135 } // namespace chromeos | |
| OLD | NEW |