Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #235 from SuhasDissa/opus
Browse files Browse the repository at this point in the history
avoid using custom sample rate for OPUS
  • Loading branch information
SuhasDissa authored Dec 18, 2023
2 parents 1f9b1dc + 296c221 commit d9f8d22
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bnyro.recorder.services

import android.media.MediaRecorder
import android.widget.Toast
import com.bnyro.recorder.App
import com.bnyro.recorder.R
Expand All @@ -23,15 +24,17 @@ class AudioRecorderService : RecorderService() {
).let {
setAudioSource(it)
}

Preferences.prefs.getInt(Preferences.audioSampleRateKey, -1).takeIf { it > 0 }?.let {
setAudioSamplingRate(it)
setAudioEncodingBitRate(it * 32 * 2)
if (audioFormat.codec != MediaRecorder.AudioEncoder.OPUS) {
Preferences.prefs.getInt(Preferences.audioSampleRateKey, -1).takeIf { it > 0 }
?.let {
setAudioSamplingRate(it)
setAudioEncodingBitRate(it * 32 * 2)
}
Preferences.prefs.getInt(Preferences.audioBitrateKey, -1).takeIf { it > 0 }?.let {
setAudioEncodingBitRate(it)
}
}

Preferences.prefs.getInt(Preferences.audioBitrateKey, -1).takeIf { it > 0 }?.let {
setAudioEncodingBitRate(it)
}
Preferences.prefs.getInt(Preferences.audioChannelsKey, AudioChannels.MONO.value).let {
setAudioChannels(it)
}
Expand All @@ -43,7 +46,11 @@ class AudioRecorderService : RecorderService() {
audioFormat.extension
)
if (outputFile == null) {
Toast.makeText(this@AudioRecorderService, R.string.cant_access_selected_folder, Toast.LENGTH_LONG).show()
Toast.makeText(
this@AudioRecorderService,
R.string.cant_access_selected_folder,
Toast.LENGTH_LONG
).show()
onDestroy()
return
}
Expand Down

0 comments on commit d9f8d22

Please sign in to comment.