Run SwiftFormat.

This commit is contained in:
Doug
2026-05-27 14:38:50 +01:00
committed by Doug
parent 5138e05e47
commit fa67713726
573 changed files with 2426 additions and 2426 deletions
@@ -49,7 +49,7 @@ class AudioPlayer: NSObject, AudioPlayerProtocol {
private(set) var playbackURL: URL?
private(set) var playbackSpeed: Float = 1.0
private var deinitInProgress = false
var duration: TimeInterval {
@@ -129,14 +129,14 @@ class AudioPlayer: NSObject, AudioPlayerProtocol {
let time = progress * duration
await internalAudioPlayer.seek(to: CMTime(seconds: time, preferredTimescale: 60))
}
func setPlaybackSpeed(_ speed: Float) {
playbackSpeed = speed
if state == .playing {
internalAudioPlayer?.rate = speed
}
}
// MARK: - Private
private func setupAudioSession() {
@@ -178,7 +178,7 @@ class AudioPlayer: NSObject, AudioPlayerProtocol {
playerItem = nil
removeObservers()
}
private func addObservers() {
guard let internalAudioPlayer, let playerItem else {
return
@@ -197,7 +197,7 @@ class AudioPlayer: NSObject, AudioPlayerProtocol {
break
}
}
rateObserver = internalAudioPlayer.observe(\.rate, options: [.old, .new]) { [weak self] _, _ in
guard let self else { return }
@@ -211,7 +211,7 @@ class AudioPlayer: NSObject, AudioPlayerProtocol {
setInternalState(.playing)
}
}
NotificationCenter.default.publisher(for: Notification.Name.AVPlayerItemDidPlayToEndTime)
.sink { [weak self] _ in
guard let self else { return }
@@ -50,7 +50,7 @@ class AudioPlayerState: ObservableObject, Identifiable {
var showProgressIndicator: Bool {
progress > 0
}
var isAttached: Bool {
audioPlayer != nil
}
@@ -124,7 +124,7 @@ class AudioPlayerState: ObservableObject, Identifiable {
playbackSpeed = speed
audioPlayer?.setPlaybackSpeed(speed.rawValue)
}
// MARK: - Private
private func subscribeToAudioPlayer(audioPlayer: AudioPlayerProtocol) {
@@ -246,7 +246,7 @@ class AudioPlayerState: ObservableObject, Identifiable {
}
audioPlayer.pause()
return MPRemoteCommandHandlerStatus.success
}
@@ -37,7 +37,7 @@ class AudioRecorder: AudioRecorderProtocol {
private let maximumRecordingTime: TimeInterval = 1800 // 30 minutes
private let silenceThreshold: Float = -50.0
private var meterLevel: Float = 0
private(set) var audioFileURL: URL?
var currentTime: TimeInterval = .zero
var isRecording: Bool {
@@ -94,7 +94,7 @@ class AudioRecorder: AudioRecorderProtocol {
}
}
}
func averagePower() -> Float {
meterLevel
}
@@ -161,7 +161,7 @@ class AudioRecorder: AudioRecorderProtocol {
// Initialize a new audio engine
let audioEngine = AVAudioEngine()
self.audioEngine = audioEngine
let inputNode = audioEngine.inputNode
let inputFormat = inputNode.outputFormat(forBus: 0)
let hardwareSampleRate = audioEngine.inputNode.outputFormat(forBus: 0).sampleRate
@@ -204,12 +204,12 @@ class AudioRecorder: AudioRecorderProtocol {
} else {
audioConverter = nil
}
// Install tap to process audio buffers coming from the mixer
mixer.installTap(onBus: 0, bufferSize: 1024, format: mixerFormat) { [weak self] buffer, _ in
self?.processAudioBuffer(buffer)
}
do {
try audioEngine.start()
completion(.success(()))
@@ -304,7 +304,7 @@ class AudioRecorder: AudioRecorderProtocol {
// Write the buffer into the audio file
do {
try audioFile.write(from: inputBuffer)
// Compute the sample value for the waveform
updateMeterLevel(inputBuffer)
@@ -366,10 +366,10 @@ class AudioRecorder: AudioRecorderProtocol {
setInternalState(.suspended)
case .ended:
MXLog.info("Interruption ended: \(notification)")
guard let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt else { return }
let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue)
if options.contains(.shouldResume) {
do {
try audioEngine?.start()
@@ -413,7 +413,7 @@ class AudioRecorder: AudioRecorderProtocol {
actionsSubject.send(.didStopRecording)
case .error(let error):
cleanupAudioEngine()
actionsSubject.send(.didFailWithError(error: error))
}
}