Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert default player audio callback #2521

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions podcasts/DefaultPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,18 @@ class DefaultPlayer: PlaybackProtocol, Hashable {
}

let peakLimiterRenderCallback: AURenderCallback = { inRefCon, _, _, _, inNumberFrames, ioData -> OSStatus in
guard
let referenceToSelf = DefaultPlayer.unretainedDefaultPlayer(for: inRefCon),
let ioData,
let tap = referenceToSelf.audioMix?.inputParameters.first?.audioTapProcessor
else {
return -1
if ioData == nil { return -1 }
let referenceToSelf: DefaultPlayer
if FeatureFlag.defaultPlayerFilterCallbackFix.enabled {
let reference = Unmanaged<DefaultPlayer>.fromOpaque(inRefCon)
referenceToSelf = reference.takeUnretainedValue()
} else {
referenceToSelf = unsafeBitCast(inRefCon, to: DefaultPlayer.self)
}
guard let tap = referenceToSelf.audioMix?.inputParameters.first?.audioTapProcessor else { return -1 }

// The peak limiter is at the end of the chain so just grab the processed audio
return MTAudioProcessingTapGetSourceAudio(tap, CMItemCount(inNumberFrames), ioData, nil, nil, nil)
return MTAudioProcessingTapGetSourceAudio(tap, CMItemCount(inNumberFrames), ioData!, nil, nil, nil)
}

// MARK: - High Pass Filter
Expand Down Expand Up @@ -505,13 +508,14 @@ class DefaultPlayer: PlaybackProtocol, Hashable {
}

let highPassFilterRenderCallback: AURenderCallback = { inRefCon, _, inTimeStamp, _, inNumberFrames, ioData -> OSStatus in
guard
let referenceToSelf = DefaultPlayer.unretainedDefaultPlayer(for: inRefCon),
let peakLimiter = referenceToSelf.peakLimiter,
let ioData = ioData
else {
return -1
let referenceToSelf: DefaultPlayer
if FeatureFlag.defaultPlayerFilterCallbackFix.enabled {
let reference = Unmanaged<DefaultPlayer>.fromOpaque(inRefCon)
referenceToSelf = reference.takeUnretainedValue()
} else {
referenceToSelf = unsafeBitCast(inRefCon, to: DefaultPlayer.self)
}
guard let peakLimiter = referenceToSelf.peakLimiter, let ioData = ioData else { return -1 }

var audioTimeStamp = AudioTimeStamp()
audioTimeStamp.mSampleTime = inTimeStamp.pointee.mSampleTime
Expand Down
Loading