Commit graph

311 commits

Author SHA1 Message Date
Solomon Peachy
9e3bb65228 database: Validate paths against MAX_PATH as well as TAX_MAXLEN
TAG_MAXLEN is 2* MAX_PATH, so this means we don't reject paths
that we could never actually open on the device.

Change-Id: I64363758163c0a6a5f54ebb1c9b455f3cb5b6e56
2025-08-25 10:46:16 -04:00
Solomon Peachy
31939086af database: Add much more verbose logging into database.log
Also turns database.log on for dbtool builds

Change-Id: I2d3fcfdd14cc7c354c84e37663b72920da564b84
2025-08-25 10:46:10 -04:00
Christian Soffke
963a66f670 tagcache: fix building with LOGF_ENABLE when LOGF_CLAUSES not defined
Change-Id: I1cfcd45069b54115cf368f52c74826d3b3eacd6e
2025-08-19 07:40:16 -04:00
Christian Soffke
8145e326a3 tagcache: skip search roots that don't exist, instead of aborting
https://forums.rockbox.org/index.php/topic,55459

Change-Id: I0c3fa07f9920ed4caabf3013702b10e59c0b550e
2025-08-15 20:46:37 +02:00
Solomon Peachy
80eca90481 tagcache: Don't try to look up "deleted" filename entries
When a file is deleted from the database, the first character of that entry
is changed to \0.  However the entry's length is not updated,
because the entry is still using space in the index.

When checking for deleted files, we were only keying on "length == 0"
instead of also checking to see if the entry itself starts with \0.

Change-Id: Ic00a0b29c3857c597ee5ff6ec01a5f4fd9633447
2025-08-13 11:38:56 -04:00
William Wilgus
50da856992 [BugFix] itoa conflicts with mingw rename to itoa_buf
Change-Id: Ife361f2fd8c8946db5bb2e0e58c0981b2ed3c5f3
2025-02-18 10:41:18 -05:00
Paul Sauro
d5fc0e4cb3 tagtree: "By First Letter" : fix numerical entry + add a "Special character" entry
- The "Special character" entry will show all special characters (non numerical + non letters)
- The numerical entry was bug, and could show some special characters from the ASCII table. It is now fixed.

Change-Id: I001fb322fab81918996e15e4d0ca6b7c9e5160af
2025-02-08 12:14:32 -05:00
William Wilgus
f55fe21f66 add itoa(), replace snprintf("%d") calls
we can save some space and still end up with a 20% faster function

Change-Id: Ia58900122944b8527ef01a673afe18ea794acb41
2025-02-03 01:23:49 -05:00
Christian Soffke
2ce1a1e638 tagcache: fix logf format specifier mismatch
Mostly replace "%ld" with "%" PRId32 for int32_t,
or add casts to improve portability and prevent
incorrectly displayed values on some systems.

NB: (Some of) the log output is also presented
to the user in the db_commit plugin.

Change-Id: I98f663b35fec682c98f8a065253ee0c9bd34b61b
2024-12-03 16:55:14 -05:00
Christian Soffke
f1010005b0 Fix simulator crashing on MacOS
Event handling must happen on the main
thread for MacOS.

Not sure if button_queue_wait is the
best place for doing the SDL event
polling, but seems to work ok.

Change-Id: If928282df84bdd74e24a48afd7dbc4c4bfcc49e2
2024-12-01 20:18:11 -05:00
William Wilgus
9af325a541 [BugFix] tagcache_search() must be closed with tagcache_search_finish()
fix a couple of places where this could be left open

Change-Id: I43ac7d6b26d728c11f96e5415710341d60f07ab8
2024-09-25 01:33:47 -04:00
William Wilgus
79bed1f422 RFC skin_tokens remove a static buffer
it was hard to hit this branch, I had to comment out:
ln 555    else if (offset == 1)
ln 556        pid3 = state->nid3;

as far as I can tell the reason for the separate filename buffer
was due to the failure mode of audio_peek_track() wiping
the id3->path, stands to reason for me that we can just fill it
again

-Already found a gotcha playlist_peek() mutates the buffer
 makes me like this solution less, might rework tagcache_fill_tags()
instead

--Fixed

Change-Id: I4a2ee71a8e2d0739c9e141948b71c2ed36296e3b
2024-09-12 19:16:02 -04:00
William Wilgus
fdbaf7df59 [Feature] playlist_viewer id3 title display
Not sure this is a great idea from disk and battery standpoint
but there is no reason you can't..

using the name buffer to fill title data
prevent hitting the disk for each screen scroll

add get_metadata_ex to allow flags
 METADATA_EXCLUDE_ID3_PATH
  prevent copying the filename to the ID3 struct
 METADATA_CLOSE_FD_ON_EXIT
  instead of seeking to the beginning the file is closed before
  get_metadata returns

add logic to allow a invalid fd to signal that get_metadata
should open and close the file within its call

bugfix per Chris_s don't use the tagcache for the trackinfo

Change-Id: Ic7a595b39a8d7a57f975312bc9c8bb4111f22a88
2024-07-09 01:40:02 -04:00
William Wilgus
935fb736e8 [FixRed] tagcache.c
I think this should be APPLICATION for hosted

Change-Id: Id0d2107bff004abf6762a8c0643b0bd872c6a24e
2024-06-13 07:52:46 -04:00
William Wilgus
633b06dcfe [Bugfix] tagcache.c reverse conditional for native targets
Change-Id: Icad11d2182586a1401bc46053273207a1283c73e
2024-06-13 07:17:01 -04:00
William Wilgus
efcea66280 Revert "readdir_r use in tagcache.check_dir, ft_load"
This reverts commit 0c737d3b2e.

Reason for revert: Not really a concern as open_stream returns an independent buffer since g#566

Change-Id: Idbd2f4a7cc2ea6362b7714629469eeb7b3d19b3b
2024-05-02 13:38:32 -04:00
William Wilgus
0c737d3b2e readdir_r use in tagcache.check_dir, ft_load
Change-Id: Ibcde39ed247e100dd47ae877fb2a3625bbb38d8b
2024-05-02 09:33:29 -04:00
Christian Soffke
3ce3b102dd Provide "quick" option for loading database into RAM
The directory cache and the database's Load to RAM feature
each result in a much better user experience.

But, when both features are enabled at the same time, it
can take a very long time on older players - easily several
minutes for larger libraries - until all of the database's
dircache references have been updated.

Include a 'Quick' option that causes the database to ignore
dircache references which can *significantly* reduce disk
activity after booting.

Change-Id: I25ae779c97d03885b06d5a28d8be55c0d05692a5
2024-04-23 23:02:47 -04:00
Aidan MacDonald
5641e8140a tagcache: Rename find_tag() -> tc_find_tag()
The overly-generic name "find_tag()" is part of the skin parser
library and this can cause problems depending on what's included
from headers. Unfortunately.

Change-Id: I0cb02b1203daa6ff36595ed6c6f40b5b56bd3e58
2024-04-01 18:21:37 +01:00
Aidan MacDonald
ac1f92d9e8 tagcache: Fix missing void in tagcache_rebuild() definition
Change-Id: I04629547979a71f61693d87abb298b7c1d5efce4
2024-04-01 17:06:29 +01:00
Solomon Peachy
57f76784c5 Fix build for hosted targets.
Basically the namespace code _never_ actually linked properly on hosted
targets, but nobody noticed as there were no users, causing the symbols
to be dropped with no fuss.

The tagcache namespace awareness stuff pulled in the namespace code,
which made things go kaboom due to it relying on native FAT parsing
code.

Change-Id: Idef5f44b026c875022436809ca1f5015eece714a
2024-03-23 19:59:31 -04:00
William Wilgus
fdc3668a6a [BugFix] Multiboot Database duplicate files
When the sd card is mounted into the root namespace the database
picks up files through both paths

previously we hid the mounted drive but this causes issues with users
databases when the drive letter changes

Adds a way to keep track of volumes mounted in the root namespace

Hides the enumerated volume in root

Database:
we can just parse the root directory ('/') and get to any mounted
volume but we can also enumerate a volume in the root directory
when this occurs it leads to multiple entries since the files can
be reached through multiple paths ex, /Foo could also be /SD1/Foo
Instead we will attempt to rewrite the root with any non-hidden volumes
failing that just leave the paths alone

Change-Id: I7bdba8cfaf63902d2a3852d28484bcf8ca317ebd
2024-03-23 01:03:33 -04:00
William Wilgus
a0c29d8857 db_commit swap threads, add ability to cancel, backup/restore
extends the db_commit plugin with the ability to delete the database
backup, restore, dis/enable auto-commit

Change-Id: Id61546e463d151399d2ac8459480e6adc5d6fac6
2023-10-10 05:48:37 -04:00
William Wilgus
17a8a54780 [BugFix] tagcache/tagtree remove static buffer from tagcache_get_next
remove sizeof(buf) infavor of the actual size provided by bufsz

Change-Id: I9fc1b2ce0937526d7acbb98738c8eb1aef15683f
2023-10-06 09:17:25 -04:00
William Wilgus
1ed640da24 [Feature] db_commit plugin allows a more verbose commit
prints logf messages to the screen buffer and dumps the
output to .rockbox/db_commit_log.txt

logs warnings about tags that can't
be displayed by the current font

adds an option to the tagcache using the file
.rockbox/database_commit.ignore to prevent auto commit

Change-Id: Ib381b3b6d9dd19d76c95d0e87e605f7378e29674
2023-10-05 21:24:37 -04:00
William Wilgus
6634a60bf0 tagcache/tagtree remove static buffer from tagcache_get_next
callers can supply their own buffer

Change-Id: I8996ecfb88e30926296a0cb0563cf6c46977323e
2023-10-03 21:54:19 -04:00
William Wilgus
eee48dca39 tagcache reduce stack usage in tmpbuf_insert and build_index functions #2
move some functions around for later ifdef for tagcache commit plugin

used fixed width variables in struct temp_file_entry

Change-Id: I7f66b15cd1bdf5abcefa700086d390d22d3b5e21
2023-10-03 13:56:00 -04:00
William Wilgus
b64d46d9d4 Revert "tagcache reduce stack usage in tmpbuf_insert and build_index functions"
This reverts commit 3bb3e3d1a6.

Reason for revert: lifetimes do not overlap but patch has issues

Change-Id: I3f831599dd1523c156205aa6565ff8afc2f4d8f6
2023-10-03 11:07:49 -04:00
William Wilgus
3bb3e3d1a6 tagcache reduce stack usage in tmpbuf_insert and build_index functions
move some functions around for later ifdef for tagcache commit plugin

used fixed width variables in struct temp_file_entry

Change-Id: Idf9c37d67fc048550366e3d3504601a19c31f31e
2023-10-03 10:08:13 -04:00
William Wilgus
1c47722226 [Feature] add a prompt to database commit on start-up
adds a new function:
gui_syncyesno_run_w_tmo(ticks, tmo_default_res, main_msg,yes_msg, no_msg)

when a database needs committed on start-up
a yes no prompt will appear if not answered within 5 seconds
it defaults to Yes

if instead you choose No next start-up you will be asked again

you could rebuild the db still and waste time but it wouldn't hurt
anything so I don't think that path needs blocked

Change-Id: I58411f6e6bfebb6f142d99f33a1e8885ae7785c1
2023-10-01 11:51:38 -04:00
Aidan MacDonald
d3b588678f Remove structec API from tagcache
Replace structec usage with explicit endian swapping routines
for the various data types. Simplify endianness detection when
loading the database. Make foreign endianness support optional,
but leave it enabled for now.

Change-Id: Ia1efb72c8830f63bbe0e51f7271c4552b5279878
2023-10-01 12:10:41 +01:00
William Wilgus
1c26f565bf tagnavi make track submenu
add some faster options to the track menu
add a shortcut for basename formatting
sort basename results

filename - by sorted filename
title - just title no formatting untagged items are unsorted as well
title mm:ss - title and duration

Change-Id: I90aea95051f6231580ef7f1fc08cd2d0d69601fb
2023-02-07 08:44:57 -05:00
William Wilgus
d5a84d42b0 [BugFix] tagcache.c fix off by one error in find_entry_disk()
the tagcache counts the null terminator strlen however, does not
no matching entries makes for a terrible amount of disk searching
and a hang on devices without dircache to save them

Change-Id: Id3460037199ee9853de0f11e4763a7ff11130e45
2023-02-04 11:39:43 -05:00
William Wilgus
4e5fcbe898 fix red #2 d6fb80d4
Change-Id: I147e9b8f7c8e64234f55d39f9ac7c7253b065f9a
2023-01-27 01:12:42 -05:00
William Wilgus
1d6ce5193f fix red d6fb80d4
Change-Id: I805490f660626f48220b41de3ee1026c260d0067
2023-01-27 00:40:20 -05:00
William Wilgus
d6fb80d4ff Tagcache - Ramcache Move ref checks, speed up disk searches
move loading file reference to a separate function

some optimization of the disk search function check tag length before
reading the actual entry & reduce number of lseek calls
this affects startup resume as well before tagcache is done loading

Change-Id: I2bd2fc53c4870416ecd1a4034b34cb6984d8ad51
2023-01-27 00:03:51 -05:00
William Wilgus
d521020d21 [Feature] Add total entries to database info
show total database entries in debug>Database Info

Change-Id: Ic22b6a032ae0ee23e0f38c0da6a9cf1433ba29e2
2023-01-15 22:57:00 -05:00
Aidan MacDonald
1e9ad3ca0d Remove buflib allocation names, part two
Remove allocation names from the buflib API and fix up all callers.

Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a
2023-01-13 10:32:54 +00:00
Aidan MacDonald
879b5dae39 Fix red 8f582c90de
global_settings is not defined when building the database tool.
Add a path buffer in tc_stat to fix this. This also avoids race
conditions that may occur if changing the path setting at runtime.

Change-Id: Ib2ca92c2e34929c79b19ef145fd7ccdcd62c8d04
2022-12-03 13:13:16 +00:00
Aidan MacDonald
8f582c90de tagcache: add a setting for customizing the database path
Add a new setting,

    database path: /path/to/folder

to change where the database files are stored, which allows it to
be shared by multiple builds when using multiboot. This avoids the
need to maintain a separate copy of the database for each build.
This setting can only be set from the config file; it has no menu
option yet (due to lack of a GUI to pick the directory).

Change-Id: Ide7b3ccdd84abb62b52f900421bd3d101773e093
2022-12-03 07:29:42 -05:00
Aidan MacDonald
98c7505c60 tagcache: move TAGCACHE_STATEFILE define to .c file
Provide a function to remove the statefile so that external
users of this define can call that instead.

Change-Id: Id3e1e0564b25fe28bbc68c2e9365d8bf51e6e4f8
2022-12-03 06:34:47 -05:00
Aidan MacDonald
90dc64da32 tagcache: remove TAGCACHE_STRICT_ALIGN flag
This has been defined to 1 since forever, so the last remaining
check presumably isn't catching anything.

Change-Id: I0b60f831a6e5e8fc45788e7581fccb0cb62bce73
2022-12-03 11:00:35 +00:00
Aidan MacDonald
b6c2b54e01 tagcache: move most defines to .c file
Most of the defines in the header file are internal to the tagcache
and therefore should not be exposed in the header, to make it clear
that outside code does not depend on the values.

Change-Id: I83b0c83c61c755231e03719a6845a555f983194a
2022-12-03 11:00:27 +00:00
William Wilgus
3745c813f9 misc.c open_pathfmt caller supplied buffer
Amachronic raised concern about open() blocking causing a static buf
to get overwritten in multiple calls its prudent to just have the caller
supply the buffer to minimize stack issues later

Change-Id: Iae27c7d063adb1a65688f920f6aa5c395fa5694a
2022-11-23 22:09:46 -05:00
William Wilgus
e7e20fab1b create function open_pathfmt() to allow printf formatting on open()
save some space by allowing printf formatting directly rather than
having a buffer and using sprintf

Change-Id: I049c8f898fb4a68a26ad0f0646250c242647ba12
2022-11-19 23:13:42 -05:00
William Wilgus
3ad8c0ad7b fix another non shadowed variable
another variable that shouldn't have been removed in 034b6d5b

Change-Id: Ie16aa2687cec7f55e9cc2477951c228de18755cd
2022-11-15 19:17:41 -05:00
William Wilgus
f6c719d7ec replace strlcpy with strmemccpy
replace applicable calls to strlcpy with calls to strmemccpy
which null terminates on truncation

in theory the strmemccpy calls should be slightly faster since they
don't traverse the rest of the source string on truncation
but I seriously doubt there is too much of that going on in the code base

Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2
2022-11-14 23:56:16 -05:00
William Wilgus
034b6d5bfb Remove some shadowed variables identified by -Wshadow
there are plenty more but these are the low hanging fruit

Change-Id: I86d9f4f56e8cd9b381d1bf6a6679cd58c6a4004d
2022-11-14 09:01:43 -05:00
Christian Soffke
498988d34a PictureFlow: Minor fixes & changed defaults
- Fix FPS counter overlapping
the artist string when
"Show album title" was set to
"Show album and artist at the top"

- Fix disappearance of center album
if certain Settings menus had been
accessed while list of tracks was
showing and you then returned to the
list of albums

- Fix disappearing album artwork after
cache had been created until you started
scrolling

- Enable context menu even if WPS
integration is disabled

- Make splash screen appear only
on first launch and for database
updates, when it is actually on screen
for long enough

- Eliminate 'Loading' splash if tagcache
is in RAM

- Show both album and artist by default on
displays whose height > 100px

Change-Id: Ie70c0d9093789294d288a4f88338ee4a588bf4a5
2022-10-22 09:33:50 +02:00
Aidan MacDonald
1718cf5f8a Convert a number of allocations to use buflib pinning
Several places in the codebase implemented an ad-hoc form of pinning;
they can be converted to use buflib pinning instead.

Change-Id: I4450be007e80f6c9cc9f56c2929fa4b9b85ebff3
2022-10-16 14:50:39 +01:00