From 74d82c08e2d88335b46f5e71f3f1fad5aeb25113 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sun, 16 Aug 2026 18:36:28 +0300 Subject: [PATCH] Removed iLBC Mode audio setting --- .../kotlin/com/tutpro/baresip/AudioScreen.kt | 60 ------------------- .../com/tutpro/baresip/AudioViewModel.kt | 11 ---- .../com/tutpro/baresip/BaresipService.kt | 16 ++--- .../main/kotlin/com/tutpro/baresip/Config.kt | 6 -- .../main/kotlin/com/tutpro/baresip/Utils.kt | 2 +- app/src/main/res/values-fi/strings.xml | 3 - app/src/main/res/values/strings.xml | 3 - 7 files changed, 9 insertions(+), 92 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt index bc935784..8d16221f 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt @@ -175,7 +175,6 @@ private fun AudioContent(viewModel: AudioViewModel, contentPadding: PaddingValue AudioModules(viewModel) OpusBitRate(viewModel) OpusPacketLoss(viewModel) - IlbcMode(viewModel) AudioDelay(viewModel) } } @@ -500,65 +499,6 @@ private fun OpusPacketLoss(viewModel: AudioViewModel) { } } -@Composable -private fun IlbcMode(viewModel: AudioViewModel) { - Row( - Modifier.fillMaxWidth().padding(end = 10.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Start - ) { - val ilbcModeTitle = stringResource(R.string.ilbc_mode) - val ilbcModeHelp = stringResource(R.string.ilbc_mode_help) - Text( - text = ilbcModeTitle, - modifier = Modifier - .weight(1f) - .clickable { - alertTitle.value = ilbcModeTitle - alertMessage.value = ilbcModeHelp - showAlert.value = true - }, - fontSize = 18.sp - ) - val currentIlbcMode by viewModel.ilbcMode.collectAsState() - val isDropDownExpanded = remember { mutableStateOf(false) } - val modeNames = listOf("20ms", "30ms") - val modeValues = listOf("20", "30") - val itemPosition = modeValues.indexOf(currentIlbcMode).let { if (it != -1) it else 1 } - - Box { - Row( - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.clickable { isDropDownExpanded.value = true } - ) { - Text(text = modeNames[itemPosition]) - Icon( - imageVector = Icons.Filled.ArrowDropDown, - contentDescription = null, - modifier = Modifier.size(36.dp) - ) - } - DropdownMenu( - expanded = isDropDownExpanded.value, - onDismissRequest = { isDropDownExpanded.value = false } - ) { - modeNames.forEachIndexed { index, name -> - DropdownMenuItem( - text = { Text(text = name) }, - onClick = { - isDropDownExpanded.value = false - viewModel.ilbcMode.value = modeValues[index] - } - ) - if (index < modeNames.size - 1) - HorizontalDivider(thickness = 1.dp) - } - } - } - } -} - @Composable private fun AudioDelay(viewModel: AudioViewModel) { Row( diff --git a/app/src/main/kotlin/com/tutpro/baresip/AudioViewModel.kt b/app/src/main/kotlin/com/tutpro/baresip/AudioViewModel.kt index 280c0666..85a0ebc1 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AudioViewModel.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AudioViewModel.kt @@ -14,7 +14,6 @@ class AudioViewModel : ViewModel() { val audioModules = MutableStateFlow(mutableMapOf()) val opusBitrate = MutableStateFlow("") val opusPacketLoss = MutableStateFlow("") - val ilbcMode = MutableStateFlow("") val audioDelay = MutableStateFlow("") val toneCountry = MutableStateFlow("") val ringtoneUri = MutableStateFlow("") @@ -26,7 +25,6 @@ class AudioViewModel : ViewModel() { var oldAudioModules = ArrayList() var oldOpusBitrate = "" var oldOpusPacketLoss = "" - var oldIlbcMode = "" var oldAudioDelay = "" var oldToneCountry = "" var oldRingtoneUri = "" @@ -58,9 +56,6 @@ class AudioViewModel : ViewModel() { oldOpusPacketLoss = Config.variable("opus_packet_loss") opusPacketLoss.value = oldOpusPacketLoss - oldIlbcMode = Config.variable("ilbc_mode") - ilbcMode.value = oldIlbcMode - oldAudioDelay = Config.variable("audio_delay") if (oldAudioDelay == "") oldAudioDelay = BaresipService.audioDelay.toString() audioDelay.value = oldAudioDelay @@ -153,12 +148,6 @@ class AudioViewModel : ViewModel() { save = true } - if (ilbcMode.value != oldIlbcMode) { - Config.replaceVariable("ilbc_mode", ilbcMode.value) - restart = true - save = true - } - val delay = audioDelay.value.trim() if (delay != oldAudioDelay) { if (!checkAudioDelay(delay)) return Result.ERROR diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index cffa176d..804a7f87 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -559,19 +559,19 @@ class BaresipService: Service() { file = File("${filesPath}/$a") if (!file.exists() && a != "config") { Log.i(TAG, "Copying asset '$a'") - Utils.copyAssetToFile(this, a, "$filesPath/$a") + Utils.copyAssetToFile(applicationContext, a, "$filesPath/$a") } else Log.i(TAG, "Asset '$a' already copied") if (a == "config") - Config.initialize(this) + Config.initialize(applicationContext) } Thread { if (contactsMode != "android") Contact.restoreBaresipContacts() if (contactsMode != "baresip") { - Contact.loadAndroidContacts(this) + Contact.loadAndroidContacts(applicationContext) registerAndroidContactsObserver() } Contact.contactsUpdate() @@ -1125,7 +1125,7 @@ class BaresipService: Service() { } else { val name = "callwaiting_$toneCountry" - val resourceId = resources.getIdentifier( + val resourceId = applicationContext.resources.getIdentifier( name, "raw", packageName @@ -2727,7 +2727,7 @@ class BaresipService: Service() { private fun playRingBack() { if (mediaPlayer == null) { val name = "ringback_$toneCountry" - val resourceId = resources.getIdentifier(name, "raw", packageName) + val resourceId = applicationContext.resources.getIdentifier(name, "raw", packageName) if (resourceId != 0) { val audioAttributes = AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) @@ -2735,7 +2735,7 @@ class BaresipService: Service() { .build() mediaPlayer = MediaPlayer().apply { setAudioAttributes(audioAttributes) - val afd = resources.openRawResourceFd(resourceId) + val afd = applicationContext.resources.openRawResourceFd(resourceId) setDataSource(afd.fileDescriptor, afd.startOffset, afd.length) afd.close() isLooping = true @@ -2752,7 +2752,7 @@ class BaresipService: Service() { private fun playBusy() { if (mediaPlayer == null) { val name = "busy_$toneCountry" - val resourceId = resources.getIdentifier(name, "raw", packageName) + val resourceId = applicationContext.resources.getIdentifier(name, "raw", packageName) if (resourceId != 0) { val audioAttributes = AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) @@ -2760,7 +2760,7 @@ class BaresipService: Service() { .build() mediaPlayer = MediaPlayer().apply { setAudioAttributes(audioAttributes) - val afd = resources.openRawResourceFd(resourceId) + val afd = applicationContext.resources.openRawResourceFd(resourceId) setDataSource(afd.fileDescriptor, afd.startOffset, afd.length) afd.close() setOnCompletionListener { diff --git a/app/src/main/kotlin/com/tutpro/baresip/Config.kt b/app/src/main/kotlin/com/tutpro/baresip/Config.kt index 5fb89fd3..cf61c927 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Config.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Config.kt @@ -237,12 +237,6 @@ object Config { else "${config}opus_packet_loss $opusPacketLoss\n" - val ilbcMode = previousVariable("ilbc_mode") - config = if (ilbcMode == "") - "${config}ilbc_mode 30\n" - else - "${config}ilbc_mode $ilbcMode\n" - val audioDelay = previousVariable("audio_delay") if (audioDelay != "") { config = "${config}audio_delay $audioDelay\n" diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt index 6582aea8..af0bc1ca 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt @@ -566,7 +566,7 @@ object Utils { fun copyAssetToFile(context: Context, asset: String, path: String) { try { - context.assets.open(asset).use { `is` -> + context.applicationContext.assets.open(asset).use { `is` -> FileOutputStream(path).use { os -> val buffer = ByteArray(512) var byteRead: Int = `is`.read(buffer) diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 0be8ac9d..110aefa2 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -450,9 +450,6 @@ Audion odotusviive (millisekunneissa) soitetun puhelun alkaessa. Aseta korkeampi arvo, jos et kuule vastaajan ääntä heti, kun puhelu alkaa. Virheellinen audioviive \'%1$s\'. Sallittu arvo on välillä 100–3000. - iLBC-moodi - Valitsee iLBC-koodekin kehyksen keston. - 30ms tarjoaa paremman äänenlaadun alhaisilla bittinopeuksilla, kun taas 20ms:ssä on pienempi viive. Oletus äänen voimakkuus Jos valittu, puhelun äänen voimakkuus asteikolla 1–10. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d2aae6af..ba997d7c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -429,9 +429,6 @@ Time (in milliseconds) to wait audio from callee when call is established. Set to a higher value if you miss audio from callee at the beginning of the call. Invalid Audio Delay \'%1$s\'. Valid values are from 100 to 3000. - iLBC Mode - Selects the default iLBC frame duration. - 30ms provides better low-bitrate quality, while 20ms has lower latency. Default Call Volume If set, default call audio volume at scale 1–10. Tone Country