Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: device/bluetooth/bluetooth_audio_sink_chromeos.cc

Issue 993273002: device/bluetooth: Add I/O watcher for audio data retrieval triggered by state change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <unistd.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 #include <sstream> 10 #include <sstream>
9 #include <string> 11 #include <string>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/debug/stack_trace.h" 14 #include "base/debug/stack_trace.h"
15 #include "base/files/file_util.h"
13 #include "base/logging.h" 16 #include "base/logging.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 17 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "dbus/message.h" 18 #include "dbus/message.h"
16 #include "device/bluetooth/bluetooth_adapter_chromeos.h" 19 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
17 20
18 using dbus::ObjectPath; 21 using dbus::ObjectPath;
19 using device::BluetoothAudioSink; 22 using device::BluetoothAudioSink;
20 23
21 namespace { 24 namespace {
22 25
23 // TODO(mcchou): Add the constant to dbus/service_constants.h. 26 // TODO(mcchou): Add the constant to dbus/service_constants.h.
24 const char kBluetoothAudioSinkServicePath[] = "/org/chromium/AudioSink"; 27 const char kBluetoothAudioSinkServicePath[] = "/org/chromium/AudioSink";
25 28
29 const int kInvalidFd = -1;
30 const uint16_t kInvalidReadMtu = 0;
31 const uint16_t kInvalidWriteMtu = 0;
32
26 ObjectPath GenerateEndpointPath() { 33 ObjectPath GenerateEndpointPath() {
27 static unsigned int sequence_number = 0; 34 static unsigned int sequence_number = 0;
28 ++sequence_number; 35 ++sequence_number;
29 std::stringstream path; 36 std::stringstream path;
30 path << kBluetoothAudioSinkServicePath << "/endpoint" << sequence_number; 37 path << kBluetoothAudioSinkServicePath << "/endpoint" << sequence_number;
31 return ObjectPath(path.str()); 38 return ObjectPath(path.str());
32 } 39 }
33 40
34 std::string StateToString(const BluetoothAudioSink::State& state) { 41 std::string StateToString(const BluetoothAudioSink::State& state) {
35 switch (state) { 42 switch (state) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 78 }
72 79
73 } // namespace 80 } // namespace
74 81
75 namespace chromeos { 82 namespace chromeos {
76 83
77 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( 84 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS(
78 scoped_refptr<device::BluetoothAdapter> adapter) 85 scoped_refptr<device::BluetoothAdapter> adapter)
79 : state_(BluetoothAudioSink::STATE_INVALID), 86 : state_(BluetoothAudioSink::STATE_INVALID),
80 volume_(BluetoothAudioSink::kInvalidVolume), 87 volume_(BluetoothAudioSink::kInvalidVolume),
81 read_mtu_(nullptr), 88 read_mtu_(kInvalidReadMtu),
82 write_mtu_(nullptr), 89 write_mtu_(kInvalidWriteMtu),
90 read_failed_logged_(false),
83 adapter_(adapter), 91 adapter_(adapter),
84 weak_ptr_factory_(this) { 92 weak_ptr_factory_(this) {
85 VLOG(1) << "BluetoothAudioSinkChromeOS created"; 93 VLOG(1) << "BluetoothAudioSinkChromeOS created";
86 94
87 DCHECK(adapter_.get()); 95 DCHECK(adapter_.get());
88 DCHECK(adapter_->IsPresent()); 96 DCHECK(adapter_->IsPresent());
97 DCHECK(DBusThreadManager::IsInitialized());
89 98
90 adapter_->AddObserver(this); 99 adapter_->AddObserver(this);
91 100
92 chromeos::BluetoothMediaClient* media = 101 BluetoothMediaClient* media =
93 DBusThreadManager::Get()->GetBluetoothMediaClient(); 102 DBusThreadManager::Get()->GetBluetoothMediaClient();
94 DCHECK(media); 103 DCHECK(media);
95 media->AddObserver(this); 104 media->AddObserver(this);
96 105
97 chromeos::BluetoothMediaTransportClient *transport = 106 BluetoothMediaTransportClient* transport =
98 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); 107 DBusThreadManager::Get()->GetBluetoothMediaTransportClient();
99 DCHECK(transport); 108 DCHECK(transport);
100 transport->AddObserver(this); 109 transport->AddObserver(this);
101 110
102 StateChanged(device::BluetoothAudioSink::STATE_DISCONNECTED); 111 StateChanged(device::BluetoothAudioSink::STATE_DISCONNECTED);
103 } 112 }
104 113
105 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { 114 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() {
106 VLOG(1) << "BluetoothAudioSinkChromeOS destroyed"; 115 VLOG(1) << "BluetoothAudioSinkChromeOS destroyed";
107 116
108 DCHECK(adapter_.get()); 117 DCHECK(adapter_.get());
109 118
110 if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) { 119 if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) {
111 Unregister(base::Bind(&base::DoNothing), 120 Unregister(base::Bind(&base::DoNothing),
112 base::Bind(&UnregisterErrorCallback)); 121 base::Bind(&UnregisterErrorCallback));
113 } 122 }
114 123
115 adapter_->RemoveObserver(this); 124 adapter_->RemoveObserver(this);
116 125
117 chromeos::BluetoothMediaClient* media = 126 BluetoothMediaClient* media =
118 DBusThreadManager::Get()->GetBluetoothMediaClient(); 127 DBusThreadManager::Get()->GetBluetoothMediaClient();
119 DCHECK(media); 128 DCHECK(media);
120 media->RemoveObserver(this); 129 media->RemoveObserver(this);
121 130
122 chromeos::BluetoothMediaTransportClient *transport = 131 BluetoothMediaTransportClient* transport =
123 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); 132 DBusThreadManager::Get()->GetBluetoothMediaTransportClient();
124 DCHECK(transport); 133 DCHECK(transport);
125 transport->RemoveObserver(this); 134 transport->RemoveObserver(this);
126 } 135 }
127 136
128 void BluetoothAudioSinkChromeOS::Unregister( 137 void BluetoothAudioSinkChromeOS::Unregister(
129 const base::Closure& callback, 138 const base::Closure& callback,
130 const device::BluetoothAudioSink::ErrorCallback& error_callback) { 139 const device::BluetoothAudioSink::ErrorCallback& error_callback) {
131 VLOG(1) << "Unregister"; 140 VLOG(1) << "Unregister";
132 141
133 if (!DBusThreadManager::IsInitialized()) 142 if (!DBusThreadManager::IsInitialized())
134 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); 143 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED);
135 144
136 chromeos::BluetoothMediaClient* media = 145 BluetoothMediaClient* media =
137 DBusThreadManager::Get()->GetBluetoothMediaClient(); 146 DBusThreadManager::Get()->GetBluetoothMediaClient();
138 DCHECK(media); 147 DCHECK(media);
139 148
140 media->UnregisterEndpoint( 149 media->UnregisterEndpoint(
141 media_path_, 150 media_path_,
142 endpoint_path_, 151 endpoint_path_,
143 base::Bind(&BluetoothAudioSinkChromeOS::OnUnregisterSucceeded, 152 base::Bind(&BluetoothAudioSinkChromeOS::OnUnregisterSucceeded,
144 weak_ptr_factory_.GetWeakPtr(), callback), 153 weak_ptr_factory_.GetWeakPtr(), callback),
145 base::Bind(&BluetoothAudioSinkChromeOS::OnUnregisterFailed, 154 base::Bind(&BluetoothAudioSinkChromeOS::OnUnregisterFailed,
146 weak_ptr_factory_.GetWeakPtr(), error_callback)); 155 weak_ptr_factory_.GetWeakPtr(), error_callback));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 219
211 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( 220 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged(
212 const ObjectPath& object_path, 221 const ObjectPath& object_path,
213 const std::string& property_name) { 222 const std::string& property_name) {
214 if (object_path != transport_path_) 223 if (object_path != transport_path_)
215 return; 224 return;
216 225
217 VLOG(1) << "MediaTransportPropertyChanged: " << property_name; 226 VLOG(1) << "MediaTransportPropertyChanged: " << property_name;
218 227
219 // Retrieves the property set of the transport object with |object_path|. 228 // Retrieves the property set of the transport object with |object_path|.
220 chromeos::BluetoothMediaTransportClient::Properties* properties = 229 BluetoothMediaTransportClient::Properties* properties =
221 DBusThreadManager::Get() 230 DBusThreadManager::Get()
222 ->GetBluetoothMediaTransportClient() 231 ->GetBluetoothMediaTransportClient()
223 ->GetProperties(object_path); 232 ->GetProperties(object_path);
224 233
225 // Dispatches a property changed event to the corresponding handler. 234 // Dispatches a property changed event to the corresponding handler.
226 if (property_name == properties->state.name()) { 235 if (property_name == properties->state.name()) {
227 if (properties->state.value() == 236 if (properties->state.value() ==
228 BluetoothMediaTransportClient::kStateIdle) { 237 BluetoothMediaTransportClient::kStateIdle) {
229 StateChanged(BluetoothAudioSink::STATE_IDLE); 238 StateChanged(BluetoothAudioSink::STATE_IDLE);
230 } else if (properties->state.value() == 239 } else if (properties->state.value() ==
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 const std::vector<uint8_t>& capabilities, 272 const std::vector<uint8_t>& capabilities,
264 const SelectConfigurationCallback& callback) { 273 const SelectConfigurationCallback& callback) {
265 VLOG(1) << "SelectConfiguration"; 274 VLOG(1) << "SelectConfiguration";
266 callback.Run(options_.capabilities); 275 callback.Run(options_.capabilities);
267 } 276 }
268 277
269 void BluetoothAudioSinkChromeOS::ClearConfiguration( 278 void BluetoothAudioSinkChromeOS::ClearConfiguration(
270 const ObjectPath& transport_path) { 279 const ObjectPath& transport_path) {
271 if (transport_path != transport_path_) 280 if (transport_path != transport_path_)
272 return; 281 return;
282
273 VLOG(1) << "ClearConfiguration"; 283 VLOG(1) << "ClearConfiguration";
274 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); 284 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED);
275 } 285 }
276 286
277 void BluetoothAudioSinkChromeOS::Released() { 287 void BluetoothAudioSinkChromeOS::Released() {
278 VLOG(1) << "Released"; 288 VLOG(1) << "Released";
279 StateChanged(BluetoothAudioSink::STATE_INVALID); 289 StateChanged(BluetoothAudioSink::STATE_INVALID);
280 } 290 }
281 291
282 void BluetoothAudioSinkChromeOS::Register( 292 void BluetoothAudioSinkChromeOS::Register(
(...skipping 19 matching lines...) Expand all
302 // Creates endpoint properties with |options|. 312 // Creates endpoint properties with |options|.
303 options_ = options; 313 options_ = options;
304 chromeos::BluetoothMediaClient::EndpointProperties endpoint_properties; 314 chromeos::BluetoothMediaClient::EndpointProperties endpoint_properties;
305 endpoint_properties.uuid = BluetoothMediaClient::kBluetoothAudioSinkUUID; 315 endpoint_properties.uuid = BluetoothMediaClient::kBluetoothAudioSinkUUID;
306 endpoint_properties.codec = options_.codec; 316 endpoint_properties.codec = options_.codec;
307 endpoint_properties.capabilities = options_.capabilities; 317 endpoint_properties.capabilities = options_.capabilities;
308 318
309 media_path_ = static_cast<BluetoothAdapterChromeOS*>( 319 media_path_ = static_cast<BluetoothAdapterChromeOS*>(
310 adapter_.get())->object_path(); 320 adapter_.get())->object_path();
311 321
312 chromeos::BluetoothMediaClient* media = 322 BluetoothMediaClient* media =
313 DBusThreadManager::Get()->GetBluetoothMediaClient(); 323 DBusThreadManager::Get()->GetBluetoothMediaClient();
314 DCHECK(media); 324 DCHECK(media);
315 media->RegisterEndpoint( 325 media->RegisterEndpoint(
316 media_path_, 326 media_path_,
317 endpoint_path_, 327 endpoint_path_,
318 endpoint_properties, 328 endpoint_properties,
319 base::Bind(&BluetoothAudioSinkChromeOS::OnRegisterSucceeded, 329 base::Bind(&BluetoothAudioSinkChromeOS::OnRegisterSucceeded,
320 weak_ptr_factory_.GetWeakPtr(), callback), 330 weak_ptr_factory_.GetWeakPtr(), callback),
321 base::Bind(&BluetoothAudioSinkChromeOS::OnRegisterFailed, 331 base::Bind(&BluetoothAudioSinkChromeOS::OnRegisterFailed,
322 weak_ptr_factory_.GetWeakPtr(), error_callback)); 332 weak_ptr_factory_.GetWeakPtr(), error_callback));
323 } 333 }
324 334
335 void BluetoothAudioSinkChromeOS::OnFileCanReadWithoutBlocking(int fd) {
336 ReadFromFile();
337 }
338
339 void BluetoothAudioSinkChromeOS::OnFileCanWriteWithoutBlocking(int fd) {
340 // Do nothing for now.
341 }
342
325 BluetoothMediaEndpointServiceProvider* 343 BluetoothMediaEndpointServiceProvider*
326 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { 344 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() {
327 return media_endpoint_.get(); 345 return media_endpoint_.get();
328 } 346 }
329 347
348 void BluetoothAudioSinkChromeOS::AcquireFD() {
349 VLOG(1) << "AcquireFD - transport path: " << transport_path_.value();
350
351 read_failed_logged_ = false;
armansito 2015/03/12 03:42:55 I would rename this variable to something like |re
Miao 2015/03/12 22:33:32 Done.
352
353 DBusThreadManager::Get()->GetBluetoothMediaTransportClient()->Acquire(
354 transport_path_,
355 base::Bind(&BluetoothAudioSinkChromeOS::OnAcquireSucceeded,
356 weak_ptr_factory_.GetWeakPtr()),
357 base::Bind(&BluetoothAudioSinkChromeOS::OnAcquireFailed,
358 weak_ptr_factory_.GetWeakPtr()));
359 }
360
361 void BluetoothAudioSinkChromeOS::WatchFD() {
362 DCHECK(file_.get() && file_->IsValid());
363
364 VLOG(1) << "WatchFD - file: " << file_->GetPlatformFile()
365 << ", file validity: " << file_->IsValid();
366
367 base::MessageLoopForIO::current()->WatchFileDescriptor(
368 file_->GetPlatformFile(), true, base::MessageLoopForIO::WATCH_READ,
369 &fd_read_watcher_, this);
370 }
371
372 void BluetoothAudioSinkChromeOS::StopWatchingFD() {
373 if (!file_.get()) {
374 VLOG(1) << "StopWatchingFD - skip";
375 return;
376 }
377
378 bool stopped = fd_read_watcher_.StopWatchingFileDescriptor();
379 VLOG(1) << "StopWatchingFD - watch stopped: " << stopped;
380 CHECK(stopped);
381
382 read_mtu_ = kInvalidReadMtu;
383 write_mtu_ = kInvalidWriteMtu;
384 file_.reset();
armansito 2015/03/12 03:42:55 Add a comment here saying that this will close the
Miao 2015/03/12 22:33:32 Done.
385 }
386
387 void BluetoothAudioSinkChromeOS::ReadFromFile() {
388 DCHECK(file_.get() && file_->IsValid());
389 DCHECK(data_.get());
390
391 int size = file_->ReadAtCurrentPosNoBestEffort(data_.get(), read_mtu_);
392
393 if (size == -1) {
394 // To reduce the number of logs, log only once for multiple failures.
395 if (!read_failed_logged_) {
396 VLOG(1) << "ReadFromFile - failed";
397 read_failed_logged_ = true;
398 }
399 return;
400 }
401
402 VLOG(1) << "ReadFromFile - read " << size << " bytes";
403 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_,
404 BluetoothAudioSinkDataAvailable(this, data_.get(), size));
405 }
406
330 void BluetoothAudioSinkChromeOS::StateChanged( 407 void BluetoothAudioSinkChromeOS::StateChanged(
331 BluetoothAudioSink::State state) { 408 BluetoothAudioSink::State state) {
332 if (state == state_) 409 if (state == state_)
333 return; 410 return;
334 411
335 VLOG(1) << "StateChnaged: " << StateToString(state); 412 VLOG(1) << "StateChanged - state: " << StateToString(state);
336 413
337 switch (state) { 414 switch (state) {
338 case BluetoothAudioSink::STATE_INVALID: 415 case BluetoothAudioSink::STATE_INVALID:
339 ResetMedia(); 416 ResetMedia();
340 ResetEndpoint(); 417 ResetEndpoint();
341 case BluetoothAudioSink::STATE_DISCONNECTED: 418 case BluetoothAudioSink::STATE_DISCONNECTED:
342 ResetTransport(); 419 ResetTransport();
343 break; 420 break;
344 case BluetoothAudioSink::STATE_IDLE: 421 case BluetoothAudioSink::STATE_IDLE:
345 // TODO(mcchou): BUG=441581 422 StopWatchingFD();
346 // Triggered by MediaTransportPropertyChanged and SetConfiguration.
347 // Stop watching on file descriptor if there is one.
348 break; 423 break;
349 case BluetoothAudioSink::STATE_PENDING: 424 case BluetoothAudioSink::STATE_PENDING:
350 // TODO(mcchou): BUG=441581 425 AcquireFD();
351 // Call BluetoothMediaTransportClient::Acquire() to get fd and mtus.
352 break; 426 break;
353 case BluetoothAudioSink::STATE_ACTIVE: 427 case BluetoothAudioSink::STATE_ACTIVE:
354 // TODO(mcchou): BUG=441581 428 WatchFD();
355 // Read from fd and call DataAvailable.
356 ReadFromFD();
357 break; 429 break;
358 default: 430 default:
359 break; 431 break;
360 } 432 }
361 433
362 state_ = state; 434 state_ = state;
363 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, 435 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_,
364 BluetoothAudioSinkStateChanged(this, state_)); 436 BluetoothAudioSinkStateChanged(this, state_));
365 } 437 }
366 438
(...skipping 23 matching lines...) Expand all
390 const std::string& error_message) { 462 const std::string& error_message) {
391 VLOG(1) << "OnRegisterFailed - error name: " << error_name 463 VLOG(1) << "OnRegisterFailed - error name: " << error_name
392 << ", error message: " << error_message; 464 << ", error message: " << error_message;
393 465
394 ResetEndpoint(); 466 ResetEndpoint();
395 error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED); 467 error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED);
396 } 468 }
397 469
398 void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded( 470 void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded(
399 const base::Closure& callback) { 471 const base::Closure& callback) {
400 VLOG(1) << "Unregisterd"; 472 VLOG(1) << "Unregisterd - endpoint: " << endpoint_path_.value();
armansito 2015/03/12 03:42:55 nit: s/Unregisterd/Unregistered/
Miao 2015/03/12 22:33:32 Done.
401 473
402 // Once the state becomes STATE_INVALID, media, media transport and media 474 // Once the state becomes STATE_INVALID, media, media transport and media
403 // endpoint will be reset. 475 // endpoint will be reset.
404 StateChanged(BluetoothAudioSink::STATE_INVALID); 476 StateChanged(BluetoothAudioSink::STATE_INVALID);
405 callback.Run(); 477 callback.Run();
406 } 478 }
407 479
408 void BluetoothAudioSinkChromeOS::OnUnregisterFailed( 480 void BluetoothAudioSinkChromeOS::OnUnregisterFailed(
409 const device::BluetoothAudioSink::ErrorCallback& error_callback, 481 const device::BluetoothAudioSink::ErrorCallback& error_callback,
410 const std::string& error_name, 482 const std::string& error_name,
411 const std::string& error_message) { 483 const std::string& error_message) {
412 VLOG(1) << "OnUnregisterFailed - error name: " << error_name 484 VLOG(1) << "OnUnregisterFailed - error name: " << error_name
413 << ", error message: " << error_message; 485 << ", error message: " << error_message;
414 486
415 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); 487 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED);
416 } 488 }
417 489
418 void BluetoothAudioSinkChromeOS::ReadFromFD() { 490 void BluetoothAudioSinkChromeOS::OnAcquireSucceeded(
419 DCHECK_GE(fd_.value(), 0); 491 const int fd,
492 const uint16_t read_mtu,
493 const uint16_t write_mtu) {
494 DCHECK_GT(fd, kInvalidFd);
495 DCHECK_GT(read_mtu, kInvalidReadMtu);
496 DCHECK_GT(write_mtu, kInvalidWriteMtu);
420 497
421 // TODO(mcchou): BUG=441581 498 // Avoids unnecessary memory reallocation if read MTU doesn't change.
armansito 2015/03/12 03:42:55 Nice!
Miao 2015/03/12 22:33:32 :)
422 // Read from file descriptor using watcher and create a buffer to contain the 499 if (read_mtu != read_mtu_) {
423 // data. Notify |Observers_| while there is audio data available. 500 read_mtu_ = read_mtu;
501 data_.reset(new char[read_mtu_]);
502 VLOG(1) << "OnAcquireSucceeded - allocate " << read_mtu_
503 << " bytes of memory";
504 }
505
506 write_mtu_ = write_mtu;
507
508 // Avoids closing the same file descriptor caused by reassignment.
509 if (!file_.get() || file_->GetPlatformFile() != fd) {
510 file_.reset(new base::File(fd));
511 DCHECK(file_->IsValid());
512 VLOG(1) << "OnAcquireSucceeded - update file";
513 }
514
515 VLOG(1) << "OnAcquireSucceeded - file: " << file_->GetPlatformFile()
516 << ", read MTU: " << read_mtu_ << ", write MTU: " << write_mtu_;
517 }
518
519 void BluetoothAudioSinkChromeOS::OnAcquireFailed(
520 const std::string& error_name,
521 const std::string& error_message) {
522 VLOG(1) << "OnAcquireFailed - error name: " << error_name
523 << ", error message: " << error_message;
524 }
525
526 void BluetoothAudioSinkChromeOS::OnReleaseFDSucceeded() {
527 VLOG(1) << "OnReleaseFDSucceeded";
528 }
529
530 void BluetoothAudioSinkChromeOS::OnReleaseFDFailed(
531 const std::string& error_name,
532 const std::string& error_message) {
533 VLOG(1) << "OnReleaseFDFailed - error name: " << error_name
534 << ", error message: " << error_message;
424 } 535 }
425 536
426 void BluetoothAudioSinkChromeOS::ResetMedia() { 537 void BluetoothAudioSinkChromeOS::ResetMedia() {
427 VLOG(1) << "ResetMedia"; 538 VLOG(1) << "ResetMedia";
428 539
429 media_path_ = dbus::ObjectPath(""); 540 media_path_ = dbus::ObjectPath("");
430 } 541 }
431 542
432 void BluetoothAudioSinkChromeOS::ResetTransport() { 543 void BluetoothAudioSinkChromeOS::ResetTransport() {
433 VLOG(1) << "ResetTransport"; 544 if (!transport_path_.IsValid()) {
545 VLOG(1) << "ResetTransport - skip";
546 return;
547 }
434 548
435 if (transport_path_.value() == "") 549 VLOG(1) << "ResetTransport - clean-up";
436 return; 550
551 VolumeChanged(BluetoothAudioSink::kInvalidVolume);
437 transport_path_ = dbus::ObjectPath(""); 552 transport_path_ = dbus::ObjectPath("");
438 VolumeChanged(BluetoothAudioSink::kInvalidVolume); 553 read_mtu_ = kInvalidReadMtu;
439 read_mtu_ = 0; 554 write_mtu_ = kInvalidWriteMtu;
440 write_mtu_ = 0; 555 file_.reset();
441 fd_.PutValue(-1);
442 } 556 }
443 557
444 void BluetoothAudioSinkChromeOS::ResetEndpoint() { 558 void BluetoothAudioSinkChromeOS::ResetEndpoint() {
445 VLOG(1) << "ResetEndpoint"; 559 VLOG(1) << "ResetEndpoint";
446 560
447 endpoint_path_ = ObjectPath(""); 561 endpoint_path_ = ObjectPath("");
448 media_endpoint_ = nullptr; 562 media_endpoint_ = nullptr;
449 } 563 }
450 564
451 } // namespace chromeos 565 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698