[PR #123] [MERGED] Rewrite ALSA buffering #224

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

📋 Pull Request Information

Original PR: https://github.com/devgianlu/go-librespot/pull/123
Author: @aykevl
Created: 10/9/2024
Status: Merged
Merged: 10/16/2024
Merged by: @devgianlu

Base: masterHead: alsa-period-size


📝 Commits (2)

  • 631d83f fix: set a reasonable period size instead of using the default
  • 435c88a feat: rewrite ALSA buffering

📊 Changes

1 file changed (+113 additions, -155 deletions)

View changed files

📝 output/driver_unix.go (+113 -155)

📄 Description

This PR fixes two main issues:

  • On some hardware, the output stutters a bit. This was the case on my laptop (Fedora Asahi) which despite being very fast still couldn't play audio without crackling on the laptop speakers (it did work over USB though). This was fixed by setting the period size to bufferSize/4, which was previously set to a default (very short) duration.
    I suspect this is the root cause of https://community.volumio.com/t/new-2023-spotify-plugin/63381/354
  • When pausing and resuming (possibly with a seek in between), some audio from before the pause would be repeated. This wasn't very noticeable with the previous short period size (80ms or 160ms or so), but with the new period size it suddenly became 2 seconds and very noticeable.
    An easy way to test this bug is to play a loud part of a song, pause, seek to a quiet part (the beginning is usually quiet), and resume. Before this PR, there was a bit of a stutter. After this PR, the stutter is gone entirely.

Note that this PR doesn't close/reopen the output device anymore on every pause/resume. I don't know whether anybody relied on this behavior but it's a change so noting it just in case.


🔄 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/devgianlu/go-librespot/pull/123 **Author:** [@aykevl](https://github.com/aykevl) **Created:** 10/9/2024 **Status:** ✅ Merged **Merged:** 10/16/2024 **Merged by:** [@devgianlu](https://github.com/devgianlu) **Base:** `master` ← **Head:** `alsa-period-size` --- ### 📝 Commits (2) - [`631d83f`](https://github.com/devgianlu/go-librespot/commit/631d83f03fb0679f6c037952cbd72a1a15d687a9) fix: set a reasonable period size instead of using the default - [`435c88a`](https://github.com/devgianlu/go-librespot/commit/435c88af574e0bc073f2db3d90f284a7c03be976) feat: rewrite ALSA buffering ### 📊 Changes **1 file changed** (+113 additions, -155 deletions) <details> <summary>View changed files</summary> 📝 `output/driver_unix.go` (+113 -155) </details> ### 📄 Description This PR fixes two main issues: * On some hardware, the output stutters a bit. This was the case on my laptop (Fedora Asahi) which despite being very fast still couldn't play audio without crackling on the laptop speakers (it did work over USB though). This was fixed by setting the period size to bufferSize/4, which was previously set to a default (very short) duration. I suspect this is the root cause of https://community.volumio.com/t/new-2023-spotify-plugin/63381/354 * When pausing and resuming (possibly with a seek in between), some audio from before the pause would be repeated. This wasn't very noticeable with the previous short period size (80ms or 160ms or so), but with the new period size it suddenly became 2 seconds and _very_ noticeable. An easy way to test this bug is to play a loud part of a song, pause, seek to a quiet part (the beginning is usually quiet), and resume. Before this PR, there was a bit of a stutter. After this PR, the stutter is gone entirely. Note that this PR doesn't close/reopen the output device anymore on every pause/resume. I don't know whether anybody relied on this behavior but it's a change so noting it just in case. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 14:26:18 +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/go-librespot#224
No description provided.