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

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

Issue 963983002: chromeos/dbus: Add verbose log to media-related clients and service provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@disconnect
Patch Set: Added helpers to convert state and error code. 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
« no previous file with comments | « chromeos/dbus/bluetooth_media_transport_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
25 ObjectPath GenerateEndpointPath() { 26 ObjectPath GenerateEndpointPath() {
26 static unsigned int sequence_number = 0; 27 static unsigned int sequence_number = 0;
27 ++sequence_number; 28 ++sequence_number;
28 std::stringstream path; 29 std::stringstream path;
29 path << kBluetoothAudioSinkServicePath << "/endpoint" << sequence_number; 30 path << kBluetoothAudioSinkServicePath << "/endpoint" << sequence_number;
30 return ObjectPath(path.str()); 31 return ObjectPath(path.str());
31 } 32 }
32 33
34 std::string StateToString(const BluetoothAudioSink::State& state) {
35 std::string verbose_state;
Ben Chan 2015/02/28 02:25:35 switch (state) { case BluetoothAudioSink::STATE_
Miao 2015/02/28 03:36:20 Done.
36 if (state == BluetoothAudioSink::STATE_INVALID) {
37 verbose_state = "invalid";
38 } else if (state == BluetoothAudioSink::STATE_DISCONNECTED) {
39 verbose_state = "disconnected";
40 } else if (state == BluetoothAudioSink::STATE_IDLE) {
41 verbose_state = "idle";
42 } else if (state == BluetoothAudioSink::STATE_PENDING) {
43 verbose_state = "pending";
44 } else if (state == BluetoothAudioSink::STATE_ACTIVE) {
45 verbose_state = "active";
46 } else {
47 verbose_state = "";
48 }
49 return verbose_state;
50 }
51
52 std::string ErrorCodeToString(const BluetoothAudioSink::ErrorCode& error_code) {
53 std::string verbose_error;
Ben Chan 2015/02/28 02:25:36 ditto
Miao 2015/02/28 03:36:20 Done.
54 if (error_code == BluetoothAudioSink::ERROR_UNSUPPORTED_PLATFORM) {
55 verbose_error = "unsupported platform";
56 } else if (error_code == BluetoothAudioSink::ERROR_INVALID_ADAPTER) {
57 verbose_error == "invalid adapter";
58 } else if (error_code == BluetoothAudioSink::ERROR_NOT_REGISTERED) {
59 verbose_error == "not registered";
60 } else if (error_code == BluetoothAudioSink::ERROR_NOT_UNREGISTERED) {
61 verbose_error == "not unregistered";
62 } else {
63 verbose_error == "";
64 }
65 return verbose_error;
66 }
67
33 // A dummy error callback for calling Unregister() in destructor. 68 // A dummy error callback for calling Unregister() in destructor.
34 void UnregisterErrorCallback( 69 void UnregisterErrorCallback(
35 device::BluetoothAudioSink::ErrorCode error_code) { 70 device::BluetoothAudioSink::ErrorCode error_code) {
36 VLOG(1) << "Bluetooth audio sink: Error code: " << error_code; 71 VLOG(1) << "UnregisterErrorCallback - " << ErrorCodeToString(error_code)
72 << "(" << error_code << ")";
37 } 73 }
38 74
39 } // namespace 75 } // namespace
40 76
41 namespace chromeos { 77 namespace chromeos {
42 78
43 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( 79 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS(
44 scoped_refptr<device::BluetoothAdapter> adapter) 80 scoped_refptr<device::BluetoothAdapter> adapter)
45 : state_(BluetoothAudioSink::STATE_INVALID), 81 : state_(BluetoothAudioSink::STATE_INVALID),
46 volume_(BluetoothAudioSink::kInvalidVolume), 82 volume_(BluetoothAudioSink::kInvalidVolume),
47 read_mtu_(nullptr), 83 read_mtu_(nullptr),
48 write_mtu_(nullptr), 84 write_mtu_(nullptr),
49 adapter_(adapter), 85 adapter_(adapter),
50 weak_ptr_factory_(this) { 86 weak_ptr_factory_(this) {
87 VLOG(1) << "Bluetooth audio sink created";
88
51 DCHECK(adapter_.get()); 89 DCHECK(adapter_.get());
52 DCHECK(adapter_->IsPresent()); 90 DCHECK(adapter_->IsPresent());
53 91
54 adapter_->AddObserver(this); 92 adapter_->AddObserver(this);
55 93
56 chromeos::BluetoothMediaClient* media = 94 chromeos::BluetoothMediaClient* media =
57 DBusThreadManager::Get()->GetBluetoothMediaClient(); 95 DBusThreadManager::Get()->GetBluetoothMediaClient();
58 DCHECK(media); 96 DCHECK(media);
59 media->AddObserver(this); 97 media->AddObserver(this);
60 98
61 chromeos::BluetoothMediaTransportClient *transport = 99 chromeos::BluetoothMediaTransportClient *transport =
62 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); 100 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient();
63 DCHECK(transport); 101 DCHECK(transport);
64 transport->AddObserver(this); 102 transport->AddObserver(this);
65 103
66 StateChanged(device::BluetoothAudioSink::STATE_DISCONNECTED); 104 StateChanged(device::BluetoothAudioSink::STATE_DISCONNECTED);
67 } 105 }
68 106
69 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { 107 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() {
108 VLOG(1) << "Bluetooth audio sink destroyed";
109
70 DCHECK(adapter_.get()); 110 DCHECK(adapter_.get());
71 111
72 if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) { 112 if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) {
73 Unregister(base::Bind(&base::DoNothing), 113 Unregister(base::Bind(&base::DoNothing),
74 base::Bind(&UnregisterErrorCallback)); 114 base::Bind(&UnregisterErrorCallback));
75 } 115 }
76 116
77 adapter_->RemoveObserver(this); 117 adapter_->RemoveObserver(this);
78 118
79 chromeos::BluetoothMediaClient* media = 119 chromeos::BluetoothMediaClient* media =
80 DBusThreadManager::Get()->GetBluetoothMediaClient(); 120 DBusThreadManager::Get()->GetBluetoothMediaClient();
81 DCHECK(media); 121 DCHECK(media);
82 media->RemoveObserver(this); 122 media->RemoveObserver(this);
83 123
84 chromeos::BluetoothMediaTransportClient *transport = 124 chromeos::BluetoothMediaTransportClient *transport =
85 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); 125 chromeos::DBusThreadManager::Get()->GetBluetoothMediaTransportClient();
86 DCHECK(transport); 126 DCHECK(transport);
87 transport->RemoveObserver(this); 127 transport->RemoveObserver(this);
88 } 128 }
89 129
90 void BluetoothAudioSinkChromeOS::Unregister( 130 void BluetoothAudioSinkChromeOS::Unregister(
91 const base::Closure& callback, 131 const base::Closure& callback,
92 const device::BluetoothAudioSink::ErrorCallback& error_callback) { 132 const device::BluetoothAudioSink::ErrorCallback& error_callback) {
133 VLOG(1) << "Bluetooth audio sink: Unregister called";
Ben Chan 2015/02/28 02:25:35 seems inconsistent with the messages above and bel
Miao 2015/02/28 03:36:20 Done.
134
93 if (!DBusThreadManager::IsInitialized()) 135 if (!DBusThreadManager::IsInitialized())
94 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); 136 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED);
95 137
96 chromeos::BluetoothMediaClient* media = 138 chromeos::BluetoothMediaClient* media =
97 DBusThreadManager::Get()->GetBluetoothMediaClient(); 139 DBusThreadManager::Get()->GetBluetoothMediaClient();
98 DCHECK(media); 140 DCHECK(media);
99 141
100 media->UnregisterEndpoint( 142 media->UnregisterEndpoint(
101 media_path_, 143 media_path_,
102 endpoint_path_, 144 endpoint_path_,
(...skipping 18 matching lines...) Expand all
121 BluetoothAudioSink::State BluetoothAudioSinkChromeOS::GetState() const { 163 BluetoothAudioSink::State BluetoothAudioSinkChromeOS::GetState() const {
122 return state_; 164 return state_;
123 } 165 }
124 166
125 uint16_t BluetoothAudioSinkChromeOS::GetVolume() const { 167 uint16_t BluetoothAudioSinkChromeOS::GetVolume() const {
126 return volume_; 168 return volume_;
127 } 169 }
128 170
129 void BluetoothAudioSinkChromeOS::AdapterPresentChanged( 171 void BluetoothAudioSinkChromeOS::AdapterPresentChanged(
130 device::BluetoothAdapter* adapter, bool present) { 172 device::BluetoothAdapter* adapter, bool present) {
131 VLOG(1) << "Bluetooth audio sink: Bluetooth adapter present changed: " 173 VLOG(1) << "Bluetooth audio sink - bluetooth adapter present changed: "
armansito 2015/02/28 02:28:24 nit: always capitalize Bluetooth. Here and below.
132 << present; 174 << present;
133 175
134 if (adapter->IsPresent()) { 176 if (adapter->IsPresent()) {
135 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); 177 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED);
136 } else { 178 } else {
137 adapter_->RemoveObserver(this); 179 adapter_->RemoveObserver(this);
138 StateChanged(BluetoothAudioSink::STATE_INVALID); 180 StateChanged(BluetoothAudioSink::STATE_INVALID);
139 } 181 }
140 } 182 }
141 183
142 void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( 184 void BluetoothAudioSinkChromeOS::AdapterPoweredChanged(
143 device::BluetoothAdapter* adapter, bool powered) { 185 device::BluetoothAdapter* adapter, bool powered) {
144 VLOG(1) << "Bluetooth audio sink: Bluetooth adapter powered changed: " 186 VLOG(1) << "Bluetooth audio sink - bluetooth adapter powered changed: "
145 << powered; 187 << powered;
146 188
147 // Regardless of the new powered state, |state_| goes to STATE_DISCONNECTED. 189 // 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. 190 // 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 191 // If true, the previous transport has been torn down, so the |state_| has to
150 // be disconnected before SetConfigruation is called. 192 // be disconnected before SetConfigruation is called.
151 if (state_ != BluetoothAudioSink::STATE_INVALID) 193 if (state_ != BluetoothAudioSink::STATE_INVALID)
152 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); 194 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED);
153 } 195 }
154 196
155 void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { 197 void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) {
156 if (object_path == media_path_) { 198 if (object_path == media_path_) {
199 VLOG(1) << "Bluetooth audio sink - media removed: "
200 << object_path.value();
157 StateChanged(BluetoothAudioSink::STATE_INVALID); 201 StateChanged(BluetoothAudioSink::STATE_INVALID);
158 } 202 }
159 } 203 }
160 204
161 void BluetoothAudioSinkChromeOS::MediaTransportRemoved( 205 void BluetoothAudioSinkChromeOS::MediaTransportRemoved(
162 const ObjectPath& object_path) { 206 const ObjectPath& object_path) {
163 // Whenever powered of |adapter_| turns false while present stays true, media 207 // Whenever powered of |adapter_| turns false while present stays true, media
164 // transport object should be removed accordingly, and the state should be 208 // transport object should be removed accordingly, and the state should be
165 // changed to STATE_DISCONNECTED. 209 // changed to STATE_DISCONNECTED.
166 if (object_path == transport_path_) { 210 if (object_path == transport_path_) {
211 VLOG(1) << "Bluetooth audio sink - media transport removed: "
212 << object_path.value();
167 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); 213 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED);
168 } 214 }
169 } 215 }
170 216
171 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( 217 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged(
172 const ObjectPath& object_path, 218 const ObjectPath& object_path,
173 const std::string& property_name) { 219 const std::string& property_name) {
174 if (object_path != transport_path_) 220 if (object_path != transport_path_)
175 return; 221 return;
176 222
(...skipping 24 matching lines...) Expand all
201 } 247 }
202 248
203 void BluetoothAudioSinkChromeOS::SetConfiguration( 249 void BluetoothAudioSinkChromeOS::SetConfiguration(
204 const ObjectPath& transport_path, 250 const ObjectPath& transport_path,
205 const TransportProperties& properties) { 251 const TransportProperties& properties) {
206 VLOG(1) << "Bluetooth audio sink: SetConfiguration called"; 252 VLOG(1) << "Bluetooth audio sink: SetConfiguration called";
207 transport_path_ = transport_path; 253 transport_path_ = transport_path;
208 254
209 // The initial state for a connection should be "idle". 255 // The initial state for a connection should be "idle".
210 if (properties.state != BluetoothMediaTransportClient::kStateIdle) { 256 if (properties.state != BluetoothMediaTransportClient::kStateIdle) {
211 VLOG(1) << "Bluetooth Audio Sink: unexpected state " << properties.state; 257 VLOG(1) << "Bluetooth audio sink: unexpected state " << properties.state;
212 return; 258 return;
213 } 259 }
214 260
215 // Updates |volume_| if the volume level is provided in |properties|. 261 // Updates |volume_| if the volume level is provided in |properties|.
216 if (properties.volume.get()) { 262 if (properties.volume.get()) {
217 VolumeChanged(*properties.volume); 263 VolumeChanged(*properties.volume);
218 } 264 }
219 265
220 StateChanged(BluetoothAudioSink::STATE_IDLE); 266 StateChanged(BluetoothAudioSink::STATE_IDLE);
221 } 267 }
(...skipping 15 matching lines...) Expand all
237 283
238 void BluetoothAudioSinkChromeOS::Released() { 284 void BluetoothAudioSinkChromeOS::Released() {
239 VLOG(1) << "Bluetooth audio sink: Released called"; 285 VLOG(1) << "Bluetooth audio sink: Released called";
240 StateChanged(BluetoothAudioSink::STATE_INVALID); 286 StateChanged(BluetoothAudioSink::STATE_INVALID);
241 } 287 }
242 288
243 void BluetoothAudioSinkChromeOS::Register( 289 void BluetoothAudioSinkChromeOS::Register(
244 const BluetoothAudioSink::Options& options, 290 const BluetoothAudioSink::Options& options,
245 const base::Closure& callback, 291 const base::Closure& callback,
246 const BluetoothAudioSink::ErrorCallback& error_callback) { 292 const BluetoothAudioSink::ErrorCallback& error_callback) {
293 VLOG(1) << "Bluetooth audio sink: Register called";
294
247 DCHECK(adapter_.get()); 295 DCHECK(adapter_.get());
248 DCHECK_EQ(state_, BluetoothAudioSink::STATE_DISCONNECTED); 296 DCHECK_EQ(state_, BluetoothAudioSink::STATE_DISCONNECTED);
249 297
250 // Gets system bus. 298 // Gets system bus.
251 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); 299 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus();
252 300
253 // Creates a Media Endpoint with newly-generated path. 301 // Creates a Media Endpoint with newly-generated path.
254 endpoint_path_ = GenerateEndpointPath(); 302 endpoint_path_ = GenerateEndpointPath();
255 media_endpoint_.reset( 303 media_endpoint_.reset(
256 BluetoothMediaEndpointServiceProvider::Create( 304 BluetoothMediaEndpointServiceProvider::Create(
(...skipping 27 matching lines...) Expand all
284 BluetoothMediaEndpointServiceProvider* 332 BluetoothMediaEndpointServiceProvider*
285 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { 333 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() {
286 return media_endpoint_.get(); 334 return media_endpoint_.get();
287 } 335 }
288 336
289 void BluetoothAudioSinkChromeOS::StateChanged( 337 void BluetoothAudioSinkChromeOS::StateChanged(
290 BluetoothAudioSink::State state) { 338 BluetoothAudioSink::State state) {
291 if (state == state_) 339 if (state == state_)
292 return; 340 return;
293 341
294 VLOG(1) << "Bluetooth audio sink state changed: " << state; 342 VLOG(1) << "Bluetooth audio sink state changed: " << StateToString(state);
343
295 switch (state) { 344 switch (state) {
296 case BluetoothAudioSink::STATE_INVALID: 345 case BluetoothAudioSink::STATE_INVALID:
297 ResetMedia(); 346 ResetMedia();
298 ResetEndpoint(); 347 ResetEndpoint();
299 case BluetoothAudioSink::STATE_DISCONNECTED: 348 case BluetoothAudioSink::STATE_DISCONNECTED:
300 ResetTransport(); 349 ResetTransport();
301 break; 350 break;
302 case BluetoothAudioSink::STATE_IDLE: 351 case BluetoothAudioSink::STATE_IDLE:
303 // TODO(mcchou): BUG=441581 352 // TODO(mcchou): BUG=441581
304 // Triggered by MediaTransportPropertyChanged and SetConfiguration. 353 // Triggered by MediaTransportPropertyChanged and SetConfiguration.
(...skipping 15 matching lines...) Expand all
320 state_ = state; 369 state_ = state;
321 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, 370 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_,
322 BluetoothAudioSinkStateChanged(this, state_)); 371 BluetoothAudioSinkStateChanged(this, state_));
323 } 372 }
324 373
325 void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { 374 void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) {
326 if (volume == volume_) 375 if (volume == volume_)
327 return; 376 return;
328 377
329 VLOG(1) << "Bluetooth audio sink volume changed: " << volume; 378 VLOG(1) << "Bluetooth audio sink volume changed: " << volume;
379
330 volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume); 380 volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume);
331
332 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, 381 FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_,
333 BluetoothAudioSinkVolumeChanged(this, volume_)); 382 BluetoothAudioSinkVolumeChanged(this, volume_));
334 } 383 }
335 384
336 void BluetoothAudioSinkChromeOS::OnRegisterSucceeded( 385 void BluetoothAudioSinkChromeOS::OnRegisterSucceeded(
337 const base::Closure& callback) { 386 const base::Closure& callback) {
338 DCHECK(media_endpoint_.get()); 387 DCHECK(media_endpoint_.get());
339 VLOG(1) << "Bluetooth audio sink registerd"; 388 VLOG(1) << "Bluetooth audio sink registerd";
340 389
341 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); 390 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED);
342 callback.Run(); 391 callback.Run();
343 } 392 }
344 393
345 void BluetoothAudioSinkChromeOS::OnRegisterFailed( 394 void BluetoothAudioSinkChromeOS::OnRegisterFailed(
346 const BluetoothAudioSink::ErrorCallback& error_callback, 395 const BluetoothAudioSink::ErrorCallback& error_callback,
347 const std::string& error_name, 396 const std::string& error_name,
348 const std::string& error_message) { 397 const std::string& error_message) {
349 VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; 398 VLOG(1) << "Bluetooth audio sink - error_name: " << error_name
399 << ", error_message: " << error_message;
350 400
351 ResetEndpoint(); 401 ResetEndpoint();
352 error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED); 402 error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED);
353 } 403 }
354 404
355 void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded( 405 void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded(
356 const base::Closure& callback) { 406 const base::Closure& callback) {
357 VLOG(1) << "Bluetooth audio sink unregisterd"; 407 VLOG(1) << "Bluetooth audio sink unregisterd";
358 408
359 // Once the state becomes STATE_INVALID, media, media transport and media 409 // Once the state becomes STATE_INVALID, media, media transport and media
360 // endpoint will be reset. 410 // endpoint will be reset.
361 StateChanged(BluetoothAudioSink::STATE_INVALID); 411 StateChanged(BluetoothAudioSink::STATE_INVALID);
362 callback.Run(); 412 callback.Run();
363 } 413 }
364 414
365 void BluetoothAudioSinkChromeOS::OnUnregisterFailed( 415 void BluetoothAudioSinkChromeOS::OnUnregisterFailed(
366 const device::BluetoothAudioSink::ErrorCallback& error_callback, 416 const device::BluetoothAudioSink::ErrorCallback& error_callback,
367 const std::string& error_name, 417 const std::string& error_name,
368 const std::string& error_message) { 418 const std::string& error_message) {
369 VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; 419 VLOG(1) << "Bluetooth audio sink: error " << error_name << ": "
420 << error_message;
421
370 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); 422 error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED);
371 } 423 }
372 424
373 void BluetoothAudioSinkChromeOS::ReadFromFD() { 425 void BluetoothAudioSinkChromeOS::ReadFromFD() {
374 DCHECK_GE(fd_.value(), 0); 426 DCHECK_GE(fd_.value(), 0);
375 427
376 // TODO(mcchou): BUG=441581 428 // TODO(mcchou): BUG=441581
377 // Read from file descriptor using watcher and create a buffer to contain the 429 // Read from file descriptor using watcher and create a buffer to contain the
378 // data. Notify |Observers_| while there is audio data available. 430 // data. Notify |Observers_| while there is audio data available.
379 } 431 }
380 432
381 void BluetoothAudioSinkChromeOS::ResetMedia() { 433 void BluetoothAudioSinkChromeOS::ResetMedia() {
434 VLOG(1) << "Bluetooth audio sink: ResetMedia";
435
382 media_path_ = dbus::ObjectPath(""); 436 media_path_ = dbus::ObjectPath("");
383 } 437 }
384 438
385 void BluetoothAudioSinkChromeOS::ResetTransport() { 439 void BluetoothAudioSinkChromeOS::ResetTransport() {
440 VLOG(1) << "Bluetooth audio sink: ResetTransport";
441
386 if (transport_path_.value() == "") 442 if (transport_path_.value() == "")
387 return; 443 return;
388 transport_path_ = dbus::ObjectPath(""); 444 transport_path_ = dbus::ObjectPath("");
389 VolumeChanged(BluetoothAudioSink::kInvalidVolume); 445 VolumeChanged(BluetoothAudioSink::kInvalidVolume);
390 read_mtu_ = 0; 446 read_mtu_ = 0;
391 write_mtu_ = 0; 447 write_mtu_ = 0;
392 fd_.PutValue(-1); 448 fd_.PutValue(-1);
393 } 449 }
394 450
395 void BluetoothAudioSinkChromeOS::ResetEndpoint() { 451 void BluetoothAudioSinkChromeOS::ResetEndpoint() {
452 VLOG(1) << "Bluetooth audio sink: ResetEndpoint";
453
396 endpoint_path_ = ObjectPath(""); 454 endpoint_path_ = ObjectPath("");
397 media_endpoint_ = nullptr; 455 media_endpoint_ = nullptr;
398 } 456 }
399 457
400 } // namespace chromeos 458 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/bluetooth_media_transport_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698