#4094 - Various tweaks, bug fixes and improvements following code review.

This commit is contained in:
Stefan Ceriu
2021-06-23 15:37:34 +03:00
parent 27fbed011e
commit 1000736265
40 changed files with 158 additions and 156 deletions
@@ -17,8 +17,6 @@
import Foundation
import AVFoundation
private let silenceThreshold: Float = -50.0
protocol VoiceMessageAudioRecorderDelegate: AnyObject {
func audioRecorderDidStartRecording(_ audioRecorder: VoiceMessageAudioRecorder)
func audioRecorderDidFinishRecording(_ audioRecorder: VoiceMessageAudioRecorder)
@@ -31,6 +29,10 @@ enum VoiceMessageAudioRecorderError: Error {
class VoiceMessageAudioRecorder: NSObject, AVAudioRecorderDelegate {
private enum Constants {
static let silenceThreshold: Float = -50.0
}
private var audioRecorder: AVAudioRecorder?
var url: URL? {
@@ -105,7 +107,7 @@ class VoiceMessageAudioRecorder: NSObject, AVAudioRecorderDelegate {
}
private func normalizedPowerLevelFromDecibels(_ decibels: Float) -> Float {
return decibels / silenceThreshold
return decibels / Constants.silenceThreshold
}
}