Address review comments, fix quality check issues.

This commit is contained in:
Jorge Martín 2022-06-07 17:14:22 +02:00
parent 155842f8bc
commit 2fbec133b6
2 changed files with 6 additions and 11 deletions

View file

@ -20,9 +20,9 @@ package im.vector.opusencoder.configuration
* Sampling rate of the input signal in Hz. * Sampling rate of the input signal in Hz.
*/ */
sealed class SampleRate private constructor(val value: Int) { sealed class SampleRate private constructor(val value: Int) {
object _8khz : SampleRate(8000) object Rate8khz : SampleRate(8000)
object _12kHz : SampleRate(12000) object Rate12kHz : SampleRate(12000)
object _16kHz : SampleRate(16000) object Rate16kHz : SampleRate(16000)
object _24KHz : SampleRate(24000) object Rate24KHz : SampleRate(24000)
object _48kHz : SampleRate(48000) object Rate48kHz : SampleRate(48000)
} }

View file

@ -27,7 +27,6 @@ import im.vector.opusencoder.OggOpusEncoder
import im.vector.opusencoder.configuration.SampleRate import im.vector.opusencoder.configuration.SampleRate
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
@ -46,7 +45,7 @@ class VoiceRecorderL(
) : VoiceRecorder { ) : VoiceRecorder {
companion object { companion object {
private val SAMPLE_RATE = SampleRate._48kHz private val SAMPLE_RATE = SampleRate.Rate48kHz
private const val BITRATE = 24 * 1024 private const val BITRATE = 24 * 1024
} }
@ -101,10 +100,6 @@ class VoiceRecorderL(
initializeCodec(outputFile.absolutePath) initializeCodec(outputFile.absolutePath)
recordingJob = recorderScope.launch { recordingJob = recorderScope.launch {
while (audioRecorder?.state != AudioRecord.STATE_INITIALIZED) {
// If the recorder is not ready let's give it some extra time
delay(10L)
}
audioRecorder?.startRecording() audioRecorder?.startRecording()
val buffer = ShortArray(bufferSizeInShorts) val buffer = ShortArray(bufferSizeInShorts)