mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[PR #449] [MERGED] Add blocking SinkActive|SinkInactive events #930
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#930
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/449
Author: @kaymes
Created: 3/10/2020
Status: ✅ Merged
Merged: 7/24/2020
Merged by: @sashahilton00
Base:
dev← Head:blocking_sink_events📝 Commits (3)
6f28b04Emit blocking sink events667e559Merge remote-tracking branch 'origin/dev' into blocking_sink_eventsd4d5525address merge conflict📊 Changes
3 files changed (+88 additions, -16 deletions)
View changed files
📝
playback/src/player.rs(+57 -15)📝
src/main.rs(+15 -1)📝
src/player_event_handler.rs(+16 -0)📄 Description
This is kind of the same feature as PR #448, but in a blocking fashion. I'm putting it up for discussion as an alternative approach.
It addresses the issue mentioned in #406.
If activated, librespot emits events before the sink is opened and after it is closed. The events are blocking in the sense that the player waits for the handler to complete. This allows to write a handler that frees the sink before librespot attempts to open it.
From an API side, this is implemented as a callback. If a callback is registered, the player executes it blockingly.
From a binary side if --emit-sink-events is set, the usual --onevent script is used and librespot waits for the script's completion.
For simplicity, the events after closing are blocking, too. To make them non-blocking would require some more special handling to avoid race conditions if the sink is closed and opened in rapid succession.
The callback (and env variables) of the script convey three states: "running", "closed", "temporarily_closed". The latter is being used if the sink is temporarily closed between tracks while loading the next one. This allows the event handler to ignore such temporary closures.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.