Improve audio source debug log descriptions
This commit is contained in:
parent
2d48da8a6d
commit
50427668a3
@ -7,7 +7,7 @@ import Foundation
|
||||
import AVFoundation
|
||||
import SignalServiceKit
|
||||
|
||||
public struct AudioSource: Hashable {
|
||||
public struct AudioSource: Hashable, CustomDebugStringConvertible {
|
||||
|
||||
public let localizedName: String
|
||||
public let portDescription: AVAudioSessionPortDescription?
|
||||
@ -82,4 +82,22 @@ public struct AudioSource: Hashable {
|
||||
|
||||
hasher.combine(portDescription.uid)
|
||||
}
|
||||
|
||||
public var debugDescription: String {
|
||||
guard let portDescription = self.portDescription else {
|
||||
assert(self.isBuiltInSpeaker)
|
||||
return "<built-in speaker>"
|
||||
}
|
||||
return portDescription.logSafeDescription
|
||||
}
|
||||
}
|
||||
|
||||
extension AVAudioSessionPortDescription {
|
||||
var logSafeDescription: String {
|
||||
let portName = self.portName
|
||||
if portName.dropFirst(4).isEmpty {
|
||||
return "<\(portType): \(portName)>"
|
||||
}
|
||||
return "<\(portType): \(portName.prefix(2))..\(portName.suffix(2))>"
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ class CallAudioService: NSObject, CallObserver {
|
||||
return [AudioSource.builtInSpeaker]
|
||||
}
|
||||
|
||||
Logger.info("availableInputs: \(availableInputs)")
|
||||
Logger.info("availableInputs: \(availableInputs.map(\.logSafeDescription))")
|
||||
return [AudioSource.builtInSpeaker] + availableInputs.map { portDescription in
|
||||
return AudioSource(portDescription: portDescription)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user