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 <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 BluetoothMediaEndpointServiceProvider* | 221 BluetoothMediaEndpointServiceProvider* |
222 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { | 222 BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { |
223 return media_endpoint_.get(); | 223 return media_endpoint_.get(); |
224 } | 224 } |
225 | 225 |
226 void BluetoothAudioSinkChromeOS::AdapterPresentChanged( | 226 void BluetoothAudioSinkChromeOS::AdapterPresentChanged( |
227 device::BluetoothAdapter* adapter, bool present) { | 227 device::BluetoothAdapter* adapter, bool present) { |
228 VLOG(1) << "AdapterPresentChanged: " << present; | 228 VLOG(1) << "AdapterPresentChanged: " << present; |
229 | 229 |
| 230 if (adapter != adapter_.get()) |
| 231 return; |
| 232 |
230 if (adapter->IsPresent()) { | 233 if (adapter->IsPresent()) { |
231 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); | 234 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); |
232 } else { | 235 } else { |
233 adapter_->RemoveObserver(this); | 236 adapter_->RemoveObserver(this); |
234 StateChanged(BluetoothAudioSink::STATE_INVALID); | 237 StateChanged(BluetoothAudioSink::STATE_INVALID); |
235 } | 238 } |
236 } | 239 } |
237 | 240 |
238 void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( | 241 void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( |
239 device::BluetoothAdapter* adapter, bool powered) { | 242 device::BluetoothAdapter* adapter, bool powered) { |
240 VLOG(1) << "AdapterPoweredChanged: " << powered; | 243 VLOG(1) << "AdapterPoweredChanged: " << powered; |
241 | 244 |
| 245 if (adapter != adapter_.get()) |
| 246 return; |
| 247 |
242 // Regardless of the new powered state, |state_| goes to STATE_DISCONNECTED. | 248 // Regardless of the new powered state, |state_| goes to STATE_DISCONNECTED. |
243 // If false, the transport is closed, but the endpoint is still valid for use. | 249 // If false, the transport is closed, but the endpoint is still valid for use. |
244 // If true, the previous transport has been torn down, so the |state_| has to | 250 // If true, the previous transport has been torn down, so the |state_| has to |
245 // be disconnected before SetConfigruation is called. | 251 // be disconnected before SetConfigruation is called. |
246 if (state_ != BluetoothAudioSink::STATE_INVALID) | 252 if (state_ != BluetoothAudioSink::STATE_INVALID) |
247 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); | 253 StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); |
248 } | 254 } |
249 | 255 |
250 void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { | 256 void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { |
251 if (object_path == media_path_) { | 257 if (object_path == media_path_) { |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 566 } |
561 | 567 |
562 void BluetoothAudioSinkChromeOS::ResetEndpoint() { | 568 void BluetoothAudioSinkChromeOS::ResetEndpoint() { |
563 VLOG(1) << "ResetEndpoint"; | 569 VLOG(1) << "ResetEndpoint"; |
564 | 570 |
565 endpoint_path_ = ObjectPath(""); | 571 endpoint_path_ = ObjectPath(""); |
566 media_endpoint_ = nullptr; | 572 media_endpoint_ = nullptr; |
567 } | 573 } |
568 | 574 |
569 } // namespace chromeos | 575 } // namespace chromeos |
OLD | NEW |