Removing Dead Code part 1 (#2234)

This commit is contained in:
Mauro
2023-12-13 09:51:57 +01:00
committed by GitHub
parent 09b276d94b
commit d99d26fcdc
88 changed files with 115 additions and 477 deletions
@@ -24,10 +24,6 @@ protocol AudioSessionProtocol: AnyObject {
}
extension AudioSessionProtocol {
func setCategory(_ category: AVAudioSession.Category, mode: AVAudioSession.Mode) throws {
try setCategory(category, mode: mode, options: [])
}
func setActive(_ active: Bool) throws {
try setActive(active, options: [])
}
@@ -46,12 +46,13 @@ class AudioPlayer: NSObject, AudioPlayerProtocol {
private var statusObserver: NSKeyValueObservation?
private var rateObserver: NSKeyValueObservation?
private var playToEndObserver: NSObjectProtocol?
private var appBackgroundObserver: NSObjectProtocol?
private var autoplay = false
private let audioSession = AVAudioSession.sharedInstance()
// periphery:ignore - when set to nil is automatically cancelled
@CancellableTask private var releaseAudioSessionTask: Task<Void, Never>?
private let releaseAudioSessionTimeoutInterval = 5.0
private(set) var url: URL?
@@ -19,7 +19,6 @@ import Foundation
enum AudioPlayerError: Error {
case genericError
case loadFileError
}
enum AudioPlayerAction {
@@ -110,7 +110,7 @@ class AudioPlayerState: ObservableObject, Identifiable {
playbackState = .stopped
}
func reportError(_ error: Error) {
func reportError() {
playbackState = .error
}
@@ -167,6 +167,7 @@ class AudioPlayerState: ObservableObject, Identifiable {
displayLink?.add(to: .current, forMode: .common)
}
// periphery:ignore:parameters displayLink - required for objc selector
@objc private func updateProgress(displayLink: CADisplayLink) {
if let currentTime = audioPlayer?.currentTime, duration > 0 {
progress = currentTime / duration
@@ -343,9 +343,9 @@ class AudioRecorder: AudioRecorderProtocol {
.store(in: &cancellables)
NotificationCenter.default.publisher(for: Notification.Name.AVAudioEngineConfigurationChange)
.sink { [weak self] notification in
.sink { [weak self] _ in
guard let self else { return }
self.handleConfigurationChange(notification: notification)
self.handleConfigurationChange()
}
.store(in: &cancellables)
@@ -396,7 +396,7 @@ class AudioRecorder: AudioRecorderProtocol {
}
}
func handleConfigurationChange(notification: Notification) {
func handleConfigurationChange() {
guard let audioEngine else { return }
MXLog.warning("Configuration changed: \(audioEngine.inputNode.inputFormat(forBus: 0))")
if internalState != .suspended {
@@ -24,7 +24,6 @@ enum AudioRecorderError: Error, Equatable {
case audioFileCreationFailure
case interrupted
case recordingCancelled
case recordingFailed
case recordPermissionNotGranted
}
@@ -57,7 +57,7 @@ class AudioRecorderState: ObservableObject, Identifiable {
recordingState = .stopped
}
func reportError(_ error: Error) {
func reportError() {
recordingState = .error
}
@@ -98,6 +98,7 @@ class AudioRecorderState: ObservableObject, Identifiable {
displayLink?.add(to: .current, forMode: .common)
}
// periphery:ignore:parameters displayLink - required for objc selector
@objc private func publishUpdate(displayLink: CADisplayLink) {
if let currentTime = audioRecorder?.currentTime {
duration = currentTime