[PR #197] [MERGED] Switch to CPAL, Symphonia, and parking_lot #450

Closed
opened 2026-02-28 14:33:03 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jpochyla/psst/pull/197
Author: @jpochyla
Created: 10/14/2021
Status: Merged
Merged: 11/16/2021
Merged by: @jpochyla

Base: masterHead: cpal-symphonia


📝 Commits (10+)

  • 50a222a core: Switch to CPAL, Symphonia, and parking_lot
  • b2dd91d core: Add experimental resampling
  • 42da6b6 core: Apply global volume and norm factor
  • 0092404 core: Huge mod reorg
  • ea1a6cc Update ureq
  • c0abb27 Remove minivorbis
  • 7dceae0 core: Rework the audio buffering pipeline
  • 583e4e6 core: Add resampling to the new Worker
  • b689920 core: Fix reporting rate calculation
  • 8220990 Nit

📊 Changes

48 files changed (+2435 additions, -3520 deletions)

View changed files

📝 .github/workflows/build.yml (+1 -1)
.gitmodules (+0 -3)
📝 Cargo.lock (+576 -32)
📝 Cargo.toml (+6 -3)
minivorbis-sys/Cargo.toml (+0 -8)
minivorbis-sys/bindings.h (+0 -3)
minivorbis-sys/build.rs (+0 -10)
minivorbis-sys/gen.sh (+0 -10)
minivorbis-sys/minivorbis (+0 -1)
minivorbis-sys/minivorbis.c (+0 -6)
minivorbis-sys/src/bindings.rs (+0 -1919)
minivorbis-sys/src/lib.rs (+0 -8)
minivorbis/Cargo.toml (+0 -8)
minivorbis/src/lib.rs (+0 -272)
📝 psst-cli/src/main.rs (+6 -18)
📝 psst-core/Cargo.toml (+7 -4)
psst-core/src/actor.rs (+118 -0)
psst-core/src/audio/decode.rs (+115 -0)
📝 psst-core/src/audio/decrypt.rs (+10 -3)
psst-core/src/audio/mod.rs (+6 -0)

...and 28 more files

📄 Description

This is an experimental effort in replacing miniaudio and minivorbis crates with cpal for the raw audio output and symphonia for decoding. This has a few benefits:

  1. We don't have to maintain miniaudio-sys bindings for different platforms.
  2. Building is simpler.
  3. Symphonia is of excellent quality, has low CPU usage and supports multiple codecs (relevant for podcast support and playing local tracks).
  4. The upstream feels a bit closer, we can fork, fix bugs, etc.

...and also a few drawbacks:

  1. cpal doesn't do any resampling. Some Windows setups seem to require apps to resample the audio themselves, but so far, the Spotify OGG tracks seem to all be sampled at 41000hz. I suppose that maybe we can assume all audio setups would support this and wait? @H-M-H has integrated dasp with cpal for resampling support: https://github.com/jpochyla/psst/discussions/167
  2. We lose native PulseAudio support. I have a feeling we could have multiple audio backends in Psst and use PA directly.

While refactoring this, I've also replaced std mutexes with parking_lot, introduced a ringbuffer between the audio thread and the decoding, and split decoding of different audio files into different threads, to avoid deadlocks in case the I/O gets stuck indefinitely.

Missing:

  • Global volume
  • Normalization
  • More sample formats (now only f32 is supported)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jpochyla/psst/pull/197 **Author:** [@jpochyla](https://github.com/jpochyla) **Created:** 10/14/2021 **Status:** ✅ Merged **Merged:** 11/16/2021 **Merged by:** [@jpochyla](https://github.com/jpochyla) **Base:** `master` ← **Head:** `cpal-symphonia` --- ### 📝 Commits (10+) - [`50a222a`](https://github.com/jpochyla/psst/commit/50a222afd2dc4974d814a228d23d3cb104e46392) core: Switch to CPAL, Symphonia, and parking_lot - [`b2dd91d`](https://github.com/jpochyla/psst/commit/b2dd91d06db99551d5851044e956d21c959d75b9) core: Add experimental resampling - [`42da6b6`](https://github.com/jpochyla/psst/commit/42da6b63a7ff1ce478df5ac3f130d10f3e58ef1b) core: Apply global volume and norm factor - [`0092404`](https://github.com/jpochyla/psst/commit/00924048fe405833c0ca93681d98bcbd5ad962f5) core: Huge mod reorg - [`ea1a6cc`](https://github.com/jpochyla/psst/commit/ea1a6ccca4760ba1a939e4abd0d9c431c31719ab) Update ureq - [`c0abb27`](https://github.com/jpochyla/psst/commit/c0abb270f8dd0b32df7303abeefde4a9a863d2db) Remove minivorbis - [`7dceae0`](https://github.com/jpochyla/psst/commit/7dceae09dde6b0bf305ff71f32c8d51f661e1723) core: Rework the audio buffering pipeline - [`583e4e6`](https://github.com/jpochyla/psst/commit/583e4e6a2971239f483bfec908eab6f6434cbbd4) core: Add resampling to the new Worker - [`b689920`](https://github.com/jpochyla/psst/commit/b689920d79141a35bf8df51107ce0028626736ba) core: Fix reporting rate calculation - [`8220990`](https://github.com/jpochyla/psst/commit/8220990eae0f79345ed23685381f3e613869c4f7) Nit ### 📊 Changes **48 files changed** (+2435 additions, -3520 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/build.yml` (+1 -1) ➖ `.gitmodules` (+0 -3) 📝 `Cargo.lock` (+576 -32) 📝 `Cargo.toml` (+6 -3) ➖ `minivorbis-sys/Cargo.toml` (+0 -8) ➖ `minivorbis-sys/bindings.h` (+0 -3) ➖ `minivorbis-sys/build.rs` (+0 -10) ➖ `minivorbis-sys/gen.sh` (+0 -10) ➖ `minivorbis-sys/minivorbis` (+0 -1) ➖ `minivorbis-sys/minivorbis.c` (+0 -6) ➖ `minivorbis-sys/src/bindings.rs` (+0 -1919) ➖ `minivorbis-sys/src/lib.rs` (+0 -8) ➖ `minivorbis/Cargo.toml` (+0 -8) ➖ `minivorbis/src/lib.rs` (+0 -272) 📝 `psst-cli/src/main.rs` (+6 -18) 📝 `psst-core/Cargo.toml` (+7 -4) ➕ `psst-core/src/actor.rs` (+118 -0) ➕ `psst-core/src/audio/decode.rs` (+115 -0) 📝 `psst-core/src/audio/decrypt.rs` (+10 -3) ➕ `psst-core/src/audio/mod.rs` (+6 -0) _...and 28 more files_ </details> ### 📄 Description This is an experimental effort in replacing `miniaudio` and `minivorbis` crates with `cpal` for the raw audio output and `symphonia` for decoding. This has a few benefits: 1. We don't have to maintain `miniaudio-sys` bindings for different platforms. 2. Building is simpler. 3. Symphonia is of excellent quality, has low CPU usage and supports multiple codecs (relevant for podcast support and playing local tracks). 4. The upstream feels a bit closer, we can fork, fix bugs, etc. ...and also a few drawbacks: 1. `cpal` doesn't do any resampling. Some Windows setups seem to require apps to resample the audio themselves, but so far, the Spotify OGG tracks seem to all be sampled at 41000hz. I suppose that maybe we can assume all audio setups would support this and wait? @H-M-H has integrated `dasp` with `cpal` for resampling support: https://github.com/jpochyla/psst/discussions/167 2. We lose native PulseAudio support. I have a feeling we could have multiple audio backends in Psst and use PA directly. While refactoring this, I've also replaced `std` mutexes with `parking_lot`, introduced a ringbuffer between the audio thread and the decoding, and split decoding of different audio files into different threads, to avoid deadlocks in case the I/O gets stuck indefinitely. Missing: - [x] Global volume - [x] Normalization - [ ] More sample formats (now only `f32` is supported) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 14:33:03 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/psst#450
No description provided.