fix: use kCMPersistentTrackID_Invalid for HLS audio tap
Root cause found: HLS variant switching changes audio trackID mid-recording (e.g. 2→10). Binding to a specific trackID causes tap to never fire. Using kCMPersistentTrackID_Invalid (wildcard) matches all audio tracks regardless of variant switches.
This commit is contained in:
parent
4ba3ccde21
commit
cff2bd2793
@ -375,9 +375,10 @@ final class PlayerRecorder: NSObject {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建 AudioMix
|
||||
// 使用 kCMPersistentTrackID_Invalid 匹配所有音频轨道
|
||||
// HLS variant 切换会导致 trackID 变化(如 2→10),绑死具体 ID 会失效
|
||||
let inputParams = AVMutableAudioMixInputParameters()
|
||||
inputParams.trackID = audioTrackID
|
||||
inputParams.trackID = kCMPersistentTrackID_Invalid
|
||||
inputParams.audioTapProcessor = tapRef
|
||||
|
||||
let audioMix = AVMutableAudioMix()
|
||||
@ -393,7 +394,7 @@ final class PlayerRecorder: NSObject {
|
||||
}
|
||||
print("[Recorder:DIAG] === installAudioTap DONE ===")
|
||||
|
||||
ctx.mixTrackID = audioTrackID
|
||||
ctx.mixTrackID = kCMPersistentTrackID_Invalid
|
||||
|
||||
// 写诊断日志
|
||||
var diagLog = "=== installAudioTap Log ===\n"
|
||||
@ -403,7 +404,8 @@ final class PlayerRecorder: NSObject {
|
||||
for (i, t) in itemTracks.enumerated() {
|
||||
diagLog += " itemTrack[\(i)]: trackID=\(t.assetTrack?.trackID ?? -1) mediaType=\(t.assetTrack?.mediaType.rawValue ?? "?") enabled=\(t.isEnabled)\n"
|
||||
}
|
||||
diagLog += "Audio trackID used: \(audioTrackID)\n"
|
||||
diagLog += "Audio trackID used: kCMPersistentTrackID_Invalid (wildcard, matches all)\n"
|
||||
diagLog += "Discovered audio trackID: \(audioTrackID)\n"
|
||||
diagLog += "TapCreate status: \(tapStatus)\n"
|
||||
diagLog += "audioMix set: \(verifyMix != nil)\n"
|
||||
writeDiagLog(diagLog)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user