Commit Graph

6 Commits

Author SHA1 Message Date
Kyle Simpson
47cf0b27eb Chore: clippy appeasement 2025-02-21 14:10:57 +00:00
Gnome!
5bbe80f20c Fix clippy warnings (#236) 2024-04-02 08:57:47 +01:00
Gnome!
3d307aaa8b Fix clippy pedantic warnings (#204) 2023-11-20 00:02:58 +00:00
Kyle Simpson
77e3916bdc Driver: Fix scheduler crash after task closure
A removed audio task could still have one or more driver messages left in its queue, leading to a crash when the id->mixer lookup failed. This removes an unwrap which is invalid under these assumptions and includes an extra cleanup measure for message forwarders under the same circumstances.

This was tested using `cargo make ready`.
2023-11-20 00:02:57 +00:00
Kyle Simpson
9fa063ff0e Chore: Clippy fixes to match new MSRV. 2023-11-20 00:02:57 +00:00
Kyle Simpson
3daf11f5d1 Driver: Implement audio scheduler (#179)
This PR implements a custom scheduler for audio threads, which reduces thread use and (often) memory consumption.

To save threads and memory (e.g., packet buffer allocations), Songbird parks Mixer tasks which do not have any live Tracks.
These are now all co-located on a single async 'Idle' task.
This task is responsible for managing UDP keepalive messages for each task, maintaining event state, and executing any Mixer task messages.
Whenever any message arrives which adds a `Track`, the mixer task is moved to a live thread.
The Idle task inspects task counts and execution time on each thread, choosing the first live thread with room, and creating a new one if needed.

Each live thread is responsible for running as many live mixers as it can in a single tick every 20ms: this currently defaults to 16 mixers per thread, but is user-configurable.
A live thread also stores RTP packet blocks to be written into by each sub-task.
Each live thread has a conservative limit of 18ms that it will aim to stay under: if all work takes longer than this, it will offload the task with the highest mixing cost once per tick onto another (possibly new) live worker thread.
2023-11-20 00:02:57 +00:00