mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 934891 - Remove DISCONNECTING state from A2DP, r=echou
This commit is contained in:
parent
9da890626e
commit
3e6d25c78b
@ -97,7 +97,8 @@ BluetoothA2dpManager::ResetAvrcp()
|
||||
static BluetoothA2dpManager::SinkState
|
||||
StatusStringToSinkState(const nsAString& aStatus)
|
||||
{
|
||||
BluetoothA2dpManager::SinkState state;
|
||||
BluetoothA2dpManager::SinkState state =
|
||||
BluetoothA2dpManager::SinkState::SINK_UNKNOWN;
|
||||
if (aStatus.EqualsLiteral("disconnected")) {
|
||||
state = BluetoothA2dpManager::SinkState::SINK_DISCONNECTED;
|
||||
} else if (aStatus.EqualsLiteral("connecting")) {
|
||||
@ -106,10 +107,8 @@ StatusStringToSinkState(const nsAString& aStatus)
|
||||
state = BluetoothA2dpManager::SinkState::SINK_CONNECTED;
|
||||
} else if (aStatus.EqualsLiteral("playing")) {
|
||||
state = BluetoothA2dpManager::SinkState::SINK_PLAYING;
|
||||
} else if (aStatus.EqualsLiteral("disconnecting")) {
|
||||
state = BluetoothA2dpManager::SinkState::SINK_DISCONNECTING;
|
||||
} else {
|
||||
MOZ_ASSERT(false, "Unknown sink state");
|
||||
BT_WARNING("Unknown sink state");
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@ -228,9 +227,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr)
|
||||
|
||||
/* HandleSinkPropertyChanged update sink state in A2dp
|
||||
*
|
||||
* Possible values: "disconnected", "disconnecting",
|
||||
* "connecting", "connected",
|
||||
* "playing"
|
||||
* Possible values: "disconnected", "connecting", "connected", "playing"
|
||||
*
|
||||
* 1. "disconnected" -> "connecting"
|
||||
* Either an incoming or outgoing connection attempt ongoing
|
||||
@ -244,9 +241,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr)
|
||||
* Audio stream suspended
|
||||
* 6. "connected" -> "disconnected"
|
||||
* "playing" -> "disconnected"
|
||||
* Disconnected from the remote device
|
||||
* 7. "disconnecting" -> "disconnected"
|
||||
* Disconnected from local
|
||||
* Disconnected from local or the remote device
|
||||
*/
|
||||
void
|
||||
BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
@ -273,10 +268,12 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
|
||||
const BluetoothValue& value = arr[0].value();
|
||||
MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
|
||||
SinkState prevState = mSinkState;
|
||||
mSinkState = StatusStringToSinkState(value.get_nsString());
|
||||
SinkState newState = StatusStringToSinkState(value.get_nsString());
|
||||
NS_ENSURE_TRUE_VOID((newState != SinkState::SINK_UNKNOWN) &&
|
||||
(newState != mSinkState));
|
||||
|
||||
NS_ENSURE_TRUE_VOID(mSinkState != prevState);
|
||||
SinkState prevState = mSinkState;
|
||||
mSinkState = newState;
|
||||
|
||||
switch(mSinkState) {
|
||||
case SinkState::SINK_CONNECTING:
|
||||
@ -303,27 +300,20 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
OnConnect(EmptyString());
|
||||
break;
|
||||
case SinkState::SINK_DISCONNECTED:
|
||||
// XXX
|
||||
// case 2: Connection attempt failed
|
||||
if (prevState == SinkState::SINK_CONNECTING) {
|
||||
if (prevState == SinkState::SINK_CONNECTING) {
|
||||
OnConnect(NS_LITERAL_STRING("A2dpConnectionError"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// case 6: Disconnected from the remote device
|
||||
// case 7: Disconnected from local
|
||||
MOZ_ASSERT(prevState == SinkState::SINK_CONNECTED ||
|
||||
prevState == SinkState::SINK_PLAYING ||
|
||||
prevState == SinkState::SINK_DISCONNECTING);
|
||||
|
||||
prevState == SinkState::SINK_PLAYING) ;
|
||||
|
||||
mA2dpConnected = false;
|
||||
NotifyConnectionStatusChanged();
|
||||
mDeviceAddress.Truncate();
|
||||
|
||||
// case 7 only
|
||||
if (prevState == SinkState::SINK_DISCONNECTING) {
|
||||
OnDisconnect(EmptyString());
|
||||
}
|
||||
OnDisconnect(EmptyString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -20,11 +20,11 @@ public:
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
enum SinkState {
|
||||
SINK_DISCONNECTED = 1,
|
||||
SINK_UNKNOWN,
|
||||
SINK_DISCONNECTED,
|
||||
SINK_CONNECTING,
|
||||
SINK_CONNECTED,
|
||||
SINK_PLAYING,
|
||||
SINK_DISCONNECTING
|
||||
};
|
||||
|
||||
static BluetoothA2dpManager* Get();
|
||||
|
Loading…
Reference in New Issue
Block a user