Allow use of software echo canceller even when hardware one would be available
This commit is contained in:
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -365,11 +365,9 @@
|
||||
</string>
|
||||
<string name="failed_to_load_module">Modulin lataaminen epäonnistui.</string>
|
||||
<string name="aec">Akustinen kaiun poisto (AKP)</string>
|
||||
<string name="aec_help">Jos merkitty, kaikua yritetään poistaa puheluiden aikana.</string>
|
||||
<string name="aec_help">Jos merkitty, kaikua yritetään poistaa ohjelmiston avulla
|
||||
puheluiden aikana.</string>
|
||||
<string name="aec_extended_filter">AKP laajennettu suodatin</string>
|
||||
<string name="aec_extended_filter_help">Jos merkitty, kaiun poistossa käytetään laajennettua
|
||||
suodatinta.
|
||||
</string>
|
||||
<string name="microphone_gain">Mikrofonin äänikerroin</string>
|
||||
<string name="microphone_gain_help">Kertoo mikrofonin äänen voimakkuuden tällä desimaaliluvulla.
|
||||
Minimikerroin on 1.0 (tehdasasetus), mikä ei muuta mikrofonin äänen voimakkuutta. Suuremmat
|
||||
|
||||
@ -340,7 +340,7 @@
|
||||
available for use by the accounts.</string>
|
||||
<string name="failed_to_load_module">Failed to load module.</string>
|
||||
<string name="aec">Acoustic Echo Cancellation</string>
|
||||
<string name="aec_help">If checked, echo cancellation is attempted on call audio.</string>
|
||||
<string name="aec_help">If checked, software echo cancellation is attempted on call audio.</string>
|
||||
<string name="aec_extended_filter">AEC Extended Filter</string>
|
||||
<string name="aec_extended_filter_help">If checked, echo cancellation is using extended filter.</string>
|
||||
<string name="microphone_gain">Microphone Gain</string>
|
||||
|
||||
Reference in New Issue
Block a user