Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h" | 5 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <string> | |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/debug/stack_trace.h" | 12 #include "base/debug/stack_trace.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
| 14 #include "dbus/message.h" | 15 #include "dbus/message.h" |
| 15 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 16 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
| 16 | 17 |
| 17 using dbus::ObjectPath; | 18 using dbus::ObjectPath; |
| 18 using device::BluetoothAudioSink; | 19 using device::BluetoothAudioSink; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // TODO(mcchou): Add the constant to dbus/service_constants.h. | 23 // TODO(mcchou): Add the constant to dbus/service_constants.h. |
| 23 const char kBluetoothAudioSinkServicePath[] = "/org/chromium/AudioSink"; | 24 const char kBluetoothAudioSinkServicePath[] = "/org/chromium/AudioSink"; |
| 24 | 25 |
| 26 // Used in VLOG. Translates a BluetoothAudioSink::State to verbose description. | |
| 27 const std::vector<std::string> kState = { | |
| 28 "invalid", "disconnected", "idle", "pending", "active"}; | |
| 29 const std::vector<std::string> kErrorCode = {"unsupported platform", | |
| 30 "invalid adapter", | |
| 31 "not registered", | |
| 32 "not unregistered"}; | |
|
armansito
2015/02/28 00:50:28
Define helper functions that do the string convers
Ben Chan
2015/02/28 01:09:22
Don't define global constants of non-POD types (ht
Miao
2015/02/28 02:19:32
Done.
| |
| 33 | |
| 25 ObjectPath GenerateEndpointPath() { | 34 ObjectPath GenerateEndpointPath() { |
| 26 static unsigned int sequence_number = 0; | 35 static unsigned int sequence_number = 0; |
| 27 ++sequence_number; | 36 ++sequence_number; |
| 28 std::stringstream path; | 37 std::stringstream path; |
| 29 path << kBluetoothAudioSinkServicePath << "/endpoint" << sequence_number; | 38 path << kBluetoothAudioSinkServicePath << "/endpoint" << sequence_number; |
| 30 return ObjectPath(path.str()); | 39 return ObjectPath(path.str()); |
| 31 } | 40 } |
| 32 | 41 |
| 33 // A dummy error callback for calling Unregister() in destructor. | 42 // A dummy error callback for calling Unregister() in destructor. |
| 34 void UnregisterErrorCallback( | 43 void UnregisterErrorCallback( |
| 35 device::BluetoothAudioSink::ErrorCode error_code) { | 44 device::BluetoothAudioSink::ErrorCode error_code) { |
| 36 VLOG(1) << "Bluetooth audio sink: Error code: " << error_code; | 45 VLOG(1) << "Bluetooth audio sink: Error code: " << kErrorCode[error_code] |
|
armansito
2015/02/28 00:50:28
Should this be "UnregisterErrorCallback - Error co
Miao
2015/02/28 02:19:32
Done.
| |
| 46 << "(" << error_code << ")"; | |
| 37 } | 47 } |
| 38 | 48 |
| 39 } // namespace | 49 } // namespace |
| 40 | 50 |
| 41 namespace chromeos { | 51 namespace chromeos { |
| 42 | 52 |
| 43 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( | 53 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( |
| 44 scoped_refptr<device::BluetoothAdapter> adapter) | 54 scoped_refptr<device::BluetoothAdapter> adapter) |
| 45 : state_(BluetoothAudioSink::STATE_INVALID), | 55 : state_(BluetoothAudioSink::STATE_INVALID), |
| 46 volume_(BluetoothAudioSink::kInvalidVolume), | 56 volume_(BluetoothAudioSink::kInvalidVolume), |
| 47 read_mtu_(nullptr), | 57 read_mtu_(nullptr), |
| 48 write_mtu_(nullptr), | 58 write_mtu_(nullptr), |
| 49 adapter_(adapter), | 59 adapter_(adapter), |
| 50 weak_ptr_factory_(this) { | 60 weak_ptr_factory_(this) { |
| 61 VLOG(1) << "Bluetooth audio sink created"; | |
| 62 | |
| 51 DCHECK(adapter_.get()); | 63 DCHECK(adapter_.get()); |
| 52 DCHECK(adapter_->IsPresent()); | 64 DCHECK(adapter_->IsPresent()); |
| 53 | 65 |
| 54 adapter_->AddObserver(this); | 66 adapter_->AddObserver(this); |
| 55 | 67 |
| 56 chromeos::BluetoothMediaClient* media = | 68 chromeos::BluetoothMediaClient* media = |
| 57 DBusThreadManager::Get()->GetBluetoothMediaClient(); | 69 DBusThreadManager::Get()->GetBluetoothMediaClient(); |
| 58 DCHECK(media); | 70 DCHECK(media); |
| 59 media->AddObserver(this); | 71 media->AddObserver(this); |
| 60 | 72 |
| 61 chromeos::BluetoothMediaTransportClient *transport = | 73 chromeos::BluetoothMediaTransportClient *transport = |
| 62 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); | 74 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); |
| 63 DCHECK(transport); | 75 DCHECK(transport); |
| 64 transport->AddObserver(this); | 76 transport->AddObserver(this); |
| 65 | 77 |
| 66 StateChanged(device::BluetoothAudioSink::STATE_DISCONNECTED); | 78 StateChanged(device::BluetoothAudioSink::STATE_DISCONNECTED); |
| 67 } | 79 } |
| 68 | 80 |
| 69 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { | 81 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { |
| 82 VLOG(1) << "Bluetooth audio sink destroyed"; | |
| 83 | |
| 70 DCHECK(adapter_.get()); | 84 DCHECK(adapter_.get()); |
| 71 | 85 |
| 72 if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) { | 86 if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) { |
| 73 Unregister(base::Bind(&base::DoNothing), | 87 Unregister(base::Bind(&base::DoNothing), |
| 74 base::Bind(&UnregisterErrorCallback)); | 88 base::Bind(&UnregisterErrorCallback)); |
| 75 } | 89 } |
| 76 | 90 |
| 77 adapter_->RemoveObserver(this); | 91 adapter_->RemoveObserver(this); |
| 78 | 92 |
| 79 chromeos::BluetoothMediaClient* media = | 93 chromeos::BluetoothMediaClient* media = |
| 80 DBusThreadManager::Get()->GetBluetoothMediaClient(); | 94 DBusThreadManager::Get()->GetBluetoothMediaClient(); |
| 81 DCHECK(media); | 95 DCHECK(media); |
| 82 media->RemoveObserver(this); | 96 media->RemoveObserver(this); |
| 83 | 97 |
| 84 chromeos::BluetoothMediaTransportClient *transport = | 98 chromeos::BluetoothMediaTransportClient *transport = |
| 85 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); | 99 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); |
| 86 DCHECK(transport); | 100 DCHECK(transport); |
| 87 transport->RemoveObserver(this); | 101 transport->RemoveObserver(this); |
| 88 } | 102 } |
| 89 | 103 |
| 90 void BluetoothAudioSinkChromeOS::Unregister( | 104 void BluetoothAudioSinkChromeOS::Unregister( |
| 91 const base::Closure& callback, | 105 const base::Closure& callback, |
| 92 const device::BluetoothAudioSink::ErrorCallback& error_callback) { | 106 const device::BluetoothAudioSink::ErrorCallback& error_callback) { |
| 107 VLOG(1) << "Bluetooth audio sink: Unregister called"; | |
| 108 | |
| 93 if (!DBusThreadManager::IsInitialized()) | 109 if (!DBusThreadManager::IsInitialized()) |
| 94 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); | 110 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); |
| 95 | 111 |
| 96 chromeos::BluetoothMediaClient* media = | 112 chromeos::BluetoothMediaClient* media = |
| 97 DBusThreadManager::Get()->GetBluetoothMediaClient(); | 113 DBusThreadManager::Get()->GetBluetoothMediaClient(); |
| 98 DCHECK(media); | 114 DCHECK(media); |
| 99 | 115 |
| 100 media->UnregisterEndpoint( | 116 media->UnregisterEndpoint( |
| 101 media_path_, | 117 media_path_, |
| 102 endpoint_path_, | 118 endpoint_path_, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 // Regardless of the new powered state, |state_| goes to STATE_DISCONNECTED. | 163 // Regardless of the new powered state, |state_| goes to STATE_DISCONNECTED. |
| 148 // If false, the transport is closed, but the endpoint is still valid for use. | 164 // If false, the transport is closed, but the endpoint is still valid for use. |
| 149 // If true, the previous transport has been torn down, so the |state_| has to | 165 // If true, the previous transport has been torn down, so the |state_| has to |
| 150 // be disconnected before SetConfigruation is called. | 166 // be disconnected before SetConfigruation is called. |
| 151 if (state_ != BluetoothAudioSink::STATE_INVALID) | 167 if (state_ != BluetoothAudioSink::STATE_INVALID) |
| 152 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); | 168 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); |
| 153 } | 169 } |
| 154 | 170 |
| 155 void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { | 171 void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { |
| 156 if (object_path == media_path_) { | 172 if (object_path == media_path_) { |
| 173 VLOG(1) << "Bluetooth audio sink: media removed: " | |
| 174 << object_path.value(); | |
| 157 StateChanged(BluetoothAudioSink::STATE_INVALID); | 175 StateChanged(BluetoothAudioSink::STATE_INVALID); |
| 158 } | 176 } |
| 159 } | 177 } |
| 160 | 178 |
| 161 void BluetoothAudioSinkChromeOS::MediaTransportRemoved( | 179 void BluetoothAudioSinkChromeOS::MediaTransportRemoved( |
| 162 const ObjectPath& object_path) { | 180 const ObjectPath& object_path) { |
| 163 // Whenever powered of |adapter_| turns false while present stays true, media | 181 // Whenever powered of |adapter_| turns false while present stays true, media |
| 164 // transport object should be removed accordingly, and the state should be | 182 // transport object should be removed accordingly, and the state should be |
| 165 // changed to STATE_DISCONNECTED. | 183 // changed to STATE_DISCONNECTED. |
| 166 if (object_path == transport_path_) { | 184 if (object_path == transport_path_) { |
| 185 VLOG(1) << "Bluetooth audio sink: media transport removed: " | |
|
armansito
2015/02/28 00:50:28
"Bluetooth audio sink - media transport removed: "
Miao
2015/02/28 02:19:33
Done.
| |
| 186 << object_path.value(); | |
| 167 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); | 187 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); |
| 168 } | 188 } |
| 169 } | 189 } |
| 170 | 190 |
| 171 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( | 191 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( |
| 172 const ObjectPath& object_path, | 192 const ObjectPath& object_path, |
| 173 const std::string& property_name) { | 193 const std::string& property_name) { |
| 174 if (object_path != transport_path_) | 194 if (object_path != transport_path_) |
| 175 return; | 195 return; |
| 176 | 196 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 201 } | 221 } |
| 202 | 222 |
| 203 void BluetoothAudioSinkChromeOS::SetConfiguration( | 223 void BluetoothAudioSinkChromeOS::SetConfiguration( |
| 204 const ObjectPath& transport_path, | 224 const ObjectPath& transport_path, |
| 205 const TransportProperties& properties) { | 225 const TransportProperties& properties) { |
| 206 VLOG(1) << "Bluetooth audio sink: SetConfiguration called"; | 226 VLOG(1) << "Bluetooth audio sink: SetConfiguration called"; |
| 207 transport_path_ = transport_path; | 227 transport_path_ = transport_path; |
| 208 | 228 |
| 209 // The initial state for a connection should be "idle". | 229 // The initial state for a connection should be "idle". |
| 210 if (properties.state != BluetoothMediaTransportClient::kStateIdle) { | 230 if (properties.state != BluetoothMediaTransportClient::kStateIdle) { |
| 211 VLOG(1) << "Bluetooth Audio Sink: unexpected state " << properties.state; | 231 VLOG(1) << "Bluetooth audio sink: unexpected state " << properties.state; |
| 212 return; | 232 return; |
| 213 } | 233 } |
| 214 | 234 |
| 215 // Updates |volume_| if the volume level is provided in |properties|. | 235 // Updates |volume_| if the volume level is provided in |properties|. |
| 216 if (properties.volume.get()) { | 236 if (properties.volume.get()) { |
| 217 VolumeChanged(*properties.volume); | 237 VolumeChanged(*properties.volume); |
| 218 } | 238 } |
| 219 | 239 |
| 220 StateChanged(BluetoothAudioSink::STATE_IDLE); | 240 StateChanged(BluetoothAudioSink::STATE_IDLE); |
| 221 } | 241 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 237 | 257 |
| 238 void BluetoothAudioSinkChromeOS::Released() { | 258 void BluetoothAudioSinkChromeOS::Released() { |
| 239 VLOG(1) << "Bluetooth audio sink: Released called"; | 259 VLOG(1) << "Bluetooth audio sink: Released called"; |
| 240 StateChanged(BluetoothAudioSink::STATE_INVALID); | 260 StateChanged(BluetoothAudioSink::STATE_INVALID); |
| 241 } | 261 } |
| 242 | 262 |
| 243 void BluetoothAudioSinkChromeOS::Register( | 263 void BluetoothAudioSinkChromeOS::Register( |
| 244 const BluetoothAudioSink::Options& options, | 264 const BluetoothAudioSink::Options& options, |
| 245 const base::Closure& callback, | 265 const base::Closure& callback, |
| 246 const BluetoothAudioSink::ErrorCallback& error_callback) { | 266 const BluetoothAudioSink::ErrorCallback& error_callback) { |
| 267 VLOG(1) << "Bluetooth audio sink: Register called"; | |
| 268 | |
| 247 DCHECK(adapter_.get()); | 269 DCHECK(adapter_.get()); |
| 248 DCHECK_EQ(state_, BluetoothAudioSink::STATE_DISCONNECTED); | 270 DCHECK_EQ(state_, BluetoothAudioSink::STATE_DISCONNECTED); |
| 249 | 271 |
| 250 // Gets system bus. | 272 // Gets system bus. |
| 251 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); | 273 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); |
| 252 | 274 |
| 253 // Creates a Media Endpoint with newly-generated path. | 275 // Creates a Media Endpoint with newly-generated path. |
| 254 endpoint_path_ = GenerateEndpointPath(); | 276 endpoint_path_ = GenerateEndpointPath(); |
| 255 media_endpoint_.reset( | 277 media_endpoint_.reset( |
| 256 BluetoothMediaEndpointServiceProvider::Create( | 278 BluetoothMediaEndpointServiceProvider::Create( |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 284 BluetoothMediaEndpointServiceProvider* | 306 BluetoothMediaEndpointServiceProvider* |
| 285 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { | 307 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { |
| 286 return media_endpoint_.get(); | 308 return media_endpoint_.get(); |
| 287 } | 309 } |
| 288 | 310 |
| 289 void BluetoothAudioSinkChromeOS::StateChanged( | 311 void BluetoothAudioSinkChromeOS::StateChanged( |
| 290 BluetoothAudioSink::State state) { | 312 BluetoothAudioSink::State state) { |
| 291 if (state == state_) | 313 if (state == state_) |
| 292 return; | 314 return; |
| 293 | 315 |
| 294 VLOG(1) << "Bluetooth audio sink state changed: " << state; | 316 VLOG(1) << "Bluetooth audio sink state changed: " << kState[state]; |
| 317 | |
| 295 switch (state) { | 318 switch (state) { |
| 296 case BluetoothAudioSink::STATE_INVALID: | 319 case BluetoothAudioSink::STATE_INVALID: |
| 297 ResetMedia(); | 320 ResetMedia(); |
| 298 ResetEndpoint(); | 321 ResetEndpoint(); |
| 299 case BluetoothAudioSink::STATE_DISCONNECTED: | 322 case BluetoothAudioSink::STATE_DISCONNECTED: |
| 300 ResetTransport(); | 323 ResetTransport(); |
| 301 break; | 324 break; |
| 302 case BluetoothAudioSink::STATE_IDLE: | 325 case BluetoothAudioSink::STATE_IDLE: |
| 303 // TODO(mcchou): BUG=441581 | 326 // TODO(mcchou): BUG=441581 |
| 304 // Triggered by MediaTransportPropertyChanged and SetConfiguration. | 327 // Triggered by MediaTransportPropertyChanged and SetConfiguration. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 320 state_ = state; | 343 state_ = state; |
| 321 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, | 344 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, |
| 322 BluetoothAudioSinkStateChanged(this, state_)); | 345 BluetoothAudioSinkStateChanged(this, state_)); |
| 323 } | 346 } |
| 324 | 347 |
| 325 void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { | 348 void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { |
| 326 if (volume == volume_) | 349 if (volume == volume_) |
| 327 return; | 350 return; |
| 328 | 351 |
| 329 VLOG(1) << "Bluetooth audio sink volume changed: " << volume; | 352 VLOG(1) << "Bluetooth audio sink volume changed: " << volume; |
| 353 | |
| 330 volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume); | 354 volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume); |
| 331 | |
| 332 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, | 355 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, |
| 333 BluetoothAudioSinkVolumeChanged(this, volume_)); | 356 BluetoothAudioSinkVolumeChanged(this, volume_)); |
| 334 } | 357 } |
| 335 | 358 |
| 336 void BluetoothAudioSinkChromeOS::OnRegisterSucceeded( | 359 void BluetoothAudioSinkChromeOS::OnRegisterSucceeded( |
| 337 const base::Closure& callback) { | 360 const base::Closure& callback) { |
| 338 DCHECK(media_endpoint_.get()); | 361 DCHECK(media_endpoint_.get()); |
| 339 VLOG(1) << "Bluetooth audio sink registerd"; | 362 VLOG(1) << "Bluetooth audio sink registerd"; |
| 340 | 363 |
| 341 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); | 364 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); |
| 342 callback.Run(); | 365 callback.Run(); |
| 343 } | 366 } |
| 344 | 367 |
| 345 void BluetoothAudioSinkChromeOS::OnRegisterFailed( | 368 void BluetoothAudioSinkChromeOS::OnRegisterFailed( |
| 346 const BluetoothAudioSink::ErrorCallback& error_callback, | 369 const BluetoothAudioSink::ErrorCallback& error_callback, |
| 347 const std::string& error_name, | 370 const std::string& error_name, |
| 348 const std::string& error_message) { | 371 const std::string& error_message) { |
| 349 VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; | 372 VLOG(1) << "Bluetooth audio sink: error " << error_name << ": " |
| 373 << error_message; | |
| 350 | 374 |
| 351 ResetEndpoint(); | 375 ResetEndpoint(); |
| 352 error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED); | 376 error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED); |
| 353 } | 377 } |
| 354 | 378 |
| 355 void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded( | 379 void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded( |
| 356 const base::Closure& callback) { | 380 const base::Closure& callback) { |
| 357 VLOG(1) << "Bluetooth audio sink unregisterd"; | 381 VLOG(1) << "Bluetooth audio sink unregisterd"; |
| 358 | 382 |
| 359 // Once the state becomes STATE_INVALID, media, media transport and media | 383 // Once the state becomes STATE_INVALID, media, media transport and media |
| 360 // endpoint will be reset. | 384 // endpoint will be reset. |
| 361 StateChanged(BluetoothAudioSink::STATE_INVALID); | 385 StateChanged(BluetoothAudioSink::STATE_INVALID); |
| 362 callback.Run(); | 386 callback.Run(); |
| 363 } | 387 } |
| 364 | 388 |
| 365 void BluetoothAudioSinkChromeOS::OnUnregisterFailed( | 389 void BluetoothAudioSinkChromeOS::OnUnregisterFailed( |
| 366 const device::BluetoothAudioSink::ErrorCallback& error_callback, | 390 const device::BluetoothAudioSink::ErrorCallback& error_callback, |
| 367 const std::string& error_name, | 391 const std::string& error_name, |
| 368 const std::string& error_message) { | 392 const std::string& error_message) { |
| 369 VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; | 393 VLOG(1) << "Bluetooth audio sink: error " << error_name << ": " |
|
armansito
2015/02/28 00:50:28
"UnregisterError - error_name: " << error_name <<
Miao
2015/02/28 02:19:33
Done.
| |
| 394 << error_message; | |
| 395 | |
| 370 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); | 396 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); |
| 371 } | 397 } |
| 372 | 398 |
| 373 void BluetoothAudioSinkChromeOS::ReadFromFD() { | 399 void BluetoothAudioSinkChromeOS::ReadFromFD() { |
| 374 DCHECK_GE(fd_.value(), 0); | 400 DCHECK_GE(fd_.value(), 0); |
| 375 | 401 |
| 376 // TODO(mcchou): BUG=441581 | 402 // TODO(mcchou): BUG=441581 |
| 377 // Read from file descriptor using watcher and create a buffer to contain the | 403 // Read from file descriptor using watcher and create a buffer to contain the |
| 378 // data. Notify |Observers_| while there is audio data available. | 404 // data. Notify |Observers_| while there is audio data available. |
| 379 } | 405 } |
| 380 | 406 |
| 381 void BluetoothAudioSinkChromeOS::ResetMedia() { | 407 void BluetoothAudioSinkChromeOS::ResetMedia() { |
| 408 VLOG(1) << "Bluetooth audio sink: ResetMedia"; | |
| 409 | |
| 382 media_path_ = dbus::ObjectPath(""); | 410 media_path_ = dbus::ObjectPath(""); |
| 383 } | 411 } |
| 384 | 412 |
| 385 void BluetoothAudioSinkChromeOS::ResetTransport() { | 413 void BluetoothAudioSinkChromeOS::ResetTransport() { |
| 414 VLOG(1) << "Bluetooth audio sink: ResetTransport"; | |
| 415 | |
| 386 if (transport_path_.value() == "") | 416 if (transport_path_.value() == "") |
| 387 return; | 417 return; |
| 388 transport_path_ = dbus::ObjectPath(""); | 418 transport_path_ = dbus::ObjectPath(""); |
| 389 VolumeChanged(BluetoothAudioSink::kInvalidVolume); | 419 VolumeChanged(BluetoothAudioSink::kInvalidVolume); |
| 390 read_mtu_ = 0; | 420 read_mtu_ = 0; |
| 391 write_mtu_ = 0; | 421 write_mtu_ = 0; |
| 392 fd_.PutValue(-1); | 422 fd_.PutValue(-1); |
| 393 } | 423 } |
| 394 | 424 |
| 395 void BluetoothAudioSinkChromeOS::ResetEndpoint() { | 425 void BluetoothAudioSinkChromeOS::ResetEndpoint() { |
| 426 VLOG(1) << "Bluetooth audio sink: ResetEndpoint"; | |
| 427 | |
| 396 endpoint_path_ = ObjectPath(""); | 428 endpoint_path_ = ObjectPath(""); |
| 397 media_endpoint_ = nullptr; | 429 media_endpoint_ = nullptr; |
| 398 } | 430 } |
| 399 | 431 |
| 400 } // namespace chromeos | 432 } // namespace chromeos |
| OLD | NEW |