79714002

Date: 2025-07-24 22:01:08
Score: 1.5
Natty:
Report link

Thanks to the help of Apple DTS engineers, there are two workarounds:

Quoting them directly:

This hasn't made it back to you, but there are two workaround which added to your bug which should eventually be sent back to you. Those are:

Option 1:

Annotate tapBlock enclosure as @Sendable

Isolate the call of `self?.processAudioBuffer(buffer)

However, since AVAudioBuffer is not marked as sendable, either import AVFAudio.AVAudioBuffer or AVFoundation with @preconcurrency annotation:

@preconcurrency import AVFAudio.AVAudioBuffer // or @preconcurrency import AVFoundation
 
[…]
 
engine.mainMixerNode.installTap(onBus: 0, bufferSize: 1024, format: format) { @Sendable [weak self] buffer, _ in
    Task { @MainActor in
        self?.processAudioBuffer(buffer)
    }
}

Option 2:

To avoid annotating the import with @preconcurrency

Annotate tapBlock enclosure as @Sendable

Extract data from AVAudioBuffer within the closure

Isolate the call of `self?.processAudioData(array)

engine.mainMixerNode.installTap(onBus: 0, bufferSize: 1024, format: format) { @Sendable [weak self] buffer, _ in
    // Extract the data from the buffer
    guard let channelData = buffer.floatChannelData?[0] else { return }
    let frameCount = Int(buffer.frameLength)
    let audioData = Array(UnsafeBufferPointer(start: channelData, count: frameCount))
 
    Task { @MainActor in
        self?.processAudioData(audioData)
    }
}
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @Sendable
  • User mentioned (0): @preconcurrency
  • User mentioned (0): @preconcurrency
  • User mentioned (0): @Sendable
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Ness Earthbound