mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Do not wait for state event feedback for pause/stop actions on the recorder
This commit is contained in:
parent
3ebcd8c1f4
commit
023326a20d
3 changed files with 14 additions and 2 deletions
|
@ -97,6 +97,7 @@ class VoiceBroadcastRecorderQ(
|
|||
}
|
||||
|
||||
override fun pauseRecord() {
|
||||
if (recordingState != VoiceBroadcastRecorder.State.Recording) return
|
||||
tryOrNull { mediaRecorder?.stop() }
|
||||
mediaRecorder?.reset()
|
||||
recordingState = VoiceBroadcastRecorder.State.Paused
|
||||
|
@ -105,6 +106,7 @@ class VoiceBroadcastRecorderQ(
|
|||
}
|
||||
|
||||
override fun resumeRecord() {
|
||||
if (recordingState != VoiceBroadcastRecorder.State.Paused) return
|
||||
currentSequence++
|
||||
currentVoiceBroadcast?.let { startRecord(it.roomId) }
|
||||
recordingState = VoiceBroadcastRecorder.State.Recording
|
||||
|
|
|
@ -53,6 +53,10 @@ class PauseVoiceBroadcastUseCase @Inject constructor(
|
|||
|
||||
private suspend fun pauseVoiceBroadcast(room: Room, reference: RelationDefaultContent?) {
|
||||
Timber.d("## PauseVoiceBroadcastUseCase: Send new voice broadcast info state event")
|
||||
|
||||
// immediately pause the recording
|
||||
pauseRecording()
|
||||
|
||||
room.stateService().sendStateEvent(
|
||||
eventType = VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO,
|
||||
stateKey = session.myUserId,
|
||||
|
@ -63,4 +67,8 @@ class PauseVoiceBroadcastUseCase @Inject constructor(
|
|||
).toContent(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun pauseRecording() {
|
||||
voiceBroadcastRecorder?.pauseRecord()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@ class StopVoiceBroadcastUseCase @Inject constructor(
|
|||
|
||||
private suspend fun stopVoiceBroadcast(room: Room, reference: RelationDefaultContent?) {
|
||||
Timber.d("## StopVoiceBroadcastUseCase: Send new voice broadcast info state event")
|
||||
|
||||
// Immediately stop the recording
|
||||
stopRecording()
|
||||
|
||||
room.stateService().sendStateEvent(
|
||||
eventType = VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO,
|
||||
stateKey = session.myUserId,
|
||||
|
@ -63,8 +67,6 @@ class StopVoiceBroadcastUseCase @Inject constructor(
|
|||
lastChunkSequence = voiceBroadcastRecorder?.currentSequence,
|
||||
).toContent(),
|
||||
)
|
||||
|
||||
stopRecording()
|
||||
}
|
||||
|
||||
private fun stopRecording() {
|
||||
|
|
Loading…
Reference in a new issue