mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[PR #811] [MERGED] Improve Alsa backend buffer slightly #1094
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#1094
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/librespot-org/librespot/pull/811
Author: @JasonLG1979
Created: 6/23/2021
Status: ✅ Merged
Merged: 7/6/2021
Merged by: @roderickvd
Base:
dev← Head:reuse-buffer-alsa-backend📝 Commits (10+)
1b4d5ebReuse the buffer for the life of the alsa sink365a21bDon't depend on capacity being exact when sizing the buffer.4f598a1Refactor Buffer in alsa.rsf5abd48Merge branch 'librespot-org:dev' into reuse-buffer-alsa-backend85bccddUse const in place of magic numbers921d703Undo a bunch of things09cf255Merge branch 'librespot-org:dev' into reuse-buffer-alsa-backende1ca981Remove unnecessary nesting and edit commente5a5115Merge branch 'librespot-org:dev' into reuse-buffer-alsa-backend85fb588Merge branch 'librespot-org:dev' into reuse-buffer-alsa-backend📊 Changes
1 file changed (+52 additions, -27 deletions)
View changed files
📝
playback/src/audio_backend/alsa.rs(+52 -27)📄 Description
Reuse the period buffer.
Vec.shrink_to_fitandVec.reserve_exacthave proven to be reliable well past our needs. (https://gist.github.com/JasonLG1979/69ed65d91c64f39de4435b3720258d02)There's no reason to not reuse the buffer and avoid unnecessary allocations.
Use a loop expression instead of a while loop to chew though the bytes because it's faster.
(https://gist.github.com/JasonLG1979/3efb5646e4bb42309bdda6d83a3da54e)
Always give the PCM a period's worth of audio even when draining the buffer.
This makes for more consistent stop to start latency (pause to play, manually changing tracks) and helps to prevent jarring, "chopped off" sounding transition when changing tracks manually. Overall resulting in a slightly smoother user experience.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.