1
0
Fork 0
forked from len0rd/rockbox
Commit graph

411 commits

Author SHA1 Message Date
Christian Soffke
50f10681b3 playlist: remove support for PLAYLIST_COMMAND_CLEAR
Although this breaks compatibility with playlist control
file versions 3-5, i.e. control files generated by any RB
build between Jan 29 2023 (commit 25bd3bc) and Oct 26 2024
(commit 7592d2c), compatibility with v2 of the control file
that was in use from 2003 to 2023 is maintained.

Change-Id: I7fd3394e31131bb0563e41d921bcaf940dd999bc
2025-08-08 09:34:52 -04:00
Christian Soffke
60010b52a2 voice: Use "All" prefix for final progress announcement
Use "All" prefix when the final item count is announced
in display_playlist_count and search_playlist
("All 2000 tracks saved"), to make it possible to tell
when the operation has finished.

Change-Id: I90419599fb30da511ee4671b8f0f7f92e2098fd0
2025-06-02 21:04:06 -04:00
Christian Soffke
498d581ca6 voice: fix regression 39f8685 (already voiced)
Some of the splashf messages that were converted
to support voicing in commit 39f8685 already had
a voice equivalent that was more appropriate,
since it also voiced parameters, and included
pauses between announcements where necessary.

Change-Id: Ia91a01c82acd6148afb4afadd64b1105802aea36
2025-05-28 11:18:29 +02:00
Solomon Peachy
39f86858c4 voice: Convert a pile of splashf() messages to be voiced
Basically, this just replaces str(STRID) with ID2P(STRID).

The voiced version of these strings cannot not have any format
specifiers (enforced by the language tooling) and are instead more
generic.

As many of these are error conditions, it is doubly important for
them to be voiced in some way.

There are some places in the code that perform their own voicing
for splash messages (eg the shutdown code); those are left alone.

Change-Id: I7d51af351e8fa5c4beee42fbfc02719f1d6591b8
2025-05-17 17:33:46 -04:00
William Wilgus
7100090f99 Remove NVRAM infavor of a separate cfg file
remove nvram and use the existing settings framework for it

add a crc check to the user_settings data to see if we need to save
the user setting file or if we can just save the status file (resume.cfg)

move volume to the system_status struct so we don't write the whole settings file
over volume changes

allow user to still export volume with save sound settings

allow the user to also export pitch and speed

name the file .resume.cfg

Rename all the SYSTEM_STATUS save file variables to TLAs to save space and
discourage tinkering

Cleanup DEBUG_AVAIL_SETTINGS output

when saving user_settings it calls status_save as well this cause the resume
file to be written twice. instead remove the callback for status_save
when setting_save is called

remove header text when saving .resume.cfg

convert status_save() to status_save(bool force)
add SYSTEM_STATUS_UPDATE_TICKS

for ATA device set this to 5 minutes
since we arlready wait for the disk to be up before saving
we don't want to miss our window

for all other every 15 minutes

that way if the battery is too low by the time shutdown comes around you
don't lose much progress

Change-Id: I27214ffd6e5d5494ee5ca83b14f04a41ba426ad7
2025-01-21 00:04:32 -05:00
Christian Soffke
ca459a9d09 misc: Eliminate redundant yes/no dialog functions
Change-Id: I28bc4531cdfe6e28a1677b1a0ebb461e48188fd8
2025-01-15 14:10:17 -05:00
Christian Soffke
b83504635c playlist: eliminate error message disconnecting USB
With no control file present, the message
"Error accessing playlist control file"
was displayed, due to playlist_resume being
called from gui_usb_screen_run.

You were likely to only run into this after a clean
install, if you hadn't listened to any music yet.

It probably makes sense to move the check for the
existence of the control file into playlist_resume,
and not even have it show a separate access error
message when the file doesn't exist.

Change-Id: Ib3a643c43d3d4d499fa5a13c01955779d69cd357
2025-01-15 14:00:10 -05:00
Christian Soffke
24c9ccfac0 playlist: Set playlist index after resuming
fixes current track selection
in Playlist Viewer when stopped

Change-Id: I3d1fa28a4bf2d631918e159a3fd8025c17979833
2025-01-15 13:28:35 -05:00
Christian Soffke
fb26398622 playlist: Fix warning when erasing playlist after reboot
Unless you had manually resumed the playlist, you
didn't get any warning after Rockbox rebooted, when
replacing a modified current playlist.

Change-Id: Ibc83e3db4e6ee51e94204ac7732760894d2fb602
2025-01-15 13:10:07 -05:00
Christian Soffke
e5c9846cb4 Playlist Catalogue: fix: "Save Current Playlist" may fail silently
- After rebooting, unless the current playlist
had been manually resumed already, the "Save
Current Playlist" option in the root menu's/
playlist catalogue's context menu failed to work.

- Eliminate error message attempting to view current
playlist when no control file present.

Change-Id: I58f1d3dc6f256fcee106ff5a17f69fa46d67b2e4
2025-01-09 06:10:46 +01:00
Christian Soffke
0012411fc5 playlist: Simplify playlist_load
Reset fd for the on-disk playlist at the place where
ownership is transferred in playlist_set_current (which
already has a note, that the playlist will be effectively
closed, but did not reset the fd).

Also ensure, that calling playlist_load closes the fd for
the on-disk playlist (and its control file), if any were
left open - even though this is not supposed to happen.

Generate name of control file in playlist_init to be more
consistent with the behavior for the current playlist.
Only a single playlist can be loaded in the playlist viewer
at the same time, so generating random names shouldn't be
needed.

Change-Id: I65e0fc07ce608c1d333a90447e18482787a98b8c
2025-01-05 14:39:24 -05:00
Christian Soffke
fe78b07db6 Playlist Viewer: Address problematic index buffer sharing
Borrowing the index buffer of the current playlist
can be problematic, since it is possible to start
playback of a different playlist from the playlist
viewer without leaving the viewer, thereby causing
a collision.

As long as we have a sufficiently large plugin
buffer, take advantage of it, regardless of
playback state.

When playback is stopped, always resume the playlist
from the control file before loading it, even if the
playlist has finished playing, to prevent running
into invalid indices.

Note:
dcfrefs_handle is initialized to 0 automatically for
the static on_disk_playlist struct.

Change-Id: I2a05a6a51a088ea9ba73858c353525db9e61c36e
2024-12-31 10:08:31 -05:00
Dana Conrad
7d3cc24dec FS#13519: multivolume: Ensure absolute paths get drive designation
Change-Id: I8419af670ca101b11bba29d9fd577f21fa22fd42
2024-12-17 21:18:06 -05:00
Roman Artiukhin
004304dc65 unicode: add iso_decode_ex with utf8 buffer size check
Make use of it in id3tags, playlist and cuesheet

Change-Id: Ibc8abc0faf16688bc9b826b7a712d1dfe9bf75b2
2024-12-15 09:26:26 -05:00
Christian Soffke
46a4361bf1 playlist viewer: move on-disk playlist struct to playlist.c
Change-Id: I40281142f2fa930f0c68b9612c12fca14885ac37
2024-11-23 09:05:39 -05:00
Christian Soffke
78bea2a7ac playlist: Remove playlist_get_required_bufsz
Change-Id: I00cf26a2502f1b31cab8d896bf8eb1ae2626020a
2024-11-16 12:18:03 -05:00
Christian Soffke
04a796fd15 playlist: create_control_unlocked: back up current playlist
When creating a new control file for the current playlist,
the existing file will now be renamed to serve as a backup,
until the next time the control file is replaced again,
allowing you to restore the previous state of the playlist,
in case you accidentally cleared it.

This also means that an entirely new file is created each
time, instead of truncating the existing one.

Change-Id: I2fd96eb8c3940b85df807fd7646dc0359a036351
2024-10-26 11:28:22 -04:00
Christian Soffke
7592d2ca5e playlist: deprecate PLAYLIST_COMMAND_CLEAR
In the following scenario, a garbage file name would
be written to the control file for the playing track
(resulting in a failure to resume correctly):

- "Keep Current Track When Replacing Playlist" option is set
- A track is playing that was not inserted but instead comes
  from a playlist file on disk
- User performs "Playing Next..." -> "Play" on some tracks, so
  that the current playlist is replaced (but leaving the playing
  track queued)
- User saves the playlist while queued track is still playing
  (the offer to remove queued tracks is declined)

The failure occurs because the pl_save_update_control function
assumes that the seek offset for queued files always points into
the control file. Meanwhile, the remove_all_tracks_unlocked
function adds the PLAYLIST_QUEUED flag indiscriminately, even if
a track comes from a playlist file instead of having been inserted.

Theoretically, this could be addressed by adding the playing
track's file name as a parameter to PLAYLIST_COMMAND_CLEAR,
which the track is then updated to point to, unless it
was already inserted (alternatively, we could seek within
the playlist file for such tracks).

Unless I'm missing something, it may be preferable, though, to
get rid of PLAYLIST_COMMAND_CLEAR completely, and instead have the
remove_all_tracks_unlocked function start over with a fresh
control file, into which we insert a single ('P' and) 'Q' command.

This seems to have several advantages:

- When resuming, we eliminate the need to parse and handle all of
  the outdated entries again that end up being cleared anyway
- It is ensured that the control file doesn't rely on the existence
  of a playlist file anymore after the playlist has been cleared
- We can reset the playlist's file name, which should make it less
  likely for the user to overwrite their previous (now unconnected)
  playlist that was still displayed in the Save dialog
- Unrelated bookmarks for the previous playlist aren't displayed
  anymore
- Improved consistency with existing behavior when the "Keep
  Current Track When Replacing Playlist" was disabled.

Change-Id: I41a89295bbac878807d65db9cf67b8a485daf0e5
2024-10-26 11:28:01 -04:00
William Wilgus
f55cb77f89 [Bugfix] FS#13492 - Playback resume fails after USB insert
On usb plug system_flush() gets called before the other
threads get a chance to ACK the insert

system_flush() calls playlist_shutdown() (amongst other things)
playlist_shutdown closes the control file

the audio thread acks USB insert
audio_stop_playback is called which now can't look up the
filename from the now closed handle for control the control file

I left the guard for checking for USB insert but it appears to be
fine without it

Change-Id: I935dbf7aed38d4a57413c0063ad953f427e9b3bb
2024-09-26 01:34:56 -04:00
William Wilgus
072228bb70 [feature] playlist. show search progressbar when iterating playlist entries
Change-Id: Ib38363f7495ca523e7cc401c0d39e060ed1705ad
2024-07-20 00:08:39 -04:00
William Wilgus
3b9d804bdf [coverity] playlist.c format_track_path() guard NULL pointers
Change-Id: If029477ef9f38ee57b3afb7901d7429319675cc5
2024-06-07 00:38:20 -04:00
William Wilgus
1b7d35126b [coverity] playlist.c pl_save_update_control fix rest of potential fd leaks
Change-Id: I65a8ac6a2ce68c5fd3cde570c3ff1b2e737d911d
2024-06-04 17:18:30 -04:00
William Wilgus
afba86f0f7 [coverity] playlist.c pl_save_update_control() close fd on error
Change-Id: Ib44e86a36540e65a15eed3e9b99106734379250d
2024-06-02 22:14:27 -04:00
William Wilgus
f4a044e561 [coverity] playlist.c get_track_filename() uninitialized buffer
format_track_path() uses path_append_ex() which might use strlen on the
existing buffer likely a false positive but cheap enough to guard against

Change-Id: I7061a434460f235fc58016f9dcf2dfe4633b9f59
2024-06-02 21:40:20 -04:00
Christian Soffke
3d7d1d4d5b plugins: properties: show track info for whole playlist
Track Info can now be displayed for the set of
all tracks contained in a  playlist. This lets
you calculate a playlist's length, for example,
even if it is not currently playing.

This functionality can be accessed from the
existing "Properties" screen for a selected
playlist file. A line has been added at the
very bottom to show Track Info.

Change-Id: I311532b7cfa9e29d46c0cd5623ba4c06c1dd5b5f
2024-06-01 11:55:36 -04:00
Christian Soffke
446496c221 Have Repeat Shuffle turn on Shuffle
When "Repeat Shuffle" is enabled, it may make sense
to visibly turn on the Shuffle setting once a playlist
ends and starts from the beginning again.

This seems to fix a few issues:

- After (an unmodified) playlist has been shuffled,
bookmarks now behave correctly in terms of restoring
the playlist's shuffled state and using the correct resume
index. This wasn't the case before. The alternative may be
to set the playlist as modified once it is shuffled, to
prevent creation of bookmarks from that point on.

- Lets you return to the un-shuffled state of the playlist at
any point

- Icon makes it easy to tell if the "unmodified" playlist has
been shuffled already, or not, which wasn't obvious before.

Change-Id: I41af04b041fdc7774c9d9267aaf983ec9d402e13
2024-04-23 05:24:48 +02:00
Christian Soffke
ea5ce8034b Replace "Reload After Saving" with option to remove queued tracks
The "Reload After Saving" setting was added in
g3347 (4f83e66) to solve FS#13287, by allowing
you to bookmark a modified playlist after saving,
without having to manually reload it first.

Since the rewrite of playlist_save in g5192
(90e3571), a modified playlist doesn't have to be
reloaded anymore in order to be bookmarked after
it's been saved, unless it contains queued tracks.

To cover the remaining use cases of the previously
available option, Rockbox will now offer to remove
any queued tracks from a playlist when saving it.

Change-Id: I2d6f12bcce14d8ff41a4d921ce84d628774103ac
2024-04-21 18:28:16 +02:00
William Wilgus
cb3b5397b3 Revert "Extend path_append_ex to truncate compname, remove some strmemdupa"
This reverts commit dbe20d453d.

Reason for revert: Crashes ipod Classic

Change-Id: I9ea329ce73383535353832d17c7c5e494e5ad516
2023-11-23 21:26:13 -05:00
William Wilgus
dbe20d453d Extend path_append_ex to truncate compname, remove some strmemdupa
remove some duplicated strings previously allocd off the stack

just removing string duplications that are easily handled with truncation
now available with path_append_ex()

this also has an advantage of less stack used in worst case scenarios

Change-Id: I3a43e33ef8a8c36599e4c6c036a0ccdd8ed0c883
2023-11-19 12:00:02 -05:00
Christian Soffke
5114827937 Fix: Rotate indices after saving playlist w/ first_index > 0
When saving the current playlist, entries written out
to disk were rotated, but its indices were not, resulting
in first_index being out of sync between the two. Thus,
an incorrect index was used for any playlist commands,
from the moment you saved the playlist until the next
time you resumed, which didn't produce the right playlist.

Change-Id: Ie4b02ce9e07e565b1b15c938cc4b820db08e8f1f
2023-11-15 23:49:53 +01:00
Christian Soffke
bd93f9f96f Increase playlist control file's version number
This should have probably been included in e9b4275,
since a control file generated with that build will
potentially cause issues when used with older versions,
in case -8 appears as an insert position.

Change-Id: I4a7097a2bd33c0dbbdad481a341b49be505f34f7
2023-11-12 02:49:20 +01:00
Christian Soffke
a82b30735d Fix queued track when resuming after PLAYLIST_COMMAND_CLEAR
PLAYLIST_COMMAND_CLEAR needs to save the index of the
currently playing track, or a track with index 0 will
be left queued after resuming from control commands

Change-Id: If7449bff92acd556b03c46e82301e8fec5c997d7
2023-11-11 00:36:14 +01:00
Christian Soffke
ba14aecd5e Fix INSERT_LAST_SHUFFLED when playlist's first_index > 0
Tracks were inserted into the middle of the playlist

Change-Id: I2a665fd3e0fe9d8900d6555e6affc5cb3d7513f8
2023-11-11 00:36:14 +01:00
Christian Soffke
d4f1247aec Playlists: Fix moving songs in reshuffled playlist
The current index wasn't always correct after moving
in a playlist with first index > 0

Change-Id: Ifbcc1e00ed0ec5b26e2176d7971cc5c1e15a8840
2023-11-11 00:36:14 +01:00
Christian Soffke
e9b4275d1f Playlists: Fix resuming from control commands with first_index > 0
add_track_to_playlist_unlocked only increased a playlist's
first index as necessary when its position parameter was
negative (i.e. one of the special insert positions was
specified).

A negative value was not stored in the control file, but
was always converted into an absolute position. Thus, any
adjustments to first_index weren't repeated when resuming
from the control file.

In particular, shuffled playlists were affected (in case of
first_index > 0), when inserting at positions <= first_index,
including appending a track to the end of a playlist. This
works by inserting at first_index and increasing first_index
by 1 afterwards.

Similarly, adding tracks in a shuffled fashion could increase
first index, whenever that was the value randomly calculated
for a track position, effectively appending it (I assume this
is on purpose).

To make sure that first_index adjustments are recovered when
resuming from the control file, and to be able to differentiate
between a prepended or appended track, store the special value
PLAYLIST_INSERT_LAST_ROTATED as the insert position in the
control file whenever first_index would have been used before,
and a special position (other than PLAYLIST_PREPEND) was
provided to the function.

Change-Id: I31f26796627fb136daeddd046cb1892bdf1b4014
2023-11-11 00:36:14 +01:00
William Wilgus
7ac4d34dd6 Playlist slight optimizations for playlist_resume
Change-Id: I766ce032a9b6b36d750a9231ff9f5d5a0167e5a5
2023-11-09 21:03:25 -05:00
William Wilgus
154f10c2d2 boost cpu when resuming playlists
Change-Id: I6184075945b59b3fce2882dd56567b5cf3cb174b
2023-11-02 23:48:54 -04:00
Christian Soffke
332a0fa968 Playlist sort/shuffle: Fix data type
I noticed that setting first_index to the
current track when shuffling a playlist
could fail in the Simulator.

Change-Id: Ic9467bd46a93aa2d2b765271110b0baee7058208
2023-11-01 15:35:58 -04:00
Christian Soffke
d77c417fd1 Fix bookmarking/reloading after saving shuffled playlist
The resume index into the playlist file
that was used for bookmarks created immediately
after saving a shuffled playlist, or for reloading
the saved playlist (in case "Reload After Saving"
was enabled), tended to be incorrect.

The playlist file effectively isn't shuffled
anymore after saving it to a file, but the
resume index may still have to be rotated unless
playback has been stopped and resumed before
bookmarking, due to indices that are shifted
by first_index.

Change-Id: Id335a7a71adc216989d7b415bfa48237d92fd7b0
2023-10-30 14:09:51 -04:00
Christian Soffke
3f3e185460 Fix return value for playlist_get_resume_info
(Only) bookmark_is_bookmarkable_state()
seems to require a return value atm.

Change-Id: I701031285aad80a46ebca747d06f15d968c0e9c7
2023-10-30 13:57:01 -04:00
Christian Soffke
96dd251571 Remove playlist_shutdown from playlist_resume
This was added in 5e757b4 as a band-aid to
prevent control data from being discarded,
but has since become superfluous after
the removal of the control file cache in
2e99e21.

Change-Id: Ia7bd84f9442ec1103aee8d3c4454216719aa2d66
2023-10-30 18:49:42 +01:00
Christian Soffke
45746934c4 playlist_set_current: Fix outdated dircache filerefs
Entries from a previously playing playlist may not
have been replaced after selecting a track from
a different playlist in the Playlist Viewer when
playback was stopped (not paused), since the index
buffer of a playlist opened in the Playlist Viewer
is shared with the current playlist when nothing is
playing.

Change-Id: I939e302c73cabd0e9d969550143635e54db32bf0
2023-10-30 02:07:01 +01:00
Aidan MacDonald
90e35716e3 playlist: Rewrite playlist_save(), optimization & fixes
playlist_save() was a poorly thought out mess. This fixes the
glaring issues and hopefully ensures that saving the playlist
never loses state (such as queued tracks or modified status)
after save+resume.

Indices are now updated on the fly, which is faster and needs
no extra memory. But if an error occurs, the playlist will be
corrupted. There is currently no attempt to handle this since
errors should be unlikely, but some error handling needs to be
added in the future.

Change-Id: If8a5dbd6a596460be08ee0b7bab9f24337886ea4
2023-10-28 14:54:02 -04:00
Christian Soffke
759aaecdff Playlist Viewer: Eliminate 'dirty' flag
A playlist's explicit 'modified' flag is now used
for keeping track of whether it's been modified
in the Playlist Viewer, not just in case of the
currently playing list, but for other playlists
as well.

When you start playback of a track from the
Playlist Viewer, a playlist's 'modified'
status is now carried over to the current
playlist, so as to produce a warning when
there is an attempt to replace the list at
a later point. This also prevents (auto)
bookmarking of the playlist if it had been
modified in the Playlist Viewer prior to
becoming the current playlist. (Bugfix)

Change-Id: Ibc391fd69285f8a67d6ffb6d8c274df3d223974c
2023-10-18 18:23:57 +02:00
Christian Soffke
75befe19ef Hide Bookmark menu for new dynamically generated playlists
The bookmark menu with the option to create a bookmark
was inadvertently displayed for new dynamic playlists,
that had no associated folder or playlist file on disk.
(e.g. after selecting some track from the database for
playback), until the playlist was modified by the user.

Change-Id: I9d6809e4d03603c651459415327f28e38162ad53
2023-10-10 12:03:52 -04:00
Aidan MacDonald
7ccbd705f4 playlist: Rework playlist modified detection and dirplay
The modified state is now an explicit flag that has to be
set whenever a user-triggered modification occurs. This is
recorded in the control file to ensure it doesn't get lost
after resume. There may be some places I missed where the
modified flag should be set/cleared, but it seems to work
well enough right now.

Change-Id: I3bdba358fc495b4ca84e389ac6e7bcbef820c219
2023-10-01 11:05:29 -04:00
Aidan MacDonald
4745970974 playlist: Use PLAYLIST_QUEUED instead of PLAYLIST_QUEUE_MASK
We don't need two names for the same 1-bit field.

Change-Id: I71ed61198da8d6e4bf4d449d8704982918099f7d
2023-09-30 09:03:58 +01:00
William Wilgus
fcc82dfdca [BugFix] REPEAT_ONE manual track skip
Still having problems with determining the type of track change

lets try just watching the audio_next/prev functions

Change-Id: Ie4233ff4d4bf49792a6549d7bcd169ff4b1afd20
2023-09-23 00:52:38 -04:00
William Wilgus
e01055a287 [RFC] REPEAT_ONE manual track skip
I recently added track skipping while REPEAT_ONE was set

currently by registering a track skip callback
I'm not entirely happy with the additional constant overhead
of the event callback

Instead I went looking for a way to distinguish
a pending track skip from some limited testing
it appears to work just as well to compare
playback's skip_pending == TRACK_SKIP_AUTO
but the lack of lifetime control worries me slightly

Change-Id: Ic71b4c3925e991f5a1216d16ecd3af6cc777ef1e
2023-09-19 19:47:22 -04:00
William Wilgus
f96f7cd941 [Feature] Skip to next file even if loop one is set.
repeat one till manually skipped

https://forums.rockbox.org/index.php/topic,54218.0.html

Change-Id: If2ea1cd892531c735c30c428dea3678806283a3b
2023-09-18 22:48:21 -04:00