Skip to content

Swift 6 strict concurrency support #17

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

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft

Swift 6 strict concurrency support #17

wants to merge 47 commits into from

Conversation

sbooth
Copy link
Owner

@sbooth sbooth commented Jun 18, 2024

The thread-safety of the various AudioObject APIs isn't clear. Lacking documentation to the contrary I assume they aren't thread-safe, which means that the current design for AudioSystemObject needs to be revisited.

@sbooth sbooth changed the title Add Sendable conformance to properties Swift 6 compatibility Jun 18, 2024
@sbooth sbooth linked an issue Jun 26, 2024 that may be closed by this pull request
@sbooth sbooth changed the title Swift 6 compatibility Swift 6 Strict Concurrency Support Jul 9, 2024
@sbooth sbooth changed the title Swift 6 Strict Concurrency Support Swift 6 strict concurrency support Jul 9, 2024
@sbooth sbooth marked this pull request as draft January 5, 2025 14:37
@sbooth sbooth requested a review from Copilot July 6, 2025 23:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds strict concurrency support by marking AudioObject and its subclasses as @unchecked Sendable, and updates the property change notification block to be @Sendable.

  • Introduces @unchecked Sendable conformance to AudioObject base class and all subclasses
  • Updates PropertyChangeNotificationBlock alias to @Sendable
  • Bumps copyright year in AudioEndpoint.swift

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

File Description
AudioObject.swift Added @unchecked Sendable to AudioObject and made its notification block @Sendable
AudioControl.swift and other subclasses Added redundant @unchecked Sendable conformance to each subclass of AudioObject
AudioEndpoint.swift Updated copyright years
Comments suppressed due to low confidence (3)

Sources/CAAudioHardware/AudioObject.swift:12

  • [nitpick] Add a brief doc comment explaining why AudioObject is marked @unchecked Sendable (e.g., underlying C API assumptions) to clarify the concurrency guarantee for future maintainers.
public class AudioObject: Equatable, Hashable, @unchecked Sendable, CustomDebugStringConvertible {

Sources/CAAudioHardware/AudioObject.swift:85

  • Consider adding unit or integration tests that exercise PropertyChangeNotificationBlock under concurrent usage to verify the notification closure behaves correctly across threads.
	public typealias PropertyChangeNotificationBlock = @Sendable (_ changes: [PropertyAddress]) -> Void

Sources/CAAudioHardware/AudioControl.swift:15

  • [nitpick] Since AudioControl inherits from AudioObject which is already declared @unchecked Sendable, you can remove the redundant @unchecked Sendable conformance here to reduce duplication.
public class AudioControl: AudioObject, @unchecked Sendable {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not compatible with Swift 6 strict concurrency
1 participant