Skip to content
Snippets Groups Projects
Commit f8dbc5d0 authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk Committed by Jakub Tyszkowski
Browse files

le_audio: Introduce Unicast fallback after Broadcast stop

This change introduces support for fallback to Unicast streaming once
Broadcast streaming is finished. To make this happend Broadcast needs to
expropriate Unicast stream then this Broadcast needs to be stopped.

Tag: #feature
Bug: 294513510
Test: atest LeAudioServiceTest
Change-Id: I2cdd8f2576b2a1bdd30e1c8fd8cff870cd4be552
parent cff2af63
No related branches found
No related tags found
No related merge requests found
......@@ -139,6 +139,7 @@ public class LeAudioService extends ProfileService {
AudioManager mAudioManager;
LeAudioTmapGattServer mTmapGattServer;
int mTmapRoleMask;
int mUnicastGroupIdDeactivatedForBroadcastTransition = LE_AUDIO_GROUP_ID_INVALID;
boolean mTmapStarted = false;
private boolean mAwaitingBroadcastCreateResponse = false;
private final LinkedList<BluetoothLeBroadcastSettings> mCreateBroadcastQueue =
......@@ -1902,6 +1903,28 @@ public class LeAudioService extends ProfileService {
}
}
void transitionFromBroadcastToUnicast() {
BluetoothDevice unicastDevice =
getLeadDeviceForTheGroup(mUnicastGroupIdDeactivatedForBroadcastTransition);
if (unicastDevice == null) {
Log.e(TAG, "EVENT_TYPE_BROADCAST_DESTROYED: No valid unicast device for group ID: "
+ mUnicastGroupIdDeactivatedForBroadcastTransition);
mUnicastGroupIdDeactivatedForBroadcastTransition = LE_AUDIO_GROUP_ID_INVALID;
return;
}
if (DBG) {
Log.d(TAG, "Transitionaing to Unicast stream for group: "
+ mUnicastGroupIdDeactivatedForBroadcastTransition
+ ", with device: "
+ unicastDevice);
}
mUnicastGroupIdDeactivatedForBroadcastTransition = LE_AUDIO_GROUP_ID_INVALID;
setActiveDevice(unicastDevice);
}
// Suppressed since this is part of a local process
@SuppressLint("AndroidFrameworkRequiresPermission")
void messageFromNative(LeAudioStackEvent stackEvent) {
......@@ -2089,6 +2112,7 @@ public class LeAudioService extends ProfileService {
handleGroupTransitToInactive(groupId, false);
if (!mCreateBroadcastQueue.isEmpty()) {
mUnicastGroupIdDeactivatedForBroadcastTransition = groupId;
BluetoothLeBroadcastSettings settings = mCreateBroadcastQueue.remove();
createBroadcast(settings);
}
......@@ -2146,6 +2170,11 @@ public class LeAudioService extends ProfileService {
}
mBroadcastDescriptors.remove(broadcastId);
/* Restore the Unicast stream from before the Broadcast was started. */
if (mUnicastGroupIdDeactivatedForBroadcastTransition != LE_AUDIO_GROUP_ID_INVALID) {
transitionFromBroadcastToUnicast();
}
} else if (stackEvent.type == LeAudioStackEvent.EVENT_TYPE_BROADCAST_STATE) {
int broadcastId = stackEvent.valueInt1;
int state = stackEvent.valueInt2;
......@@ -2933,6 +2962,10 @@ public class LeAudioService extends ProfileService {
handleGroupTransitToInactive(groupId, false);
}
mGroupDescriptors.remove(groupId);
if (mUnicastGroupIdDeactivatedForBroadcastTransition == groupId) {
mUnicastGroupIdDeactivatedForBroadcastTransition = LE_AUDIO_GROUP_ID_INVALID;
}
}
notifyGroupNodeRemoved(device, groupId);
}
......@@ -3937,6 +3970,8 @@ public class LeAudioService extends ProfileService {
ProfileService.println(sb, " currentlyActiveGroupId: " + getActiveGroupId());
ProfileService.println(sb, " mActiveAudioOutDevice: " + mActiveAudioOutDevice);
ProfileService.println(sb, " mActiveAudioInDevice: " + mActiveAudioInDevice);
ProfileService.println(sb, " mUnicastGroupIdDeactivatedForBroadcastTransition: "
+ mUnicastGroupIdDeactivatedForBroadcastTransition);
ProfileService.println(sb, " mExposedActiveDevice: " + mExposedActiveDevice);
ProfileService.println(sb, " mHfpHandoverDevice:" + mHfpHandoverDevice);
ProfileService.println(sb, " mLeAudioIsInbandRingtoneSupported:"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment