Commit graph

16744 commits

Author SHA1 Message Date
Aidan MacDonald
8dbc0914f6 imageviewer: limit progress bar LCD update rate
The progress callback doesn't rate limit LCD updates, which causes
excessive slowdowns (up to 150x!) on some targets. Limiting updates
to 20fps solves the problem and should boost load speed across the
board, particularly for large images and animated GIFs that may run
the progress callback thousands of times.

Change-Id: Ia48924d4dcb24c1111509329581809be494d0165
2022-04-09 23:15:48 +01:00
Aidan MacDonald
32f1418c5a buffering: fix buffer overflows with bitmap loading
In some circumstances it was possible for a bitmap to overflow its
buffer and overwrite the next handle. The easiest way to trigger it
is with a highly compressed JPEG that is decoded to a large bitmap.
Because the JPEG file size is used to determine how much to allocate
this would cause an obvious buffer overflow when the JPEG is smaller
than the decoded bitmap. Fix this by using the decoded bitmap size as
the allocation size. Some overhead must be added to deal with JPEGs,
but it will be freed once the image is loaded.

A less obvious possibility is the fact that add_handle() will allow
a handle to be added even if there's not enough space for the entire
allocation. This is generally beneficial because it allows the first
part of a file to be loaded while waiting for space to free up, but
for bitmaps it is not valid because the whole image is loaded at once.
Hence if there is not actually enough space in the buffer, the bitmap
load can again overflow the actual free space and overwrite the next
handle.

The buffering code supports an H_ALLOCALL flag for allocations that
need the free space available immediately, so use it for bitmaps to
avoid that bug.

load_image() had a sketchy-looking check for free space which stopped
me from triggering the bug with simple tests, but since guessing the
free space is obviously a bad idea when the caller *knows* how much
free space there really is, remove that guess and let the caller tell
load_image() the real deal.

Change-Id: If62a58759705d83c16ee5b50f26bcbccc3f6c01f
2022-04-09 15:20:57 +01:00
Aidan MacDonald
5aa0fc3b00 jpeg: provide a rough estimate of decoder memory overhead
JPEG decoding requires additional space in the bitmap buffer beyond
what is needed for the decoded pixel data. Provide a way to estimate
how much overhead is needed.

The actual overhead is sizeof(struct jpeg) + decode_buf_size, where
the latter depends on the image size and JPEG encoding used. From my
testing decode_buf_size is normally pretty small (under 5 KiB) but
looking at the code it could be large in some cases, primarily with
large images, so 32 KiB seems to be a decent compromise. Someone who
knows better about JPEG should pick a better value if that's too big.

Using a constant is obviously not the most accurate but it seems to
be the simplest option for retrofitting to existing code.

Change-Id: I573b0abb8ca2d79e43f185010487f07226edb793
2022-04-09 15:20:57 +01:00
Aidan MacDonald
7718b24401 buffering: fix signed overflow in next_handle_id()
Not sure what the comment is talking about - signed overflow
is undefined behavior and we don't use -fwrapv or other flags
to make it defined. I can't see how a compiler could abuse it
here, but the overflow is nonetheless easily avoided.

Change-Id: Ibed6d7c0d841db2aa86b9d8ba4c6a0d08c413354
2022-04-09 15:20:57 +01:00
William Wilgus
bd444ebd0a BUGFIX keyboard.c make vp alloc static
don't stop playback to alloc viewports for the keyboard
For the moment it doesn't make much difference
each vp takes about 40 bytes (double that in the sim?)
so not the end of the world 120 extra bytes

Change-Id: I482d7e3061cf9fb8065dc28bf62a6f830770f3c7
2022-04-08 18:11:21 -04:00
Nick Peskett
db55d30372 Allow cuesheet index offsets longer than 99 minutes.
While the track number is limited to 99, I know of no documented
constraint on the value of offset minutes to 99.

As we are storing the millisecond offset as unsigned long, assuming
32 bit, we can allow 70,000 minutes (2^32 / 60000).

However, I've been unable to generate a test audio file 48 days long
under 2GB, so I've set the limit to 30,000 minutes.

In addition, this change reduces the maximum number of seconds to 59,
and frames to 74.

I've generated some silent test files with the filenames being
cue_[minutes].mp3

http://peskett.co.uk/rockbox/test_cues/

Change-Id: I3ca4468ebc88ba134c4e785e9395f90bf76941ac
2022-04-07 20:10:19 -04:00
William Wilgus
d1be73cfc0 keyboard.c Use viewports, move text box pos
allows items to be moved around with less code changes

remove scrolling I was not overly impressed with it
add test_kbd plugin

Change-Id: Ic183c7221bda9405891632704f3a7bbfd79bfe83
2022-04-07 19:46:56 -04:00
William Wilgus
bf3e67204c lastfm_scrobbler check for back to back repeat entries
if you skip a track after the halfway point the scrobbler may double post
with slightly different timestamps but the same track info

take a crc of the non-unique part and check against the previously
written track

Change-Id: I676342c4cd76f632131d9cb6d9f7d2f59df357e6
2022-04-02 08:05:37 -04:00
William Wilgus
43abe2d820 lastfm_scrobbler check pointers for validity
we need to make sure we don't deref NULL pointers

Change-Id: I9c564b681cd20222c3a134680e60a310b2eb846c
2022-04-02 07:42:06 -04:00
Aidan MacDonald
5ffe520de4 playlist: use path_strip_last_volume, clarify path conventions
The comment regarding Windows paths was fairly confusing as to
its intent. What the code is trying to do is replace the drive
letter with the volume containing the playlist, which appears
reasonable. The middle of the comment was devoted to explaining
why the code below was potentially incorrect which only served
to add to the confusion.

AFAICT the last volume specifier in a path will cause search to
start from the root of that volume, so any incorrect result can
be avoided by using the new function path_strip_last_volume().

Finally, add a comment at the top of the function that explains
what it does.

Change-Id: If4e4938801f2f81eb52f5d32b5461872995e5e83
2022-04-01 11:40:02 -04:00
Christian Soffke
ca0c3dee0a ImageViewer: M3K keymap allow scrolling up/down
Change-Id: I385354688b1d8f8df4d44e7e177e23bdb6ed3df4
2022-04-01 11:01:52 -04:00
James D. Smith
6e3937e836 lastfm Scrobbler: Substitute album artist for empty artist.
Change-Id: I66dda13ec2cbb592ebe0d269f0c7eff749bc737a
2022-04-01 06:11:42 -04:00
Solomon Peachy
a9e02b4850 FS13338: Updated Slovak translation (Matej Golian)
Change-Id: I41f794a457435f0d02da180673e272438e3879b2
2022-03-31 21:33:53 -04:00
Solomon Peachy
f08d083ed0 FS13441: Updated Italian translation (Alessio Lenzi)
Change-Id: I442d79842ca1d58d122058171175a6fee844a353
2022-03-31 21:32:42 -04:00
Solomon Peachy
cbb5efd525 FS13340: Updated Polish Translation (Adam Rak)
Change-Id: I5b10231277c6c546400b3d74e3c0339f6026b729
2022-03-31 21:31:33 -04:00
William Wilgus
43830d0128 alarm_menu share setter with settime
share the time picker with the alarm

block the date portion, seconds are ignored

Change-Id: Idc6974466772c33248ff532c8f3c62c744ee06d9
2022-03-30 09:05:28 -04:00
Christian Soffke
df3afcfa3b PictureFlow: Configurable album sorting
Now offers sorting by:

- Album artist, then album name
- Album artist, then album year
- Album year
- Album name

Years are determined by the most recently
released track appearing on an album, if the
value differs between tracks.

On the M3K,  instead of by going into Settings,
volume buttons can also be used for quickly
adjusting the current sorting

Change-Id: I2c50059617114fb418336c466fdd37415473ac7d
2022-03-27 08:51:58 -04:00
Christian Soffke
aec8b36348 PictureFlow: Prevent queue overflow & simplify locking
Change-Id: I41f620a4fdaf155913a944e7caf4c015990a53d4
2022-03-27 08:51:58 -04:00
Christian Soffke
ae121de149 PictureFlow: Write bitmaps in one go
Analogous to an earlier change w.r.t. reading bitmaps

Change-Id: I68e71160b51eb893f18071cc77d9c9a3ef84de0f
2022-03-27 08:51:58 -04:00
William Wilgus
593d9f623d lastfm_scrobbler fix yellow for targets w/o storage callback
Change-Id: I0a3dbcf8c8c0c72efa2506d1998fd24d228ed91d
2022-03-26 11:12:19 -04:00
William Wilgus
f105ad7b23 lastfm_scrobbler fix red for devices w/o storage callback
Change-Id: I2062534b6e2a82171b856cc76efe8b78dbf9b13c
2022-03-26 03:20:49 -04:00
William Wilgus
fd15ea25d3 LastFm remove scrobbler from core make a TSR plugin WIP
remove scrobbler from core make it a plugin

Change-Id: I606810eba7d570dfb332789aed913c6f8adc7fb7
2022-03-26 02:50:11 -04:00
William Wilgus
8eb4689ab1 add way to lock portion of plugin buffer for TSR plugins
Some things in core that should probably be plugins steal the plugin buffer
for their own use, TSR plugins have no way to detect or prevent this
lock buffer reserves buffer_size bytes directly after the plugin itself
returns the unreserved bytes still available from the plugin buffer

Change-Id: I5a7849e209129b09400036a594569ef396b1b85f
2022-03-25 18:16:11 -04:00
William Wilgus
822b16b1c6 debug_menu dbg_buffering_thread show more on tiny screens
I think the clipzip has the smallest screen at 96
might need to be enabled for LCD_WIDTH <=128 too

remove scrolling thread info for larger screens

Change-Id: Ic98c9fc0b53f79e90776c13429194f9c37c1d48b
2022-03-22 17:55:23 -04:00
William Wilgus
7910f4a7aa debug_menu cleanup/optimize some common format strings
Change-Id: I84b070f8ea264ea64bddd82f9849ec20c72a4863
2022-03-22 16:16:11 -04:00
William Wilgus
61bc7b91bc tagcache.c remove 16-bit compression for add_uniqbuf
apparently there are tags such as year or genre that are indexed 1 byte
apart, as much as I like the idea of this I cannot come up with a way
to reliably denote 2 16 bit entries from a single 32 bit entry without
losing data or adding bookkeeping which would likely make it pointless

Change-Id: I8a9908575700cab9506c36f5422222145557fa6b
2022-03-22 00:22:42 -04:00
William Wilgus
64c577a0c5 filetree.c cleanup
just a little cleanup of ft file filtering code

store result of filter mask to a local var

put skin apply code in its own function

Change-Id: Ib899608f64e36346b9bde07caa5d5ac29de05af9
2022-03-21 08:14:30 -04:00
William Wilgus
08b42791ff tag_cache.c optimize str_begins_ends_oneof
the function is shared

Change-Id: I362a75ea5a39690647df4f421d9429ef2114ef02
2022-03-19 03:30:54 -04: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
0f2d623216 tagcache add logging option for clause matching #2
Change-Id: Ideaa89a6fb227ecc8a4a107dced98f85b6b40a4f
2022-03-19 02:11:57 -04:00
William Wilgus
a56975af6c tagcache add logging option for clause mtching
Change-Id: I5099287398b448d2f44283419395ab8919d6019c
2022-03-19 01:59:07 -04:00
William Wilgus
a5e684c894 BUGFIX root_menu.c
Change-Id: Ie6268c63f5ed5197d2da678851b4bfdf7764252c
2022-03-18 19:45:01 -04:00
William Wilgus
b31444261e [COV] cuesheet.c var line could be uninitialized
Change-Id: Id753ecc28f4029e05032be0c0ac6ecd27e9e370f
2022-03-18 18:57:55 -04:00
William Wilgus
99f8457279 cuesheet, fix dumb typo
Change-Id: I17aefb0b507898819f9f6d369d986205c6a59c9d
2022-03-18 17:34:11 -04:00
William Wilgus
a13ae2afd5 [COV] folder_select buffer overrun
Change-Id: I441e1fa13d3832b3b12e3f46f35ef63fb3c1de02
2022-03-18 08:59:32 -04:00
Aidan MacDonald
b309fae2bc touchscreen: fix quickscreen
Looks like I made a mistake testing this originally because there's
no way this would've worked.

Change-Id: I89dc0d831e381eb957cf6e1a801236b5cd829efa
2022-03-16 19:57:28 -04:00
William Wilgus
b3e0d18f7d skin_engine.c settings_apply_skins cleanup
just some cleanup and removal of ifdefs in favor of dummy functions

Change-Id: I03a1d351344afcc428dedb67aab915184f99bd23
2022-03-15 20:17:11 -04:00
William Wilgus
20b9ce5497 debug_menu make scrolling manual for OS Threads item
the automatic scrolling is not very nice to try and read instead use
OK button to advance and long press std ok to reset to beginning
(or scroll up and down)

Change-Id: I964ccefcd3c16836cc92f52247d7b8e65c6d627b
2022-03-14 20:53:45 -04:00
William Wilgus
9b4e784560 BUGFIX string_option parsers
fix bugs introduced in the switch over to using string_option
instead of if else strcmp trees,
embedded album art should work again
skin parser had an error for 'noborder' and 'nobar'

Change-Id: I957d81e5fa8467b33bbd93d63c4428c36100acca
2022-03-14 17:23:18 -04:00
William Wilgus
6dcbf7ff77 debug_menu scroll os stack screen
the os threads items update too quick to see them scroll

implement a simple scroller

Change-Id: I1161dec1b528c9b96b31eacd85c1ec2420cac61d
2022-03-14 02:42:02 -04:00
William Wilgus
6d122e3932 cuesheet, cleanup tag code with strncmp
Change-Id: I97076266103d20e59537e4e0959a70cc12b207f6
2022-03-13 17:11:50 -04:00
William Wilgus
2352cef6d0 replace more strcmp if then trees with string_option()
1

Change-Id: Ic89bbb2ab41068d09c7bd9caa5ba7f38749b9084
2022-03-13 14:31:02 -04:00
William Wilgus
77e4dd81f5 option_string clean-up and consolidate with metadata_common
Change-Id: I2649f6af37bd871fb8f181ae2f716ff0bcf1f65c
2022-03-13 10:55:47 -04:00
William Wilgus
eb86ee296a skin_parser.c fix red stupid typo
Change-Id: If4830afc84b32e79ec5aef7add8574485c11af3c
2022-03-13 04:51:16 -04:00
William Wilgus
3f2ad8bf2b skin_parser.c fix red
Change-Id: If093ad790f63d39855bf3253ae7a6c11afcc1a96
2022-03-13 04:22:05 -04:00
William Wilgus
74df3ba2d8 add function string_option to misc.c use in skin_parser.c
function string_option allows a string to be found in a
supplied list of options

Change-Id: If9134090406b74ab11f4ef9ed6517a4b99b9d73e
2022-03-13 03:45:00 -04:00
William Wilgus
eecf840989 playlist.c fix red for non-DIRCACHE targets
Change-Id: Id02f67dee6f40a80c832dea785f56f32885a5528
2022-03-11 22:52:02 -05:00
William Wilgus
a59b3c5d11 playlist_resume, wait for dircache to complete before loading songs
with root redirect and even relative paths eventually we need the dircache
to get files from the disk

Change-Id: Ia443f473f09dd534674d5fdb71251214ce01eed7
2022-03-11 22:30:39 -05:00
William Wilgus
95af36d0dd playlist.c fix red for non multivolume targets
Change-Id: Ic0fdb325bc9c8d886c7627679fb2d02521400da7
2022-03-11 20:05:14 -05:00
William Wilgus
eb32238b22 playlist.c use basename for playlist_get_filename_crc32
strip the vol and use the relative portion

Change-Id: I6259343e63a84f0ab97bd6f491de09320d74eac4
2022-03-11 19:45:58 -05:00