Commit graph

195 commits

Author SHA1 Message Date
Aidan MacDonald
a64cad847e playlist: Simplify playlist modified detection
Any modifications to the playlist (insert, delete, shuffle, etc)
will cause the modified flag to be set. The flag is cleared when
the playlist is saved. Code that generates playlists can manually
clear the modified flag if appropriate; there is now a proper API
for this so the tagcache and pictureflow don't need to resort to
hacks.

Change-Id: I8d3c723265a41db07a13de3f1d2abb0444528d57
2023-03-23 13:01:23 -04:00
William Wilgus
3bb75e0039 tagtree.c optimize get_tag()
store tag length to shortcut strcmp

this is nearly as fast as making a hash table using gperf

its not the hottest path but its
even slightly faster to shortcut
based on string length

    if (tagstr_len > match->len)
        continue;
    else if (tagstr_len < match->len)
        break;

but I found no measurable difference
I don't think its worth the extra constraint of keeping tags sorted

Change-Id: I4bb47cc6c5b8266d5f13c4ac78ae11d55ecb2d67
2023-02-09 06:56:58 -05: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
b5d93a6605 Revert "tagtree remove unneeded strlen"
This reverts commit 8379c6eb07.

Reason for revert:
tcs.result_len is not the same as strlen(dptr->name) + 1
since it gets filled with filename

Change-Id: I1264afc0a43ffe75adf1de00d27ab98e3adbca19
2023-02-05 06:47:38 -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
Christian Soffke
32f365bf3c database: make parent tables work with plugin
Enables the use of PictureFlow and the Properties plugin
with parent tables of ALLSUBENTRIES, such as an album
or album artist, instead of individual tracks.

Change-Id: I18c4779ed116a48c732ae32b9629e7e0d93ce7c8
2023-01-19 15:56:35 -05:00
Christian Soffke
7f265ee8dd Database: Add ability to insert multiple files into playlists
You could only add single files to playlists
from the database browser before. This
enables adding any database selection to
a new or existing playlist.

Change-Id: I811c7167641c589944bb2afc18dcc1d299a7b979
2023-01-14 12:14:28 -05:00
William Wilgus
40355caefd buflib_shrink use NULL to signal start isn't changing
Change-Id: Id3e86d3860b8ed860dc6dcbc394b1b8f9f3274b5
2023-01-13 09:50:29 -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
Christian Soffke
1773e56447 tagtree: Discard item history when selection changes in both directions
A changed selection only caused the item
history for deeper levels to be discarded
in tagtree_enter, when you were descending,
but not in tagtree_exit when you were ascending
the menu hierarchy again.

Change-Id: Ia40fa47980a05c2569e8af04e928b06130aa1f33
2022-12-30 21:57:55 -05:00
William Wilgus
3957aa8720 RFC BugFix tagtree.c reload data abort
TagNav.lua adds Reload to the Custom View menu of tagnav to allow users to make new search queries on the fly
previously you had to reboot the device to do this

I was getting a data abort prior to calling tagnav_init now but it worked fine if I copy pasted
the contents of the init function

I'm not sure how this fixed it but making a static init function makes it work as intended
is it a race some weird thing with the compiler??

Ideas??

Change-Id: I7fd6c50f929d3ac2d9ecec5336942288e9213ad5
2022-12-03 07:41:33 -05:00
William Wilgus
8379c6eb07 tagtree remove unneeded strlen
unfortunately most of the overhead in searching for <Untagged> occurs in
reading of entries so changing searching the resulting string faster doesn't
do much good but any we don't need this strlen call since its already been
computed

Change-Id: Ia2815a6e7d75237366977632f9b0bc7999254096
2022-11-23 11:01:19 -05:00
William Wilgus
263cc13985 tagtree.c move sort_inverse out of compare function
Change-Id: I9c91a96a45fe98d51d27974bc2d6d79eaa5039d3
2022-11-22 19:14:26 -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
c088a9453d Database: Restore selection in lower menu levels
The database only remembered what you'd selected when
ascending the menu hierarchy again from a lower level.

Now it restores a previous selection going in the other
direction as well, when you enter a new menu, as long
as the selection at the current level hasn't changed.

Change-Id: I5068287ff758a7cfebf1428e9b0ffd30e6ef541e
2022-11-14 05:47:10 +01:00
Christian Soffke
e6ab74d4ac Database: Eliminate redundant list item selection
- gui_synclist_select_item will be called in the update_dir
function by dirbrowse()

- it is unnecessary to call when the tables opened by
tagtree_enter are not being displayed but are only being
used for inserting table contents into the current playlist.

Change-Id: Ib768b457b2baa7eb85cf73c6339fd4f603d03d90
2022-11-14 05:36:46 +01:00
Christian Soffke
97936e0661 Database: Fix problematic dirlevel reset
Dirlevel is restored in this error case without
exiting the previously entered tables.

Change-Id: I516c3ed635bc5c49dcf551223258215f79bff046
2022-11-14 05:35:28 +01:00
William Wilgus
dd1fbd51fc TagTree Show file name for tag_title [UNTAGGED] BugFix
limit result to tags that only show <UNTAGGED>

Change-Id: I56ff4ea8c5a17df806d69d58599a9a88f8acc4b0
2022-11-11 18:36:07 -05:00
Christian Soffke
9da3044cf7 Database: Remove firstpos/pos_history
From what I can tell, this is unused historical
baggage that has no effect whatsoever these
days.

Change-Id: I1b6fed64e7bf5cc4db4ec028617c818c59d81324
2022-11-02 07:19:36 -04:00
Christian Soffke
ca908d6336 Database: Fix FS#13368 – use separate selected item history
Database and File Browser were sharing
each other’s selected item history before.

Since the database isn’t browsed
recursively, it’s probably unnecessary to
include its own history in the tree context
and its backups, saving.a little bit of memory.

Change-Id: I87c9aed6f7056bc481b8b7299089851ef28f9bc5
2022-11-02 07:19:36 -04: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
Christian Soffke
653082ad1d Database: Adjust "Play Selected First"&"Shuffle" behavior
- With "Play Selected First" and "Shuffle" enabled,
another item was randomly selected when returning
to the list. This appears to be a bug

- With "Play Selected First" disabled, the first item was
selected. This appeared to be intentional, since, at least with
"Shuffle" disabled, that is the item that was played
back. This may not be helpful either, since it makes you lose
your place in what can be a long list. It is also  not
consistent with the behavior of the File Browser. The current
selection should probably be maintained in all cases.

- At least according to the manual and the behavior of the File
Browser, "Play Selected First" should only apply when "Shuffle"
is enabled.

Change-Id: Ic1205477d5bf8b22f8f32dd6d31d3b9ceb5a2d24
2022-10-21 03:59:49 +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
William Wilgus
f9ea1fc79d splash_progress add delay function
I figure this is a better way to allow a delay before showing the
progress meter

Change-Id: I909902a52619023b0b87635d2eb94ed00cb4bcec
2022-10-13 00:10:25 -04:00
Christian Soffke
eb5e15803b Use splash_progress in database when inserting into dynamic playlist
Change-Id: Iaef66cc00a1be0ce3cf869f0e6137a2e9efa2713
2022-10-10 07:49:04 -04:00
Christian Soffke
8f6d0efd71 tagtree: Delay showing search progress when ramcache is enabled
The disk doesn't need to spin up when the
database is in RAM. Results are usually returned
without any noticeable delay, so the splash  only
creates distraction.

Change-Id: I04e5b7d2e00f045143dd86e0561091be3d8f9724
2022-08-19 00:27:34 -04:00
Aidan MacDonald
b79eefc858 apps: fix tagtree arithmetic on null pointers
It was possible for the tag tree's buflib move callback to turn a
null pointer non-null. The tagcache_search_clause->str can be null
for OR clauses. Also ensure that clauses are zeroed on allocation
to ensure garbage pointers don't creep in.

Change-Id: Ic823a8eecc501eeaa75798066521e427a9a89190
2022-05-02 16:48:19 +01:00
William Wilgus
ddbca125a6 tagtree/tagcache add new clause operators begins/ends _oneof
new operators @^, @$
begins_oneof and ends_oneof

albumartist @^ "L|The L"
Led Zeppelin, The look

albumartist @$ "girls|Boys"
spice girls, beasty boys

Change-Id: I26ce3d8155d970a55e003f74e2f9478db76204f1
2022-03-19 02:24:14 -04:00
William Wilgus
f88ea12bac tagcache compress uniqbuf 2 16-bit indices occupy a single 32 bit slot
a lot of space is wasted when file indices less than 65535
entries should be more than 1 byte apart so use the LSB as a flag
when indices are > 65535 set flag to 0 and proceed as before

explicitly mark uniqbuf as 32bit

Change-Id: I54e06c152c369eb6c0322186fe2c1e9a1e6d940d
2022-03-02 20:22:49 -05:00
William Wilgus
045f52d475 tagtree.c optmize clause operator parsing
makes WS after a clause conditional optional

Change-Id: I335b5381fb788c19130aa8d57dfb18bb43a07c18
2022-02-28 06:35:11 -05:00
William Wilgus
887249671c TagTree Show file name for tag_title [UNTAGGED]
fallback to filename as [UNTAGGED] is a terrible way to browse titles

Change-Id: Ifcdc4c27562339b8a916313fb946c88c4eba3b5a
2022-02-25 22:54:47 -05:00
Christian Soffke
7d59bbd170 Database: Fix selection being reset
Consistent with (preferable) behavior of file browser
after selecting an item for playback

Change-Id: I45a72f6d743fd70c301f9d5de0f8a2a02157b2c6
2021-12-28 10:57:13 -05:00
Aidan MacDonald
f4fbc1bceb tagtree: Support user override config file
Allow users to create an alternative tagnavi config file named
"tagnavi_user.config" in the .rockbox directory. If present, it
will be used instead of the default tagnavi.config, allowing the
default menu to be completely redefined.

This makes it much easier to maintain customizations which remove
or modify parts of the default config -- since the default config
is shipped in the Rockbox zips, a customized tagnavi.config would
have to be saved with manual intervention on each & every update.

Change-Id: I509177fab0e01fc0db0bc4407a3a92bbff5fa481
2021-12-24 10:41:27 -05:00
James D. Smith
fcb9c06852 Database: Fix tag_albumartist; new tag_virt_canonicalartist.
Change-Id: I1d887f8a9d6690b8286407d2502432b0497cfeb9
2021-09-17 21:42:05 -04:00
William Wilgus
a4a5f5f33f Check core max allocations for valid handle
fix rolo warnings

Change-Id: Ia2c669a5517aec54e5b2c0dc5934c88a4f49f2a9
2021-03-04 14:25:58 +00:00
Christian Soffke
436e64e09e Fix playback queue bug when "Insert Next" is used with multiple songs at once
After using “Insert Next” to insert multiple songs at once (e.g. an album from the database browser or folder from the file browser), subsequent Insert operations will incorrectly insert items after the first song of all items that were previously inserted, instead of after the last song of the previously inserted items.

A bug fix was originally written by Costas Calamvokis for the file browser only. I adopted the original fix and added code analogous to it so that it works from the database browser as well.

See FS#7898, FS#7363 or this forum post for more info:
https://forums.rockbox.org/index.php/topic,53741.0.html

Change-Id: Ie2718e136df0b340000f7a171e9e806cf23a27b4
2021-02-17 11:34:59 +00:00
Solomon Peachy
8cb555460f [3/4] Completely remove HWCODEC support
'swcodec' is now always set (and recording_swcodec for recording-capable
units) in feature.txt so the manual and language strings don't need to
all be fixed up.

Change-Id: Ib2c9d5d157af8d33653e2d4b4a12881b9aa6ddb0
2020-07-24 21:20:13 +00:00
William Wilgus
cb94b3ae2e keyboard add ability to specify temporary custom layouts
rb core allows you to load custom keyboard layouts

this patch adds the ability to load a keyboard layout in a buffer
the custom layout is temporary and does not overwrite the current layout

use like so:

    unsigned short kbd[64];
    unsigned short *kbd_p = kbd;
    if (!kbd_create_layout("ABCD1234\n", kbd, sizeof(kbd)))
        kbd_p = NULL;

    rb->kbd_input(buf,sizeof(buf), kbd_p);

Change-Id: I7be2bd4a1b4797a147fa70228a9749dc56ac052a
2020-07-22 06:48:28 -04:00
William Wilgus
501404d703 tagtree add %reload to allow hot reloading of tagnavi config
adds (static) function tagtree_unload
 frees all buflib allocations for tagtree

adds command %reload that allows a new tagnavi file to be loaded
without device restart
use it like so..
"Reload..." -> %reload

Allocations are now checked for validity (probably a good idea anyway)

Change-Id: I2b4b9b7e253f97f3e6575e0ea7a92905e004d47f
2019-08-02 05:16:16 +02:00
William Wilgus
3e27705eb9 tagtree.c->loadroot() guard against overflow
forum user chris_s noted an possible unhandled cache overflow

Change-Id: Ia79399d6581ef6b635578896519fda8126c731d7
2019-07-10 09:38:36 +02:00
William Wilgus
dd40c46d50 Fix menu warnings
change offending bool return to int

warning: cast between incompatible function types from
'_Bool (*)(void)' to 'int (*)(void)' [-Wcast-function-type]

forgot to remove -- typedef int (*menu_function)(void);

Change-Id: Ie4c8d3ddb0fb7843c4ec584203350d658d6bee3e
2018-10-18 00:06:31 +02:00
Michael Sevakis
6436c6e749 Fix tagtree from blowing up when its buffer moves
I noticed that after booting with the external storage removed,
playing from tagtree, inserting the card, forcing dircache to
reallocate from the debug screen, and trying to reenter tagtree,
it would data abort because the dircache reallaction to a larger
size caused the tagtree buffer to move.

Adjustment to at least one pointer (csi) was missed. Since it's
non-trivial there to determine when things should be NULL and
when they shouldn't, add check for menu too before moving it.
As for the rest, who knows.

Change-Id: Iea6538a2091b4b47083f39296555efc47edf8ba8
2017-02-10 20:58:03 -05:00
Thomas Martitz
470989bd70 events: Rework event subsystem (add_event, send_event) to be more versatile.
add_event_ex is added that takes an extra user_data pointer. This pointer is
passed to the callback (add_event and add_event_ex have slightly different
callbacks types). All callbacks also get the event id passed. Events added
with add_event_ex must be removed with remove_event_ex because the user_data
pointer must match in addition to the callback pointer.

On the other add_event is simplified to omit the oneshort parameter which
was almost always false (still there with add_event_ex).

As a side effect the ata_idle_notify callbacks are changed as well, they
do not take a data parameter anymore which was always NULL anyway.

This commit also adds some documentation to events.h

Change-Id: I13e29a0f88ef908f175b376d83550f9e0231f772
2014-03-14 23:36:30 +01:00
Michael Sevakis
31b7122867 Implement time-based resume and playback start.
This complements offset-based resume and playback start funcionality.
The implementation is global on both HWCODEC and SWCODEC.

Basically, if either the specified elapsed or offset are non-zero,
it indicates a mid-track resume.

To resume by time only, set elapsed to nonzero and offset to zero.
To resume by offset only, set offset to nonzero and elapsed to zero.

Which one the codec uses and which has priority is up to the codec;
however, using an elapsed time covers more cases:

* Codecs not able to use an offset such as VGM or other atomic
formats

* Starting playback at a nonzero elapsed time from a source that
contains no offset, such as a cuesheet

The change re-versions pretty much everything from tagcache to nvram.

Change-Id: Ic7aebb24e99a03ae99585c5e236eba960d163f38
Reviewed-on: http://gerrit.rockbox.org/516
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2014-03-10 04:12:30 +01:00
Thomas Martitz
84c7d6133b tagtree: Use strnatcasecmp() for the database browser too.
Even though you can insert leading zeros that makes ascii sort work for
numbers, sometimes the leading zeros don't suffice. In order to always
sort numerically strnatcasecmp() is needed.

With the default tagnavi.config this affects albums with discnum > 9
or tracnums > 99. This FS#12888.

Change-Id: Ie265c86eaf6dd07b6beda9e5eef25eb81eef8fd4
2014-01-15 23:18:35 +01:00
Michael Sevakis
023f6b6efd Get rid of some superfluous single-purpose functions in playback.
* Remove explicit tracking of elapsed time of previous track.
* Remove function to obtain auto skip flag.
* Most playback events now carry the extra information instead and
  pass 'struct track_event *' for data.
* Tweak scrobbler to use PLAYBACK_EVENT_TRACK_FINISH, which makes
  it cleaner and removes the struct mp3entry.

Change-Id: I500d2abb4056a32646496efc3617406e36811ec5
2013-07-13 00:08:51 -04:00
Michael Sevakis
ffa8626b0c Fix whitespace in files for following commit.
Change-Id: I4adb8a152e9b99fcd26d95da7334d7d0cbe2a036
2013-07-12 21:39:06 -04:00
Thomas Martitz
baa070cca6 GSoC/Buflib: Enable compaction in buflib.
This enables the ability to allocate (and free) memory dynamically
without fragmentation, through compaction. This means allocations can move
and fragmentation be reduced. Most changes are preparing Rockbox for this,
which many times means adding a move callback which can temporarily disable
movement when the corresponding code is in a critical section.

For now, the audio buffer allocation has a central role, because it's the one
having allocated most. This buffer is able to shrink itself, for which it
needs to stop playback for a very short moment. For this,
audio_buffer_available() returns the size of the audio buffer which can
possibly be used by other allocations because the audio buffer can shrink.

lastfm scrobbling and timestretch can now be toggled at runtime without
requiring a reboot.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30381 a1c6a512-1295-4272-9138-f99709370657
2011-08-30 14:01:45 +00:00
Thomas Martitz
d0b72e2590 GSoC/Buflib: Add buflib memory alocator to the core.
The buflib memory allocator is handle based and can free and
compact, move or resize memory on demand. This allows to effeciently
allocate memory dynamically without an MMU, by avoiding fragmentation
through memory compaction.

This patch adds the buflib library to the core, along with
convinience wrappers to omit the context parameter. Compaction is
not yet enabled, but will be in a later patch. Therefore, this acts as a
replacement for buffer_alloc/buffer_get_buffer() with the benifit of a debug
menu.

See buflib.h for some API documentation.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30380 a1c6a512-1295-4272-9138-f99709370657
2011-08-30 14:01:33 +00:00