mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
refactor: Improve selectedDevice; Use own rememberState; Reset selectedDevice on stop
This commit is contained in:
parent
57424cc1d3
commit
a515d2b36c
@ -12,7 +12,7 @@ import android.os.Build
|
||||
import app.myzel394.alibi.ui.utils.MicrophoneInfo
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
class AudioRecorderService: IntervalRecorderService() {
|
||||
class AudioRecorderService : IntervalRecorderService() {
|
||||
var amplitudesAmount = 1000
|
||||
var selectedDevice: MicrophoneInfo? = null
|
||||
|
||||
@ -27,11 +27,11 @@ class AudioRecorderService: IntervalRecorderService() {
|
||||
val audioManger = getSystemService(AUDIO_SERVICE)!! as AudioManager
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
if (selectedDevice == null) {
|
||||
if (selectedDevice == null) {
|
||||
audioManger.clearCommunicationDevice()
|
||||
} else {
|
||||
audioManger.setCommunicationDevice(selectedDevice!!.deviceInfo)
|
||||
}
|
||||
} else {
|
||||
audioManger.setCommunicationDevice(selectedDevice!!.deviceInfo)
|
||||
}
|
||||
} else {
|
||||
if (selectedDevice == null) {
|
||||
audioManger.stopBluetoothSco()
|
||||
@ -104,6 +104,7 @@ class AudioRecorderService: IntervalRecorderService() {
|
||||
super.stop()
|
||||
|
||||
resetRecorder()
|
||||
selectedDevice = null
|
||||
}
|
||||
|
||||
override fun getAmplitudeAmount(): Int = amplitudesAmount
|
||||
|
@ -168,10 +168,13 @@ fun RecordingStatus(
|
||||
if (microphones.isNotEmpty()) {
|
||||
MicrophoneSelection(
|
||||
microphones = microphones,
|
||||
selectedMicrophone = audioRecorder.recorderService!!.selectedDevice,
|
||||
selectedMicrophone = audioRecorder.selectedDevice,
|
||||
onSelect = {
|
||||
audioRecorder.changeMicrophone(it)
|
||||
audioRecorder.recorderService!!.startNewCycle()
|
||||
|
||||
if (!audioRecorder.isPaused) {
|
||||
audioRecorder.recorderService!!.startNewCycle()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user