Skip to content
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

Refactor & document playlist-related things #416

Merged
merged 20 commits into from
Jan 24, 2025

Conversation

hasezoey
Copy link
Contributor

This PR refactors & documents playlist-related things, in more details:

  • document tui::components::playlist::playlist_add_* functions
  • document playback::playlist::Playlist fields & functions
  • fix possible infinite loop in Playlist::get_random_index
  • report errors in Playlist::add_track / Playlist::add_playlist instead of silently ignoring them (like "unsupported file type")
  • early-return parsing playlist.log if file did not exist or is empty
  • dont save a empty 0 to playlist.log if the playlist is empty, only truncate the file
  • some style changes (dedent, simpler calls)
  • clear everything in Playlist::clear instead of having some residual data
  • remove Playlist::next_track and only use Playlist::next_track_index
  • gitignore the .vscode directory

Some optimizations:

  • in Playlist::save write to BufWriter directly, instead of into a intermediate buffer
  • in Playlist::swap_* use Vec::swap instead of removing & inserting

…directly

instead of buffering everything again
…instead of "remove" & "insert"

"remove" and "insert" will move all the data and may allocate, whereas "swap" literally swaps in-place.
…rack" and report errors

move single-add track to own function and report any errors instead of silently failing.
Now "invalid file type" errors are actually caught (not when symphonia or so fails though yet).
as it was basically never used, and "next_track_index" can fully serve the use-case.
Also always use "next_track_index" if available, not just when "gapless".
Finally, remove field "config" as it is now never used.
@tramhao tramhao merged commit e608bc5 into tramhao:master Jan 24, 2025
5 checks passed
@hasezoey hasezoey deleted the playlistRefactor branch January 24, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants