Skip to content

Fix Swift 6 concurrency compatibility - #4

Draft
prikshitgupta wants to merge 1 commit into
hidden-spectrum:developfrom
prikshitgupta:fix/swift6-sendable-bitrate-mode
Draft

Fix Swift 6 concurrency compatibility#4
prikshitgupta wants to merge 1 commit into
hidden-spectrum:developfrom
prikshitgupta:fix/swift6-sendable-bitrate-mode

Conversation

@prikshitgupta

Copy link
Copy Markdown

What

  • Adds checked Sendable conformance to SwiftLAME's immutable public value types.
  • Keeps AVAudioFile local to the encoding task instead of transferring it across isolation.
  • Preserves source validation during SwiftLameEncoder initialization.
  • Replaces the placeholder test with Swift 5/6 compatibility, invalid-input, playable-output, and cancellation tests.

Why

Swift 6 rejects LameVbrMode.default because the enum is not Sendable, then rejects SwiftLameEncoder.encode because the task captures a struct containing AVAudioFile. Marking the encoder @unchecked Sendable would hide a real unsafe transfer, so this patch narrows stored state to checked Sendable values and constructs the audio file inside the worker task.

Behavior preserved

  • Initialization still throws when the source cannot be opened.
  • Encoding still runs in a task with the requested priority.
  • Progress and cancellation behavior remain unchanged.
  • Telephony output remains playable at 8 kHz / 64 kbps.

Verification

  • swift test — 4 tests passed.
  • swift test -Xswiftc -swift-version -Xswiftc 6 — 4 tests passed.
  • Tests cover checked Sendable contracts, missing input, playable MP3 output, progress completion, and cancellation cleanup.
  • No @unchecked Sendable, nonisolated(unsafe), or global-actor workaround is used.

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.

1 participant