When Default Call Volume is set, set both STREAM_MUSIC and STREAM_VOICE_CALL streams
This commit is contained in:
@@ -56,7 +56,7 @@ class BaresipService: Service() {
|
|||||||
private var rtTimer: Timer? = null
|
private var rtTimer: Timer? = null
|
||||||
private var audioFocusRequest: AudioFocusRequest? = null
|
private var audioFocusRequest: AudioFocusRequest? = null
|
||||||
private var audioFocusUsage = -1
|
private var audioFocusUsage = -1
|
||||||
private var origVolume = -1
|
private var origVolume = mutableMapOf<Int, Int>()
|
||||||
private val btAdapter = BluetoothAdapter.getDefaultAdapter()
|
private val btAdapter = BluetoothAdapter.getDefaultAdapter()
|
||||||
private var linkAddresses = mutableMapOf<String, String>()
|
private var linkAddresses = mutableMapOf<String, String>()
|
||||||
private var activeNetwork: Network? = null
|
private var activeNetwork: Network? = null
|
||||||
@@ -1134,23 +1134,26 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setCallVolume() {
|
private fun setCallVolume() {
|
||||||
if (callVolume != 0 && origVolume == -1) {
|
if (callVolume != 0 && origVolume.isEmpty()) {
|
||||||
val streamType = AudioManager.STREAM_VOICE_CALL
|
for (streamType in listOf(AudioManager.STREAM_MUSIC, AudioManager.STREAM_VOICE_CALL)) {
|
||||||
origVolume = am.getStreamVolume(streamType)
|
origVolume[streamType] = am.getStreamVolume(streamType)
|
||||||
am.setStreamVolume(streamType,
|
am.setStreamVolume(
|
||||||
|
streamType,
|
||||||
(callVolume * 0.1 * am.getStreamMaxVolume(streamType)).roundToInt(),
|
(callVolume * 0.1 * am.getStreamMaxVolume(streamType)).roundToInt(),
|
||||||
0)
|
0
|
||||||
Log.d(TAG, "Orig/new call volume is $origVolume/${am.getStreamVolume(streamType)}")
|
)
|
||||||
|
Log.d(TAG, "Orig/new $streamType volume is " +
|
||||||
|
"${origVolume[streamType]}/${am.getStreamVolume(streamType)}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resetCallVolume() {
|
private fun resetCallVolume() {
|
||||||
if (origVolume != -1) {
|
for ((streamType, streamVolume) in origVolume) {
|
||||||
val streamType = AudioManager.STREAM_VOICE_CALL
|
am.setStreamVolume(streamType, streamVolume, 0)
|
||||||
am.setStreamVolume(streamType, origVolume, 0)
|
Log.d(TAG, "Reset $streamType volume to ${am.getStreamVolume(streamType)}")
|
||||||
Log.d(TAG, "Reset volume to ${am.getStreamVolume(streamType)}")
|
|
||||||
origVolume = -1
|
|
||||||
}
|
}
|
||||||
|
origVolume.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("WakelockTimeout")
|
@SuppressLint("WakelockTimeout")
|
||||||
|
|||||||
Reference in New Issue
Block a user