diff --git a/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt
index 26ece40c..396895b9 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt
@@ -148,13 +148,9 @@ class AudioActivity : AppCompatActivity() {
oldOpusPacketLoss = Config.variable("opus_packet_loss")
opusPacketLoss.setText(oldOpusPacketLoss)
- if (!BaresipService.aecAvailable) {
- aec = binding.Aec
- oldAec = modules.contains("webrtc_aecm.so")
- aec.isChecked = oldAec
- } else {
- binding.AecLayout.visibility = View.GONE
- }
+ aec = binding.Aec
+ oldAec = modules.contains("webrtc_aecm.so")
+ aec.isChecked = oldAec
audioDelay = binding.AudioDelay
audioDelay.setText("${BaresipService.audioDelay}")
@@ -301,28 +297,28 @@ class AudioActivity : AppCompatActivity() {
save = true
}
- if (!BaresipService.aecAvailable) {
- if (aec.isChecked != oldAec) {
- if (aec.isChecked) {
- Config.addVariable("module", "webrtc_aecm.so")
- if (gain != "1.0") {
- restart = true
- } else {
- if (Api.module_load("webrtc_aecm.so") != 0) {
- Utils.alertView(
- this, getString(R.string.error),
- getString(R.string.failed_to_load_module)
- )
- aec.isChecked = false
- return false
- }
- }
+ if (aec.isChecked != oldAec) {
+ if (aec.isChecked) {
+ Config.addVariable("module", "webrtc_aecm.so")
+ if (gain != "1.0") {
+ restart = true
} else {
- Api.module_unload("webrtc_aecm.so")
- Config.removeVariableValue("module", "webrtc_aecm.so")
+ if (Api.module_load("webrtc_aecm.so") != 0) {
+ Utils.alertView(
+ this, getString(R.string.error),
+ getString(R.string.failed_to_load_module)
+ )
+ aec.isChecked = false
+ return false
+ }
}
- save = true
+ BaresipService.webrtcAec = true
+ } else {
+ Api.module_unload("webrtc_aecm.so")
+ Config.removeVariableValue("module", "webrtc_aecm.so")
+ BaresipService.webrtcAec = false
}
+ save = true
}
val audioDelay = audioDelay.text.toString().trim()
diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt
index 81e4dd68..7162d2c8 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt
@@ -73,7 +73,6 @@ class BaresipService: Service() {
private lateinit var bluetoothReceiver: BroadcastReceiver
private lateinit var hotSpotReceiver: BroadcastReceiver
private lateinit var androidContactsObserver: ContentObserver
-
private lateinit var stopState: String
private lateinit var quitTimer: CountDownTimer
@@ -835,31 +834,14 @@ class BaresipService: Service() {
if (am.mode != MODE_IN_COMMUNICATION)
am.mode = MODE_IN_COMMUNICATION
call!!.status = "connected"
- if (playerSessionId != 0) {
- if (aecAvailable) {
- val aec = AcousticEchoCanceler.create(playerSessionId)
- if (aec != null) {
- if (!aec.getEnabled()) {
- aec.setEnabled(true)
- if (aec.getEnabled())
- Log.d(TAG, "aec is enabled")
- else
- Log.w(TAG, "Failed to enable AEC")
- }
- }
- else
- Log.w(TAG, "Failed to create AEC")
- }
- playerSessionId = 0
- }
if (recorderSessionId != 0) {
- if (aecAvailable) {
- val aec = AcousticEchoCanceler.create(recorderSessionId)
+ if (aecAvailable && !webrtcAec) {
+ aec = AcousticEchoCanceler.create(recorderSessionId)
if (aec != null) {
- if (!aec.getEnabled()) {
- aec.setEnabled(true)
- if (aec.getEnabled())
- Log.d(TAG, "aec is enabled")
+ if (!aec!!.getEnabled()) {
+ aec!!.setEnabled(true)
+ if (aec!!.getEnabled())
+ Log.d(TAG, "AEC is enabled")
else
Log.w(TAG, "Failed to enable AEC")
}
@@ -868,23 +850,28 @@ class BaresipService: Service() {
Log.w(TAG, "Failed to create AEC")
}
if (agcAvailable) {
- val agc = AutomaticGainControl.create(recorderSessionId)
- if (agc != null)
- if (!agc.getEnabled()) {
- agc.setEnabled(true)
- if (agc.getEnabled())
- Log.d(TAG, "agc is enabled")
+ agc = AutomaticGainControl.create(recorderSessionId)
+ if (agc != null) {
+ if (!agc!!.getEnabled()) {
+ agc!!.setEnabled(true)
+ if (agc!!.getEnabled())
+ Log.d(TAG, "AGC is enabled")
}
+ }
+ else
+ Log.w(TAG, "Failed to create AGC")
}
if (nsAvailable) {
- val ns = NoiseSuppressor.create(recorderSessionId)
+ ns = NoiseSuppressor.create(recorderSessionId)
if (ns != null) {
- if (!ns.getEnabled()) {
- ns.setEnabled(true)
- if (ns.getEnabled())
+ if (!ns!!.getEnabled()) {
+ ns!!.setEnabled(true)
+ if (ns!!.getEnabled())
Log.d(TAG, "ns is enabled")
}
}
+ else
+ Log.w(TAG, "Failed to create NS")
}
recorderSessionId = 0
}
@@ -970,6 +957,9 @@ class BaresipService: Service() {
nm.cancel(CALL_NOTIFICATION_ID)
stopRinging()
stopMediaPlayer()
+ aec?.release()
+ agc?.release()
+ ns?.release()
val newCall = call.newCall
if (newCall != null) {
newCall.onHoldCall = null
@@ -1631,6 +1621,10 @@ class BaresipService: Service() {
var aecAvailable = AcousticEchoCanceler.isAvailable()
var agcAvailable = AutomaticGainControl.isAvailable()
private val nsAvailable = NoiseSuppressor.isAvailable()
+ private var aec: AcousticEchoCanceler? = null
+ private var ns: NoiseSuppressor? = null
+ private var agc: AutomaticGainControl? = null
+ var webrtcAec = false
private var btAdapter: BluetoothAdapter? = null
private var playerSessionId = 0
private var recorderSessionId = 0
diff --git a/app/src/main/kotlin/com/tutpro/baresip/Config.kt b/app/src/main/kotlin/com/tutpro/baresip/Config.kt
index 1bd684c2..c0b71aef 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/Config.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/Config.kt
@@ -20,8 +20,6 @@ object Config {
if (!File(configPath).exists()) {
for (module in AudioActivity.audioModules)
config = "${config}module ${module}.so\n"
- if (!BaresipService.aecAvailable)
- config = "${config}module webrtc_aecm.so\n"
previousConfig = config
} else {
previousConfig = String(Utils.getFileContents(configPath)!!, StandardCharsets.ISO_8859_1)
@@ -155,8 +153,10 @@ object Config {
if ("${module}.so" in previousModules)
config = "${config}module ${module}.so\n"
- if (!BaresipService.aecAvailable && "webrtc_aecm.so" in previousModules)
+ if ("webrtc_aecm.so" in previousModules || !File(configPath).exists()) {
config = "${config}module webrtc_aecm.so\n"
+ BaresipService.webrtcAec = true
+ }
val micGain = previousVariable("augain")
config = if (BaresipService.agcAvailable || micGain == "" || micGain == "1.0")
diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml
index f8621621..914c7a5b 100644
--- a/app/src/main/res/values-fi/strings.xml
+++ b/app/src/main/res/values-fi/strings.xml
@@ -365,11 +365,9 @@
Modulin lataaminen epäonnistui.
Akustinen kaiun poisto (AKP)
- Jos merkitty, kaikua yritetään poistaa puheluiden aikana.
+ Jos merkitty, kaikua yritetään poistaa ohjelmiston avulla
+ puheluiden aikana.
AKP laajennettu suodatin
- Jos merkitty, kaiun poistossa käytetään laajennettua
- suodatinta.
-
Mikrofonin äänikerroin
Kertoo mikrofonin äänen voimakkuuden tällä desimaaliluvulla.
Minimikerroin on 1.0 (tehdasasetus), mikä ei muuta mikrofonin äänen voimakkuutta. Suuremmat
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 988b758e..9df0738f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -340,7 +340,7 @@
available for use by the accounts.
Failed to load module.
Acoustic Echo Cancellation
- If checked, echo cancellation is attempted on call audio.
+ If checked, software echo cancellation is attempted on call audio.
AEC Extended Filter
If checked, echo cancellation is using extended filter.
Microphone Gain