-
Notifications
You must be signed in to change notification settings - Fork 442
feat(coreaudio): make Stream implement Send on CoreAudio #1021
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we can not do this without spawning a separate thread to keep AudioObjectPropertyListener
in. Maybe its perfectly safe maybe its not. There is not enough documentation from Apple to judge that.
Lets give Apple users an extra thread doing nothing but keep that object on the same thread.... We should name the thread: apple_should_document_their_audio_api
\s
@dvdsk good catch. Let's be more conservative. I've reworked this to use a dedicated thread. While I was at it, I also killed the |
This should be in a good state now - thanks @dvdsk for the necessary reviews. I'll rebase and if you agree, we can merge. |
77ba291
to
3e765e1
Compare
…ustness - Use try_lock to avoid panics and recover from poisoned locks when invoking error callbacks - Skip error callback if lock is busy - Enhance disconnect listener thread to report creation errors and ensure proper synchronization - Update stream lock error message for clarity
Consolidate repeated error callback logic into invoke_error_callback for better readability and maintainability. Update usages in device.rs and disconnect manager. Add documentation for the helper.
3e765e1
to
25b2135
Compare
It would be nice if various backends could be tested on their send-ness, to make sure this doesn't accidentally regress. Something on the lines of const fn assert_send<T: Send>() {}
const _: () = assert_send::<Stream>(); maybe, so that a non-send stream is a compile fail? |
Stream
can now be moved between threads safely on macOS.Rc<RefCell<>>
withArc<Mutex<>>
for thread-safe access to stream stateDisconnectManager
to isolate non-Send
AudioObjectPropertyListener
unsafe impl Send
implementations that are now automatically derivedThe mutex is only locked during
play()
andpause()
operations, so performance impact is negligible. The audio callback is completely unaffected.