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 |
index 98124e87263c207558a893d1c378b0fefaf91684..aab0e2ec77aa9e1bd112a46750adfecfde8e1f05 100644 |
--- a/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
+++ b/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
@@ -6,6 +6,7 @@ |
#include <algorithm> |
#include <sstream> |
+#include <string> |
#include <vector> |
#include "base/debug/stack_trace.h" |
@@ -30,10 +31,45 @@ ObjectPath GenerateEndpointPath() { |
return ObjectPath(path.str()); |
} |
+std::string StateToString(const BluetoothAudioSink::State& state) { |
+ 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.
|
+ if (state == BluetoothAudioSink::STATE_INVALID) { |
+ verbose_state = "invalid"; |
+ } else if (state == BluetoothAudioSink::STATE_DISCONNECTED) { |
+ verbose_state = "disconnected"; |
+ } else if (state == BluetoothAudioSink::STATE_IDLE) { |
+ verbose_state = "idle"; |
+ } else if (state == BluetoothAudioSink::STATE_PENDING) { |
+ verbose_state = "pending"; |
+ } else if (state == BluetoothAudioSink::STATE_ACTIVE) { |
+ verbose_state = "active"; |
+ } else { |
+ verbose_state = ""; |
+ } |
+ return verbose_state; |
+} |
+ |
+std::string ErrorCodeToString(const BluetoothAudioSink::ErrorCode& error_code) { |
+ std::string verbose_error; |
Ben Chan
2015/02/28 02:25:36
ditto
Miao
2015/02/28 03:36:20
Done.
|
+ if (error_code == BluetoothAudioSink::ERROR_UNSUPPORTED_PLATFORM) { |
+ verbose_error = "unsupported platform"; |
+ } else if (error_code == BluetoothAudioSink::ERROR_INVALID_ADAPTER) { |
+ verbose_error == "invalid adapter"; |
+ } else if (error_code == BluetoothAudioSink::ERROR_NOT_REGISTERED) { |
+ verbose_error == "not registered"; |
+ } else if (error_code == BluetoothAudioSink::ERROR_NOT_UNREGISTERED) { |
+ verbose_error == "not unregistered"; |
+ } else { |
+ verbose_error == ""; |
+ } |
+ return verbose_error; |
+} |
+ |
// A dummy error callback for calling Unregister() in destructor. |
void UnregisterErrorCallback( |
device::BluetoothAudioSink::ErrorCode error_code) { |
- VLOG(1) << "Bluetooth audio sink: Error code: " << error_code; |
+ VLOG(1) << "UnregisterErrorCallback - " << ErrorCodeToString(error_code) |
+ << "(" << error_code << ")"; |
} |
} // namespace |
@@ -48,6 +84,8 @@ BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( |
write_mtu_(nullptr), |
adapter_(adapter), |
weak_ptr_factory_(this) { |
+ VLOG(1) << "Bluetooth audio sink created"; |
+ |
DCHECK(adapter_.get()); |
DCHECK(adapter_->IsPresent()); |
@@ -67,6 +105,8 @@ BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( |
} |
BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { |
+ VLOG(1) << "Bluetooth audio sink destroyed"; |
+ |
DCHECK(adapter_.get()); |
if (state_ != BluetoothAudioSink::STATE_INVALID && media_endpoint_.get()) { |
@@ -90,6 +130,8 @@ BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { |
void BluetoothAudioSinkChromeOS::Unregister( |
const base::Closure& callback, |
const device::BluetoothAudioSink::ErrorCallback& error_callback) { |
+ 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.
|
+ |
if (!DBusThreadManager::IsInitialized()) |
error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); |
@@ -128,7 +170,7 @@ uint16_t BluetoothAudioSinkChromeOS::GetVolume() const { |
void BluetoothAudioSinkChromeOS::AdapterPresentChanged( |
device::BluetoothAdapter* adapter, bool present) { |
- VLOG(1) << "Bluetooth audio sink: Bluetooth adapter present changed: " |
+ VLOG(1) << "Bluetooth audio sink - bluetooth adapter present changed: " |
armansito
2015/02/28 02:28:24
nit: always capitalize Bluetooth. Here and below.
|
<< present; |
if (adapter->IsPresent()) { |
@@ -141,7 +183,7 @@ void BluetoothAudioSinkChromeOS::AdapterPresentChanged( |
void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( |
device::BluetoothAdapter* adapter, bool powered) { |
- VLOG(1) << "Bluetooth audio sink: Bluetooth adapter powered changed: " |
+ VLOG(1) << "Bluetooth audio sink - bluetooth adapter powered changed: " |
<< powered; |
// Regardless of the new powered state, |state_| goes to STATE_DISCONNECTED. |
@@ -154,6 +196,8 @@ void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( |
void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { |
if (object_path == media_path_) { |
+ VLOG(1) << "Bluetooth audio sink - media removed: " |
+ << object_path.value(); |
StateChanged(BluetoothAudioSink::STATE_INVALID); |
} |
} |
@@ -164,6 +208,8 @@ void BluetoothAudioSinkChromeOS::MediaTransportRemoved( |
// transport object should be removed accordingly, and the state should be |
// changed to STATE_DISCONNECTED. |
if (object_path == transport_path_) { |
+ VLOG(1) << "Bluetooth audio sink - media transport removed: " |
+ << object_path.value(); |
StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); |
} |
} |
@@ -208,7 +254,7 @@ void BluetoothAudioSinkChromeOS::SetConfiguration( |
// The initial state for a connection should be "idle". |
if (properties.state != BluetoothMediaTransportClient::kStateIdle) { |
- VLOG(1) << "Bluetooth Audio Sink: unexpected state " << properties.state; |
+ VLOG(1) << "Bluetooth audio sink: unexpected state " << properties.state; |
return; |
} |
@@ -244,6 +290,8 @@ void BluetoothAudioSinkChromeOS::Register( |
const BluetoothAudioSink::Options& options, |
const base::Closure& callback, |
const BluetoothAudioSink::ErrorCallback& error_callback) { |
+ VLOG(1) << "Bluetooth audio sink: Register called"; |
+ |
DCHECK(adapter_.get()); |
DCHECK_EQ(state_, BluetoothAudioSink::STATE_DISCONNECTED); |
@@ -291,7 +339,8 @@ void BluetoothAudioSinkChromeOS::StateChanged( |
if (state == state_) |
return; |
- VLOG(1) << "Bluetooth audio sink state changed: " << state; |
+ VLOG(1) << "Bluetooth audio sink state changed: " << StateToString(state); |
+ |
switch (state) { |
case BluetoothAudioSink::STATE_INVALID: |
ResetMedia(); |
@@ -327,8 +376,8 @@ void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { |
return; |
VLOG(1) << "Bluetooth audio sink volume changed: " << volume; |
- volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume); |
+ volume_ = std::min(volume, BluetoothAudioSink::kInvalidVolume); |
FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_, |
BluetoothAudioSinkVolumeChanged(this, volume_)); |
} |
@@ -346,7 +395,8 @@ void BluetoothAudioSinkChromeOS::OnRegisterFailed( |
const BluetoothAudioSink::ErrorCallback& error_callback, |
const std::string& error_name, |
const std::string& error_message) { |
- VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; |
+ VLOG(1) << "Bluetooth audio sink - error_name: " << error_name |
+ << ", error_message: " << error_message; |
ResetEndpoint(); |
error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED); |
@@ -366,7 +416,9 @@ void BluetoothAudioSinkChromeOS::OnUnregisterFailed( |
const device::BluetoothAudioSink::ErrorCallback& error_callback, |
const std::string& error_name, |
const std::string& error_message) { |
- VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message; |
+ VLOG(1) << "Bluetooth audio sink: error " << error_name << ": " |
+ << error_message; |
+ |
error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); |
} |
@@ -379,10 +431,14 @@ void BluetoothAudioSinkChromeOS::ReadFromFD() { |
} |
void BluetoothAudioSinkChromeOS::ResetMedia() { |
+ VLOG(1) << "Bluetooth audio sink: ResetMedia"; |
+ |
media_path_ = dbus::ObjectPath(""); |
} |
void BluetoothAudioSinkChromeOS::ResetTransport() { |
+ VLOG(1) << "Bluetooth audio sink: ResetTransport"; |
+ |
if (transport_path_.value() == "") |
return; |
transport_path_ = dbus::ObjectPath(""); |
@@ -393,6 +449,8 @@ void BluetoothAudioSinkChromeOS::ResetTransport() { |
} |
void BluetoothAudioSinkChromeOS::ResetEndpoint() { |
+ VLOG(1) << "Bluetooth audio sink: ResetEndpoint"; |
+ |
endpoint_path_ = ObjectPath(""); |
media_endpoint_ = nullptr; |
} |