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
|
static BluetoothA2dpManager::SinkState
|
||||||
StatusStringToSinkState(const nsAString& aStatus)
|
StatusStringToSinkState(const nsAString& aStatus)
|
||||||
{
|
{
|
||||||
BluetoothA2dpManager::SinkState state;
|
BluetoothA2dpManager::SinkState state =
|
||||||
|
BluetoothA2dpManager::SinkState::SINK_UNKNOWN;
|
||||||
if (aStatus.EqualsLiteral("disconnected")) {
|
if (aStatus.EqualsLiteral("disconnected")) {
|
||||||
state = BluetoothA2dpManager::SinkState::SINK_DISCONNECTED;
|
state = BluetoothA2dpManager::SinkState::SINK_DISCONNECTED;
|
||||||
} else if (aStatus.EqualsLiteral("connecting")) {
|
} else if (aStatus.EqualsLiteral("connecting")) {
|
||||||
@ -106,10 +107,8 @@ StatusStringToSinkState(const nsAString& aStatus)
|
|||||||
state = BluetoothA2dpManager::SinkState::SINK_CONNECTED;
|
state = BluetoothA2dpManager::SinkState::SINK_CONNECTED;
|
||||||
} else if (aStatus.EqualsLiteral("playing")) {
|
} else if (aStatus.EqualsLiteral("playing")) {
|
||||||
state = BluetoothA2dpManager::SinkState::SINK_PLAYING;
|
state = BluetoothA2dpManager::SinkState::SINK_PLAYING;
|
||||||
} else if (aStatus.EqualsLiteral("disconnecting")) {
|
|
||||||
state = BluetoothA2dpManager::SinkState::SINK_DISCONNECTING;
|
|
||||||
} else {
|
} else {
|
||||||
MOZ_ASSERT(false, "Unknown sink state");
|
BT_WARNING("Unknown sink state");
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -228,9 +227,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr)
|
|||||||
|
|
||||||
/* HandleSinkPropertyChanged update sink state in A2dp
|
/* HandleSinkPropertyChanged update sink state in A2dp
|
||||||
*
|
*
|
||||||
* Possible values: "disconnected", "disconnecting",
|
* Possible values: "disconnected", "connecting", "connected", "playing"
|
||||||
* "connecting", "connected",
|
|
||||||
* "playing"
|
|
||||||
*
|
*
|
||||||
* 1. "disconnected" -> "connecting"
|
* 1. "disconnected" -> "connecting"
|
||||||
* Either an incoming or outgoing connection attempt ongoing
|
* Either an incoming or outgoing connection attempt ongoing
|
||||||
@ -244,9 +241,7 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr)
|
|||||||
* Audio stream suspended
|
* Audio stream suspended
|
||||||
* 6. "connected" -> "disconnected"
|
* 6. "connected" -> "disconnected"
|
||||||
* "playing" -> "disconnected"
|
* "playing" -> "disconnected"
|
||||||
* Disconnected from the remote device
|
* Disconnected from local or the remote device
|
||||||
* 7. "disconnecting" -> "disconnected"
|
|
||||||
* Disconnected from local
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||||
@ -273,10 +268,12 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
|||||||
|
|
||||||
const BluetoothValue& value = arr[0].value();
|
const BluetoothValue& value = arr[0].value();
|
||||||
MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
|
MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
|
||||||
SinkState prevState = mSinkState;
|
SinkState newState = StatusStringToSinkState(value.get_nsString());
|
||||||
mSinkState = 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) {
|
switch(mSinkState) {
|
||||||
case SinkState::SINK_CONNECTING:
|
case SinkState::SINK_CONNECTING:
|
||||||
@ -303,27 +300,20 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
|||||||
OnConnect(EmptyString());
|
OnConnect(EmptyString());
|
||||||
break;
|
break;
|
||||||
case SinkState::SINK_DISCONNECTED:
|
case SinkState::SINK_DISCONNECTED:
|
||||||
// XXX
|
|
||||||
// case 2: Connection attempt failed
|
// case 2: Connection attempt failed
|
||||||
if (prevState == SinkState::SINK_CONNECTING) {
|
if (prevState == SinkState::SINK_CONNECTING) {
|
||||||
OnConnect(NS_LITERAL_STRING("A2dpConnectionError"));
|
OnConnect(NS_LITERAL_STRING("A2dpConnectionError"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// case 6: Disconnected from the remote device
|
// case 6: Disconnected from the remote device
|
||||||
// case 7: Disconnected from local
|
|
||||||
MOZ_ASSERT(prevState == SinkState::SINK_CONNECTED ||
|
MOZ_ASSERT(prevState == SinkState::SINK_CONNECTED ||
|
||||||
prevState == SinkState::SINK_PLAYING ||
|
prevState == SinkState::SINK_PLAYING) ;
|
||||||
prevState == SinkState::SINK_DISCONNECTING);
|
|
||||||
|
|
||||||
mA2dpConnected = false;
|
mA2dpConnected = false;
|
||||||
NotifyConnectionStatusChanged();
|
NotifyConnectionStatusChanged();
|
||||||
mDeviceAddress.Truncate();
|
mDeviceAddress.Truncate();
|
||||||
|
OnDisconnect(EmptyString());
|
||||||
// case 7 only
|
|
||||||
if (prevState == SinkState::SINK_DISCONNECTING) {
|
|
||||||
OnDisconnect(EmptyString());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -20,11 +20,11 @@ public:
|
|||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
|
|
||||||
enum SinkState {
|
enum SinkState {
|
||||||
SINK_DISCONNECTED = 1,
|
SINK_UNKNOWN,
|
||||||
|
SINK_DISCONNECTED,
|
||||||
SINK_CONNECTING,
|
SINK_CONNECTING,
|
||||||
SINK_CONNECTED,
|
SINK_CONNECTED,
|
||||||
SINK_PLAYING,
|
SINK_PLAYING,
|
||||||
SINK_DISCONNECTING
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static BluetoothA2dpManager* Get();
|
static BluetoothA2dpManager* Get();
|
||||||
|
Loading…
Reference in New Issue
Block a user