fix: use delivered system audio format

This commit is contained in:
2026-08-26 10:22:59 +02:00
parent aed34f6d28
commit 4e8fdc7603
3 changed files with 60 additions and 7 deletions
+14 -2
View File
@@ -248,8 +248,20 @@ final class ProcessTap {
do {
logger.debug("Attempting to read audio tap stream basic description for tapID #\(tapID)...")
self.tapStreamDescription = try tapID.readAudioTapStreamBasicDescription()
logger.debug("Successfully read tap stream description: \(String(describing: self.tapStreamDescription))")
let advertisedDescription = try tapID.readAudioTapStreamBasicDescription()
// The aggregate device may adapt the tap to the active hardware's
// sample rate. Its input stream is the format actually delivered
// to the I/O proc, so use that rather than the tap's pre-aggregate
// advertisement. Using the latter can halve the written duration
// when, for example, a 48 kHz tap is delivered at 24 kHz.
do {
self.tapStreamDescription = try aggregateDeviceID.readInputStreamBasicDescription()
logger.info("Using aggregate input stream description: \(String(describing: self.tapStreamDescription), privacy: .public); tap advertised: \(String(describing: advertisedDescription), privacy: .public)")
} catch {
self.tapStreamDescription = advertisedDescription
logger.warning("Could not read aggregate input stream format; using tap format: \(error, privacy: .public)")
}
} catch {
logger.error("Failed to read audio tap stream basic description for tapID #\(tapID): \(error)")
throw error // Propagate error