Skip to content

AudioQueue should impl Send and Sync #745

Open
@davll

Description

@davll

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:

  1. Low Latency -> should not be blocked by event loops
  2. Background playback

Proposal

I came up with some solutions to the problem to achieve sharable AudioQueue

  1. Replace Rc<AudioSubsystem> with Arc<AudioSubsystem>
  2. AudioQueue should provide Handle for sharing, and provide other threads a subset of methods, such as enqueue, dequeue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions