Open
Description
Problem
According to SDL Wiki, SDL_QueueAudio and SDL_DequeueAudio should be thread-safe, implying that audio queue should be sharable across threads. However, AudioQueue in rust-sdl2 contains Rc<AudioSubsystem>
that blocks it from Send+Sync.
Why AudioQueue should impl Send + Sync
Push-based audio processing needs a higher priority thread instead of main thread for the below reasons:
- Low Latency -> should not be blocked by event loops
- Background playback
Proposal
I came up with some solutions to the problem to achieve sharable AudioQueue
- Replace
Rc<AudioSubsystem> with Arc<AudioSubsystem>
- AudioQueue should provide
Handle
for sharing, and provide other threads a subset of methods, such asenqueue
,dequeue