Audio routing fix
This commit is contained in:
@ -2737,10 +2737,9 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
val isSpeakerphoneOn = if (VERSION.SDK_INT >= 31)
|
val isSpeakerphoneOn = if (VERSION.SDK_INT >= 31)
|
||||||
am.communicationDevice?.type == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER
|
am.communicationDevice?.type == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER
|
||||||
else {
|
else
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
am.isSpeakerphoneOn
|
am.isSpeakerphoneOn
|
||||||
}
|
|
||||||
|
|
||||||
if (Call.inCall() && isAnyCallMode) {
|
if (Call.inCall() && isAnyCallMode) {
|
||||||
cleanupRunnable?.let {
|
cleanupRunnable?.let {
|
||||||
@ -2756,9 +2755,8 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!Call.inCall() && currentMode == MODE_NORMAL) {
|
else if (!Call.inCall() && currentMode == MODE_NORMAL)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
Log.d(TAG, "Scheduling ensureCommunicationMode (current: $currentMode) in 500ms " +
|
Log.d(TAG, "Scheduling ensureCommunicationMode (current: $currentMode) in 500ms " +
|
||||||
"(target speaker: $speakerPhone)")
|
"(target speaker: $speakerPhone)")
|
||||||
@ -2777,22 +2775,22 @@ class BaresipService: Service() {
|
|||||||
if (InCallService.instance != null) {
|
if (InCallService.instance != null) {
|
||||||
Log.d(TAG, "Using InCallService for audio route: $speakerPhone")
|
Log.d(TAG, "Using InCallService for audio route: $speakerPhone")
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
InCallService.instance!!.setAudioRoute(
|
val currentRoute = InCallService.instance!!.callAudioState?.route ?:
|
||||||
if (speakerPhone)
|
|
||||||
android.telecom.CallAudioState.ROUTE_SPEAKER
|
|
||||||
else
|
|
||||||
android.telecom.CallAudioState.ROUTE_EARPIECE
|
android.telecom.CallAudioState.ROUTE_EARPIECE
|
||||||
)
|
@Suppress("DEPRECATION")
|
||||||
|
if (speakerPhone)
|
||||||
|
InCallService.instance!!.setAudioRoute(android.telecom.CallAudioState.ROUTE_SPEAKER)
|
||||||
|
else if (currentRoute == android.telecom.CallAudioState.ROUTE_SPEAKER)
|
||||||
|
InCallService.instance!!.setAudioRoute(android.telecom.CallAudioState.ROUTE_EARPIECE)
|
||||||
}
|
}
|
||||||
else if (!hasTelecom) {
|
else if (!hasTelecom) {
|
||||||
Log.d(TAG, "No Telecom connection, using AudioManager for speaker")
|
Log.d(TAG, "No Telecom connection, using AudioManager for speaker")
|
||||||
Utils.setSpeakerPhone(mainExecutor, am, speakerPhone)
|
Utils.setSpeakerPhone(mainExecutor, am, speakerPhone)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (c in Call.calls()) {
|
for (c in Call.calls())
|
||||||
ConnectionService.setOutput(c.callp, speakerPhone)
|
ConnectionService.setOutput(c.callp, speakerPhone)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
if (am.mode != MODE_NORMAL) {
|
if (am.mode != MODE_NORMAL) {
|
||||||
am.mode = MODE_NORMAL
|
am.mode = MODE_NORMAL
|
||||||
|
|||||||
Reference in New Issue
Block a user