@@ -634,46 +634,92 @@ public func releaseStream(_ stream: OpaquePointer) {
634634
635635// MARK: - Recording Output (macOS 15.0+)
636636
637- @ _cdecl ( " sc_stream_add_recording_output " )
638- public func addRecordingOutput (
639- _ stream : OpaquePointer ,
640- _ recordingOutput : OpaquePointer ,
641- _ callback : @escaping @ convention ( c ) ( UnsafeMutableRawPointer ? , Bool , UnsafePointer < CChar > ? ) -> Void ,
642- _ context : UnsafeMutableRawPointer ?
643- ) {
644- if #available ( macOS 15 . 0 , * ) {
637+ #if compiler(>=6.0 )
638+ // Full implementation for Xcode 16+ / Swift 6+ (macOS 15 SDK)
639+
640+ @ available ( macOS 15 . 0 , * )
641+ private func addRecordingOutputImpl (
642+ _ stream : OpaquePointer ,
643+ _ recordingOutput : OpaquePointer
644+ ) throws {
645645 let s : SCStream = unretained ( stream)
646646 let rec : SCRecordingOutput = unretained ( recordingOutput)
647- do {
648- try s. addRecordingOutput ( rec)
649- callback ( context, true , nil )
650- } catch {
651- error. localizedDescription. withCString { callback ( context, false , $0) }
652- }
653- } else {
654- let bridgeError = SCBridgeError . configurationError ( " addRecordingOutput requires macOS 15.0 or later " )
655- bridgeError. description. withCString { callback ( context, false , $0) }
647+ try s. addRecordingOutput ( rec)
656648 }
657- }
658649
659- @_cdecl ( " sc_stream_remove_recording_output " )
660- public func removeRecordingOutput(
661- _ stream: OpaquePointer ,
662- _ recordingOutput: OpaquePointer ,
663- _ callback: @escaping @convention ( c) ( UnsafeMutableRawPointer ? , Bool , UnsafePointer < CChar > ? ) -> Void ,
664- _ context: UnsafeMutableRawPointer ?
665- ) {
666- if #available( macOS 15 . 0 , * ) {
650+ @available ( macOS 15 . 0 , * )
651+ private func removeRecordingOutputImpl(
652+ _ stream: OpaquePointer ,
653+ _ recordingOutput: OpaquePointer
654+ ) throws {
667655 let s : SCStream = unretained ( stream)
668656 let rec : SCRecordingOutput = unretained ( recordingOutput)
669- do {
670- try s. removeRecordingOutput ( rec)
671- callback ( context, true , nil )
672- } catch {
673- error. localizedDescription. withCString { callback ( context, false , $0) }
657+ try s. removeRecordingOutput ( rec)
658+ }
659+
660+ @_cdecl ( " sc_stream_add_recording_output " )
661+ public func addRecordingOutput(
662+ _ stream: OpaquePointer ,
663+ _ recordingOutput: OpaquePointer ,
664+ _ callback: @escaping @convention ( c) ( UnsafeMutableRawPointer ? , Bool , UnsafePointer < CChar > ? ) -> Void ,
665+ _ context: UnsafeMutableRawPointer ?
666+ ) {
667+ if #available( macOS 15 . 0 , * ) {
668+ do {
669+ try addRecordingOutputImpl ( stream, recordingOutput)
670+ callback ( context, true , nil )
671+ } catch {
672+ error. localizedDescription. withCString { callback ( context, false , $0) }
673+ }
674+ } else {
675+ let bridgeError = SCBridgeError . configurationError ( " addRecordingOutput requires macOS 15.0 or later " )
676+ bridgeError. description. withCString { callback ( context, false , $0) }
674677 }
675- } else {
676- let bridgeError = SCBridgeError . configurationError ( " removeRecordingOutput requires macOS 15.0 or later " )
678+ }
679+
680+ @_cdecl ( " sc_stream_remove_recording_output " )
681+ public func removeRecordingOutput(
682+ _ stream: OpaquePointer ,
683+ _ recordingOutput: OpaquePointer ,
684+ _ callback: @escaping @convention ( c) ( UnsafeMutableRawPointer ? , Bool , UnsafePointer < CChar > ? ) -> Void ,
685+ _ context: UnsafeMutableRawPointer ?
686+ ) {
687+ if #available( macOS 15 . 0 , * ) {
688+ do {
689+ try removeRecordingOutputImpl ( stream, recordingOutput)
690+ callback ( context, true , nil )
691+ } catch {
692+ error. localizedDescription. withCString { callback ( context, false , $0) }
693+ }
694+ } else {
695+ let bridgeError = SCBridgeError . configurationError ( " removeRecordingOutput requires macOS 15.0 or later " )
696+ bridgeError. description. withCString { callback ( context, false , $0) }
697+ }
698+ }
699+
700+ #else
701+ // Stub implementation for older compilers (macOS < 15 SDK)
702+
703+ @_cdecl ( " sc_stream_add_recording_output " )
704+ public func addRecordingOutput(
705+ _ stream: OpaquePointer ,
706+ _ recordingOutput: OpaquePointer ,
707+ _ callback: @escaping @convention ( c) ( UnsafeMutableRawPointer ? , Bool , UnsafePointer < CChar > ? ) -> Void ,
708+ _ context: UnsafeMutableRawPointer ?
709+ ) {
710+ let bridgeError = SCBridgeError . configurationError ( " addRecordingOutput requires macOS 15.0 SDK or later " )
677711 bridgeError. description. withCString { callback ( context, false , $0) }
678712 }
679- }
713+
714+ @_cdecl ( " sc_stream_remove_recording_output " )
715+ public func removeRecordingOutput(
716+ _ stream: OpaquePointer ,
717+ _ recordingOutput: OpaquePointer ,
718+ _ callback: @escaping @convention ( c) ( UnsafeMutableRawPointer ? , Bool , UnsafePointer < CChar > ? ) -> Void ,
719+ _ context: UnsafeMutableRawPointer ?
720+ ) {
721+ let bridgeError = SCBridgeError . configurationError ( " removeRecordingOutput requires macOS 15.0 SDK or later " )
722+ bridgeError. description. withCString { callback ( context, false , $0) }
723+ }
724+
725+ #endif
0 commit comments