-
Notifications
You must be signed in to change notification settings - Fork 225
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
Switch to CPAL, Symphonia, and parking_lot #197
Conversation
Builds fine on OpenBSD as is. Requires pinning Requires https://github.com/jpochyla/psst/pull/197/files#diff-bba7fe42fa43c91b64f31715a4f831828de23276c69965b0c5bce3cf59db8ae7R13 to be set to
Eventually, music plays on OpenBSD/amd64 without crashes, albeit noticably slower. |
Sigh, so sndio also can't resample the signal on its own. OK, let's put a resampler in there! I'll try |
Keep doing ,nice work 100/100 |
@klemensn I've added an experimental resampling support through (pure Rust conversion of) |
FWIW, it builds and plays on OpenBSD/amd64 without further patching but the playback speed is still too slow. |
Playback speed slow meaning the sample rate is incorrect? |
This branch definitely starts playback much, much faster on boot. No issues on my side with latest commit (Fedora 35, Pipewire 3.39) though I'll randomly get a |
Did you |
Uff, I'm sorry this is taking so long, folks. I believe that as of the latest commit, the design is sound:
|
6e6a2dc
to
8220990
Compare
OK, so I think we should bite the bullet and merge this. One major thing that is missing is additional sample format support, opening the stream will fail on configs without f32 support, but let's do this in master. |
All these commits still build on OpenBSD (with dependency tweaks). Playback speed, however, is still very slow, e.g. dark voices. There is another regression: Pause does not work, so once playing it can only
Do note that the play/pause icon does toggle in the UI, so I dare say that this |
@klemensn Would you please try the playback speed in the release mode? Play/pause is reliant on the CPAL support for pausing/resuming the stream, so it seems the problem is in the OpenBSD backend side, but we should do client-side pausing anyway (to get fadeouts). |
Here is how I have always built
I have to disable optimizations, otherwise rustc(1) (read: LLVM) runs OOM Now I did
and FWIW, here are the changes I need on-top due to OpenBSD: |
@klemensn While it's definitely possible there's a bug, I'd fully expect the playback to be slow when compiled without optimisations. The previous media pipeline was mostly in C (minivorbis + miniaudio), which is less sensitive to compiling in debug mode. |
AFAIK opt-level=0 means absolutely no optimizinations, inlining ecc. I'm not sure I completely understand what's causing OOM but you could try to pass it |
This builds the |
e037c42 Fixes pause/play, i.e.
Edit: while having a track paused to write this comment, another (new) error appeared and playback is completely silent now. Not even restarting
So I close the app and reopen it, but the |
Please don't treat these OpenBSD related issues as a blocker. I'm just a user at this point and support for OpenBSD is still in its early days (other parts need fixing/updating regardless of the sound backend). So if all this works on Linux/MacOS/Windows and is a clear improvement, the rest (read: OpenBSD/sndio support) can still be done afterwards, imho. |
This is an experimental effort in replacing
miniaudio
andminivorbis
crates withcpal
for the raw audio output andsymphonia
for decoding. This has a few benefits:miniaudio-sys
bindings for different platforms....and also a few drawbacks:
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 integrateddasp
withcpal
for resampling support: Alternative audio backends #167While refactoring this, I've also replaced
std
mutexes withparking_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:
f32
is supported)