Removed iLBC Mode audio setting

This commit is contained in:
Juha Heinanen
2026-08-16 18:36:28 +03:00
parent 6f2734df0f
commit 74d82c08e2
7 changed files with 9 additions and 92 deletions

View File

@ -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(

View File

@ -14,7 +14,6 @@ class AudioViewModel : ViewModel() {
val audioModules = MutableStateFlow(mutableMapOf<String, Boolean>())
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<String>()
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

View File

@ -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 {

View File

@ -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"

View File

@ -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)

View File

@ -450,9 +450,6 @@
<string name="audio_delay_help">Audion odotusviive (millisekunneissa) soitetun puhelun alkaessa.
Aseta korkeampi arvo, jos et kuule vastaajan ääntä heti, kun puhelu alkaa.</string>
<string name="invalid_audio_delay">Virheellinen audioviive \'%1$s\'. Sallittu arvo on välillä 1003000.</string>
<string name="ilbc_mode">iLBC-moodi</string>
<string name="ilbc_mode_help">Valitsee iLBC-koodekin kehyksen keston.
30ms tarjoaa paremman äänenlaadun alhaisilla bittinopeuksilla, kun taas 20ms:ssä on pienempi viive.</string>
<string name="default_call_volume">Oletus äänen voimakkuus</string>
<string name="default_call_volume_help">Jos valittu, puhelun äänen voimakkuus
asteikolla 110.</string>

View File

@ -429,9 +429,6 @@
<string name="audio_delay_help">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.</string>
<string name="invalid_audio_delay">Invalid Audio Delay \'%1$s\'. Valid values are from 100 to 3000.</string>
<string name="ilbc_mode">iLBC Mode</string>
<string name="ilbc_mode_help">Selects the default iLBC frame duration.
30ms provides better low-bitrate quality, while 20ms has lower latency.</string>
<string name="default_call_volume">Default Call Volume</string>
<string name="default_call_volume_help">If set, default call audio volume at scale 110.</string>
<string name="tone_country">Tone Country</string>