mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-30 16:46:20 +00:00
Prevent unecessary sound devices reload
This commit is contained in:
parent
08052d64fd
commit
e3f1611a0f
4 changed files with 38 additions and 3 deletions
|
|
@ -31,6 +31,7 @@ disable_ringing=1
|
||||||
|
|
||||||
[audio]
|
[audio]
|
||||||
android_disable_audio_focus_requests=1
|
android_disable_audio_focus_requests=1
|
||||||
|
android_monitor_audio_devices=0
|
||||||
|
|
||||||
[video]
|
[video]
|
||||||
displaytype=MSAndroidTextureDisplay
|
displaytype=MSAndroidTextureDisplay
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,14 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
||||||
"$TAG Added device [${device.productName}] with ID [${device.id}] and type [${device.type}]"
|
"$TAG Added device [${device.productName}] with ID [${device.id}] and type [${device.type}]"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
core.reloadSoundDevices()
|
if (telecomManager.getCurrentlyFollowedCalls() <= 0) {
|
||||||
|
Log.i("$TAG No call found in Telecom's CallsManager, reloading sound devices")
|
||||||
|
core.reloadSoundDevices()
|
||||||
|
} else {
|
||||||
|
Log.i(
|
||||||
|
"$TAG At least one active call in Telecom's CallsManager, let it handle the added device"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,7 +131,14 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
||||||
"$TAG Removed device [${device.id}][${device.productName}][${device.type}]"
|
"$TAG Removed device [${device.id}][${device.productName}][${device.type}]"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
core.reloadSoundDevices()
|
if (telecomManager.getCurrentlyFollowedCalls() <= 0) {
|
||||||
|
Log.i("$TAG No call found in Telecom's CallsManager, reloading sound devices")
|
||||||
|
core.reloadSoundDevices()
|
||||||
|
} else {
|
||||||
|
Log.i(
|
||||||
|
"$TAG At least one active call in Telecom's CallsManager, let it handle the removed device"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,6 +256,11 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
override fun onAudioDevicesListUpdated(core: Core) {
|
||||||
|
Log.i("$TAG Available audio devices list was updated")
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
override fun onLastCallEnded(core: Core) {
|
override fun onLastCallEnded(core: Core) {
|
||||||
Log.i("$TAG Last call ended")
|
Log.i("$TAG Last call ended")
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ class TelecomCallControlCallback(
|
||||||
|
|
||||||
callControl.availableEndpoints.onEach { list ->
|
callControl.availableEndpoints.onEach { list ->
|
||||||
Log.i("$TAG New available audio endpoints list")
|
Log.i("$TAG New available audio endpoints list")
|
||||||
if (availableEndpoints.size != list.size) {
|
if (availableEndpoints != list) {
|
||||||
Log.i(
|
Log.i(
|
||||||
"$TAG List size of available audio endpoints has changed, reload sound devices in SDK"
|
"$TAG List size of available audio endpoints has changed, reload sound devices in SDK"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,15 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
||||||
override fun onCallCreated(core: Core, call: Call) {
|
override fun onCallCreated(core: Core, call: Call) {
|
||||||
onCallCreated(call)
|
onCallCreated(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
override fun onLastCallEnded(core: Core) {
|
||||||
|
currentlyFollowedCalls = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var currentlyFollowedCalls: Int = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
callsManager.registerAppWithTelecom(
|
callsManager.registerAppWithTelecom(
|
||||||
CallsManager.CAPABILITY_BASELINE or
|
CallsManager.CAPABILITY_BASELINE or
|
||||||
|
|
@ -65,6 +72,11 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
fun getCurrentlyFollowedCalls(): Int {
|
||||||
|
return currentlyFollowedCalls
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun onCallCreated(call: Call) {
|
fun onCallCreated(call: Call) {
|
||||||
Log.i("$TAG Call created: $call")
|
Log.i("$TAG Call created: $call")
|
||||||
|
|
@ -112,6 +124,7 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
||||||
coreContext.postOnCoreThread {
|
coreContext.postOnCoreThread {
|
||||||
coreContext.terminateCall(call)
|
coreContext.terminateCall(call)
|
||||||
}
|
}
|
||||||
|
currentlyFollowedCalls -= 1
|
||||||
},
|
},
|
||||||
{ // onSetActive
|
{ // onSetActive
|
||||||
Log.i("$TAG We're asked to resume the call")
|
Log.i("$TAG We're asked to resume the call")
|
||||||
|
|
@ -140,6 +153,8 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
||||||
|
|
||||||
// We must first call setCallback on callControlScope before using it
|
// We must first call setCallback on callControlScope before using it
|
||||||
callbacks.onCallControlCallbackSet()
|
callbacks.onCallControlCallbackSet()
|
||||||
|
currentlyFollowedCalls += 1
|
||||||
|
Log.i("$TAG Call added to Telecom's CallsManager")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("$TAG Failed to add call to Telecom's CallsManager!")
|
Log.e("$TAG Failed to add call to Telecom's CallsManager!")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue