Commit graph

462 commits

Author SHA1 Message Date
Aidan MacDonald
680261fbb7 buflib: Prep for multiple backend support, rename to buflib_mempool
Rename the current buflib implementation to buflib_mempool.

Change-Id: Iefdf74be1f7d8fcd19e6ce2289c3d1459b54d013
2023-01-15 10:04:13 +00: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
541960a110 rbcodec/dsp: restore configure loop in dsp_init() (FS#13386)
It seems removing this causes a crash on the Clip+ when playing
any file. Appears to be a timing-related issue as replacing the
loop with an mdelay() also fixes it. Needs further investigation
to identify the real cause of the problem, see FS#13386.

Change-Id: Ia93a2887a79b376de50563d6bb3bbc79cee11a1c
2023-01-12 04:56:06 -05:00
William Wilgus
9367ef1ed6 [BugFix] Fix some Shif related UB -- ASAN
these are the low hanging fruit identified by ASAN

cast the byte values before shift

Change-Id: Ifc5645354a10c15ccd09d1343e1705857a51e011
2023-01-04 22:00:25 -05:00
William Wilgus
6cbf2160e5 tlsf fix corruption checks
Turns out (~PTR_MASK) != (0xFFFFFFFF - PTR_MASK) in 64 bit land

tmp_b = (bhdr_t*) ( (intptr_t)b->prev_hdr & BLOCK_SIZE );

using ~STATE_MASK or even #define BLOCK_SIZE (~PTR_MASK) resolves the issue

switching  BLOCK_SIZE TO  ~STATE_MASK appears to fix it

Also define BLOCK_SIZE (~PTR_MASK)

Fix a few signed / unsigned errors

Change-Id: Ica59db0faa2df408831c23312243ae19259dba6b
2023-01-02 10:09:46 -05:00
Solomon Peachy
485e96d6be tlsf: Update to upstream 2.4.6 release
Seems to resolve FS#13383 and FS#13384

Change-Id: I43b2f166b78e61c16723a944729aa117260320fc
2022-12-31 15:21:55 -05:00
Aidan MacDonald
ba010851fa Remove lib/x1000-installer
Carrying this library is somewhat of a maintenance burden because
some Rockbox APIs are mocked or duplicated in the test suite and
thus need to be fixed up when refactoring.

It's also unused & incomplete, so there's no good reason to keep
it in tree any more.

Change-Id: If39c62744b4edc0d81b1b6608ee5df69430e6581
2022-12-23 19:54:18 +00:00
Aidan MacDonald
6e794c9a2d rbcodec dsp: Refactor DSP init routines, restore INIT_ATTR
Refactor DSP init routines so there is a dedicated init function
for the stages that need it. Remove the DSP_INIT configure message.
This allows the init code to be safely marked INIT_ATTR, saving a
bit of code size, and allowing the linker to verify that there are
no unsafe references to the init routines.

Change-Id: I1702f0f579bbb300a6fe7d0e67b13aa2e9dd7f8a
2022-12-23 12:47:10 -05:00
Aidan MacDonald
34a092a997 rbcodec dsp: Replace enum dsp_ids arguments with unsigned int
Because casting to and from "enum dsp_id" just adds noise,
change everything to unsigned int.

Change-Id: I52a7ae55f406e673d5b811b29657fcdc4b62ab10
2022-12-22 18:00:37 -05:00
Aidan MacDonald
b96b7640de rbcodec dsp: Move dsp_sample_io_configure() to its own file
Makes dsp_sample_input.c a bit less messy, and dependencies
are more explicit. There's possibly a minor loss of inlining
but it isn't a big deal.

Change-Id: I30f923a0ca758f2b113d32852d1f65586dff0cd1
2022-12-22 17:20:14 -05:00
Aidan MacDonald
992455dc58 Fix red in 8165a6c245
Change-Id: I939b40492902525c911c063c66b28529b7d0842f
2022-12-18 23:55:36 +00:00
Aidan MacDonald
8165a6c245 rbcodec dsp: Remove INIT_ATTR from the DSP library
All of these are technically unsafe cross-section references but
most aren't reported by the linker, probably due to inlining. In
practice there was no problem because the affected code was only
run at init time anyway.

For now, remove INIT_ATTR until the init code can be refactored
to avoid the problematic references. This should also save code
size by moving more code to the init section.

dsp_init() gets to keep its attribute because it's already OK.

Change-Id: Idc9ac0e02cb07f31d186686e0382275c02a85dbb
2022-12-18 22:23:52 +00:00
William Wilgus
626be18da0 [Bug Fix] haas surround use delay_ms instead of index surround_strength
this appears to be an old bug

rather than using an index use delay_ms directly

Change-Id: Ia4d0bf8eb8030d6ded08354abc31cc7ddefdda99
2022-12-16 08:30:54 -05:00
William Wilgus
863538c50a [Bug Fix] dsp_proc_enable init race / crash
haas surround is causing a seg fault

it appears process is null see https://www.rockbox.org/tracker/task/13382
for details

when the low_latency_callback is enabled it happens less frequently

lets default to an empty process that way there are no NULL pointers to call

Change-Id: Ib72ba1a58cbb20cef04b5ea50964adadeee74a75
2022-12-11 22:17:12 -05:00
William Wilgus
972810f6cf strlcpy finish cleanup
remove strlcpy & strlcat from string.h

document suspicious strlcpy call

convert strlcat.h users to string-extra

Change-Id: I313e75db86385c0e6d1aee75d252093be4935f60
2022-11-17 01:54:46 -05:00
Aidan MacDonald
2f278af760 codecs: alac: Improve resume accuracy and clean up rounding errors
Resume by offset was obviously inaccurate for ALAC -- it tried
to convert the offset to an elapsed time using the approximate
bitrate, which is going to be wrong for VBR files. This became
a problem since commit 26ffcd8f9f restored the ability to resume
by offset.

It turns out that m4a_seek_raw() has terrible resolution since
it can only seek to chunk boundaries, and lies about the real
sample position; basically the same issue that affected seeking
described in commit 4dd3c2b33e. Resuming by offset is still not
very accurate because of this. Prefer to resume by time first,
which is normally highly accurate (and never worse than offset)
but use the file offset if it's the only thing we have.

There were a couple time calculations still using 32-bit math,
so clean those up too to reduce issues due to rounding errors.

Change-Id: Idd3bccd67505f4e59e784d92e45ea80a273975bb
2022-11-16 06:48:28 -05:00
Aidan MacDonald
ea61347a0b codecs: aac: Prefer to resume by time instead of offset
m4a_seek_raw() is relatively inaccurate, so time-based resume
should be preferred.

Change-Id: I959ef165f9a99d12deb804c13d20413c1cecf867
2022-11-16 06:48:22 -05:00
William Wilgus
45bd4c7220 Fix last of red for strmemccpy
Change-Id: I76c421d938a879e57018e3f9706edf77c03de1b5
2022-11-15 01:58:28 -05:00
Aidan MacDonald
4e60fb77e0 codecs: mpa: Improve seek & resume accuracy for VBR files
The codec used 32-bit math for elapsed time <-> file position
calculations. The rounding errors seem to be the cause of poor
seek/resume accuracy on long VBR files; switching to 64-bit math
makes things much better.

Change-Id: Iba638d9e031a891022510c31c141cc4541e3f149
2022-11-01 09:52:34 -04:00
roman.artiukhin
0d30356734 Refactor to reuse seek code for resume by time
It fixes Playback/Bookmarks Resume for long vbr mp3 files
It also fixes resume by time for asf files.

As a replacement for https://gerrit.rockbox.org/r/c/rockbox/+/4750

Change-Id: Iaa59b5862385f5fe91fdc2fb0b1fde8ce75c0b54
2022-11-01 09:23:35 -04:00
William Wilgus
12ef045fdf move buflib_free invalid handle check to the function
allow buflib_free to check for invalid or already freed handles
within the function -- remove all the invalid handle guards thru core_free

Change-Id: Ibdcbc82760fc93b674c42283fca420d94907df8e
2022-10-15 09:26:58 -04:00
Solomon Peachy
9d3d925295 Revert "RFC: Get rid of mpegplayer plugin"
This reverts commit d25d24812e.

Change-Id: I1563223e343fb1e2eda72a45823b38350025ff93
2022-10-13 11:08:11 -04:00
Solomon Peachy
d25d24812e RFC: Get rid of mpegplayer plugin
It might have made sense once upon a time, but in today's world...

Change-Id: I5d638e6f7a2308c50ab12bd901338f02cf426aae
2022-10-02 11:57:20 -04:00
Aidan MacDonald
972c8c0ab6 Suppress bogus GCC 12 -Waddress warnings for SKINOFFSETTOPTR
This appears to be a bug in GCC 12 due to more aggressive -Waddress
warnings. According to the GCC documentation, the warning should be
suppressed because the "problem" code is coming from a macro, but it
doesn't happen for cases like "if(!SKINOFFSETTOPTR(...))" where the
macro is negated.

Assigning the result of SKINOFFSETTOPTR() to a temporary and checking
that suppresses the warning.

Change-Id: Ia37a1e06a454d29032bb8128a2f059b149ea2b83
2022-09-18 13:53:27 +01:00
Solomon Peachy
05149cd4dc Fix a couple of warnings uncovered by GCC12
Change-Id: Ib628a27bfc6f95a822e46b931ccfbed90f41b122
2022-07-11 16:11:29 -04:00
William Wilgus
e1c5a3e296 fix uninitialized warning in libopus
likely this is truly a bug but I imagine much worse things
happen before this point in that case

Change-Id: If78465cf2ae1e5cf38ad7f087dd436b888bc9996
2022-06-21 22:05:17 -04:00
Aidan MacDonald
981e972839 mips: add native backtrace implementation
Should make debugging crashes on native MIPS targets far easier.
This is by no means a 100% complete or robust implementation but
it seems to handle the vast majority of functions.

Change-Id: Id5f430270e02b5092b79026b6876675c784aa649
2022-05-22 07:16:11 -04:00
William Wilgus
79864c6ec2 add const to const * strings
I don't think this will amke any difference except maybe for hosted ports

Change-Id: I84f898aea92a6963901a6d889dd18b63f24c9a41
2022-05-03 23:00:58 -04:00
Aidan MacDonald
4dd3c2b33e codecs: m4a: improve seek accuracy
Seeking doesn't work well in M4A files with very few chunks due to
the seek method used (chunk based using the info in the 'stco' atom).
According to libm4a/demux.c the expected seek resolution using this
method is 1/4 to 1/2 seconds. However, ffmpeg generates files with a
1 megabyte chunk size, so the resolution is much worse than expected
on some files: around 30-40 seconds at 256kbps.

There was a bug with the seek position reported back to Rockbox: the
codec pretended it could seek exactly to the requested sample, but it
would only seek to the start of a chunk. This could leave the UI in a
confusing state because the real playback position was different from
what the elapsed time showed. Fix this by recalculating the reported
sample position using the chunk start.

To fix the low seek accuracy, use the table in the 'stsz' atom to skip
individual packets within a chunk. This is very accurate, but it takes
a lot of RAM to allocate the table. Currently the table is not allowed
to use more than half of the codec RAM, which should suffice for short
files on most targets. On files where the table is too large the codec
will fall back to the less accurate chunk-based seek method.

Change-Id: Ide38ea846c1cdd69691e9b1e1cd87eb0fa11cf78
2022-05-02 12:16:21 -04:00
Aidan MacDonald
6b8c94a6e3 Fix some non-portable alignment values
UBSan reports an avalanche of unaligned pointer bugs stemming from
hardcoded 4-byte alignments used in certain places. Use sizeof(long)
instead to align to the machine word size.

Change-Id: I28e505212462c5268afa24e95df3a103ac3e2213
2022-05-02 15:38:48 +01:00
Aidan MacDonald
9e93796407 buffering: remove bufgettail/bufcuttail
These operations can only be used in limited circumstances and have
exactly one user. bufgettail especially seems of dubious value; how
often do you need to read N bytes from the end of a file without
changing the file position?

strip_tags() was the only function using them, to strip off ID3v1
and APE tags off the end of buffered tracks. This would save only
32-192 bytes per track -- if the container format uses APE/ID3v1.
It hardly seems worth the effort.

Change-Id: I8fc3c1408517eda6126e75e76d76daea904b50eb
2022-04-20 16:51:49 -04:00
Aidan MacDonald
fca7b8e2ff Fix undefined behavior that blocks compiling with UBSan
Left shifts are not defined in C if they would cause signed overflow,
so these expressions get instrumented, which makes them unusable as
switch values and triggers compile errors when compiling with UBSan.

Change-Id: I0588d4be1e00ba1cfde0eac119ead368b20d10c9
2022-04-17 11:37:34 -04:00
William Wilgus
01d2979bce [COV] metadata module, fix uninit warnings #2
decrease size hit of initializing asf by using a union
remove init from bytes LE conversion in metadata common
-- bad idea for performance

Change-Id: I4514adc125e5da2b99d9f913ba74afd5f1345822
2022-03-20 09:56:44 -04:00
William Wilgus
2a88ec50cd [COV] metadata module, fix uninit warnings
Change-Id: Ifeb22642d7fb683542ff9dcfca0bc58c91ab5f38
2022-03-20 09:10:57 -04:00
William Wilgus
542609bb31 metadata.c fix red
comma, helpful

Change-Id: Iaa352cf1b542f1b805278af8560a6927684dc8d2
2022-03-14 17:38:55 -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
2352cef6d0 replace more strcmp if then trees with string_option()
1

Change-Id: Ic89bbb2ab41068d09c7bd9caa5ba7f38749b9084
2022-03-13 14:31:02 -04:00
William Wilgus
a62d36d9e7 Warble builds define WARBLE fix metadata_common in warble builds
Change-Id: Ie5115162da5a06d917de09f75b90254bb30b7513
2022-03-13 11:41:30 -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
a9c62f2c39 metadata_common.c optimize parse_tag
Change-Id: I84ad404fdcc9698b9d08e6e9c37929f4b7bf569f
2022-03-13 01:40:42 -05:00
William Wilgus
376ffbcf9a ARM support, optimize popcount fn
Change-Id: Iec02d0b5973721a3943b9c23ced3afc721cd3753
2022-03-12 00:00:01 -05:00
William Wilgus
68d0175172 BUGFIX arm aeabi_sdivmod crashes in interupt mode
Change-Id: I6e89334b0f5df1d513a3f466e1db9cdc198944fe
2022-03-11 03:05:15 -05:00
William Wilgus
01e76548c3 backtrace, put pc and sp on their own lines
Change-Id: Ia5853c4f2d1b86dc1e2cd0882f5da27e4eba5724
2022-03-08 23:37:50 -05:00
Aidan MacDonald
e8faf2f2ad buflib: add a common dummy callbacks struct & use it
There are various allocations that can't be moved or shrunk.
Provide a global callback struct for this use case instead of
making each caller declare its own dummy struct.

Also fixed ROLO and x1000 installer code which incorrectly
used movable allocations.

Change-Id: I00088396b9826e02e69a4a33477fe1a7816374f1
2022-02-12 10:24:32 -05:00
Aidan MacDonald
1ad60c3344 x1000-installer: remove redundant overflow check
This overflow is impossible to trigger due to the simple
relationship between binary and hexadecimal numbers.

Change-Id: Ie8243129967abb935a77152a808765318052c979
2021-11-28 15:46:06 +00:00
Aidan MacDonald
c086a3386f x1000-installer: map filenames accept only valid characters
Instead of using isgraph(), check for legal FAT32 characters
excluding spaces (which are used as field separators).

Change-Id: I291f0acb5f24c558099c237d913f4f35ae06b834
2021-11-28 15:46:06 +00:00
Aidan MacDonald
31242f8570 x1000-installer: add test for xf_map_parseline
Change-Id: I35db43c83dc3964607b95f6b5c300c2fef455ac8
2021-11-28 15:46:02 +00:00
Aidan MacDonald
4879891da3 x1000-installer: xf_stream_read_lines bugfixes
- Only treat EOF as newline if the line is non-empty to
  suppress a useless empty line after the end of a file.
- Deal with 0- and 1-byte line buffers safely.
- Remove whitespace stripping and comment handling which
  was left over from refactoring. Move it to xf_map_parse()
  where it belongs.

Change-Id: I9f05f4e18ca6dd011ca4cd231f0b5ea37c784778
2021-11-28 13:55:48 +00:00
Aidan MacDonald
420d545018 x1000-installer: tests for xf_stream.c
Change-Id: Ib9d1ca0109029f09ff0f8adfc10925c7c9a0f8b9
2021-11-28 13:55:43 +00:00
Aidan MacDonald
b027063c03 x1000-installer: simple test suite runner
Change-Id: I0b9ee81cbd8dda593924b2f7c32a1d1d87ce84b0
2021-11-28 13:45:20 +00:00