More audio manager/bluetooth related fixes and improvements.
This commit is contained in:
@@ -195,6 +195,9 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
|||||||
//}
|
//}
|
||||||
len = re_snprintf(event_buf, sizeof event_buf, "%s", "call incoming");
|
len = re_snprintf(event_buf, sizeof event_buf, "%s", "call incoming");
|
||||||
break;
|
break;
|
||||||
|
case UA_EVENT_CALL_OUTGOING:
|
||||||
|
len = re_snprintf(event_buf, sizeof event_buf, "%s", "call outgoing");
|
||||||
|
break;
|
||||||
case UA_EVENT_CALL_LOCAL_SDP:
|
case UA_EVENT_CALL_LOCAL_SDP:
|
||||||
len = re_snprintf(event_buf, sizeof event_buf, "call %sed", prm);
|
len = re_snprintf(event_buf, sizeof event_buf, "call %sed", prm);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -68,9 +68,6 @@ class BaresipService: Service() {
|
|||||||
filesPath = filesDir.absolutePath
|
filesPath = filesDir.absolutePath
|
||||||
|
|
||||||
am = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
am = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
// Hack to avoid playback delay when outgoing call is established
|
|
||||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
|
||||||
|
|
||||||
val rtUri = RingtoneManager.getActualDefaultRingtoneUri(applicationContext,
|
val rtUri = RingtoneManager.getActualDefaultRingtoneUri(applicationContext,
|
||||||
RingtoneManager.TYPE_RINGTONE)
|
RingtoneManager.TYPE_RINGTONE)
|
||||||
rt = RingtoneManager.getRingtone(applicationContext, rtUri)
|
rt = RingtoneManager.getRingtone(applicationContext, rtUri)
|
||||||
@@ -509,11 +506,8 @@ class BaresipService: Service() {
|
|||||||
if (!Utils.isVisible())
|
if (!Utils.isVisible())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
"call offered" -> {
|
|
||||||
proximitySensing(true)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
"call progress", "call ringing" -> {
|
"call progress", "call ringing" -> {
|
||||||
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
||||||
AudioAttributes.CONTENT_TYPE_SPEECH)
|
AudioAttributes.CONTENT_TYPE_SPEECH)
|
||||||
setCallVolume()
|
setCallVolume()
|
||||||
@@ -605,8 +599,20 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"call outgoing" -> {
|
||||||
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
|
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
||||||
|
AudioAttributes.CONTENT_TYPE_SPEECH)
|
||||||
|
setCallVolume()
|
||||||
|
proximitySensing(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
"call answered" -> {
|
"call answered" -> {
|
||||||
stopRinging()
|
stopRinging()
|
||||||
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
|
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
||||||
|
AudioAttributes.CONTENT_TYPE_SPEECH)
|
||||||
|
setCallVolume()
|
||||||
proximitySensing(true)
|
proximitySensing(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -625,9 +631,6 @@ class BaresipService: Service() {
|
|||||||
CallHistory.save()
|
CallHistory.save()
|
||||||
call.hasHistory = true
|
call.hasHistory = true
|
||||||
}
|
}
|
||||||
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
|
||||||
AudioAttributes.CONTENT_TYPE_SPEECH)
|
|
||||||
setCallVolume()
|
|
||||||
if (!Utils.isVisible())
|
if (!Utils.isVisible())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -714,6 +717,7 @@ class BaresipService: Service() {
|
|||||||
} else {
|
} else {
|
||||||
abandonAudioFocus()
|
abandonAudioFocus()
|
||||||
}
|
}
|
||||||
|
am.mode = AudioManager.MODE_NORMAL
|
||||||
proximitySensing(false)
|
proximitySensing(false)
|
||||||
}
|
}
|
||||||
if (ua.account.callHistory && !call.hasHistory) {
|
if (ua.account.callHistory && !call.hasHistory) {
|
||||||
@@ -967,7 +971,7 @@ class BaresipService: Service() {
|
|||||||
Log.d(TAG, "Audio focus granted for usage $usage")
|
Log.d(TAG, "Audio focus granted for usage $usage")
|
||||||
audioFocusUsage = usage
|
audioFocusUsage = usage
|
||||||
if (isBluetoothHeadsetConnected() && !am.isBluetoothScoOn) {
|
if (isBluetoothHeadsetConnected() && !am.isBluetoothScoOn) {
|
||||||
Log.d(TAG, "Starting Bluetooth Sco")
|
Log.d(TAG, "Starting Bluetooth SCO")
|
||||||
am.startBluetoothSco()
|
am.startBluetoothSco()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1053,7 +1057,6 @@ class BaresipService: Service() {
|
|||||||
rtTimer = null
|
rtTimer = null
|
||||||
}
|
}
|
||||||
rt.stop()
|
rt.stop()
|
||||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1162,6 +1165,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun cleanService() {
|
private fun cleanService() {
|
||||||
|
am.mode = AudioManager.MODE_NORMAL
|
||||||
abandonAudioFocus()
|
abandonAudioFocus()
|
||||||
uas.clear()
|
uas.clear()
|
||||||
status.clear()
|
status.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user