Commit graph

823 commits

Author SHA1 Message Date
Roman Artiukhin
78903e9d38 Reapply "buffering: remove bufgettail/bufcuttail"
This reverts commit 2bd88936f7. Strip tags functionlity will be moved to codec.

Change-Id: Iff28ff7a29da09632ceed30a7959cc1ee8bf3cc8
2025-05-26 10:59:56 -04:00
Solomon Peachy
2bd88936f7 Revert "buffering: remove bufgettail/bufcuttail"
This reverts commit 9e93796407.

Fixes FS#13626, which is caused by non-audio ID3v1/APE tags at
the end of the audio data stream.

Change-Id: Ic69af14a5d1264b7896a54b5f2ad314022dd98ac
2025-05-20 07:51:48 -04:00
William Wilgus
731f3fd8be Playback logging add Start time and rename when log size exceeds 512k
renames to playback_nnnn.log

you won't get the message when first enabling logging since it
happens at start-up..

Change-Id: I58ca65a48deff7c5bb1f93c3d86d9ee9e19f3f2e
2025-03-01 19:16:46 -05: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
Roman Artiukhin
7f4a8891a6 metadata: mp3: Support unsync embedded jpeg album art
Support parsing alubm art from id3 metadata with "unsynchronisation scheme":
https://id3.org/id3v2.3.0#The_unsynchronisation_scheme

Change-Id: I1e2ca4ae0aa967f7e80142a04c9a7d99e38e68b2
2025-01-16 10:08:41 -05:00
William Wilgus
0493ee19c3 lastfm_scrobbler speed up track culling, better duplicate logic
rather than going through the whole file each time we can just walk
through the remainder speeds up duplicate removal by quite a bit

check timestamp of tracks to not remove multiple plays of the same song
at different times, unless back to back (then its probably a resume after
shutdown)

devices without RTC use current_tick but thats in centiseconds
convert to milliseconds so we can use the timestamp in the above calculations

my fix to the scrobbler_viewer makes the include menus disappear as
soon as you hide columns so explicitly mark if we are
dealing with a scrobbler log at load

Change-Id: I11bbebe9af45945a7e1326a5e419290086b05aaa
2025-01-13 18:08:40 -05:00
William Wilgus
c3fd32bdf2 [Feature] playback logging from core
people don't like having to remember to run the TSR plugin so
lets meet them halfway

all tracks are added with timestamp, elapsed, length, trackname

added buffering for ATA devices

still needed:
-Done -- a plugin that parses for duplicates and reads the track info
to create the actual scrobbler log
(log can be truncated once dumped)
this should allow you to run the plugin at leisure

later I'd like to expand this logging to allow
track culling based on skipped songs..

remove the TSR plugin as hard disk no longer need to use it

Change-Id: Ib0b74b4c868fecb3e4941a8f4b9de7bd8728fe3e
2025-01-13 00:45:09 -05:00
William Wilgus
b07d7d6af0 skin_token.c, playback.c, add get_temp_mp3entry()
add function get_temp_mp3entry() to return a valid mp3entry from scratch_mem
UNBUFFERED_ID3
or if playback hasn't been started used statically allocated mp3entry
NEXTTRACK_ID3

Change-Id: I3909fb585e0f5ad590f917ce827e991440f1fe75
2024-12-26 00:58:51 -05:00
Christian Soffke
1745b74576 Make simulator compile on MacOS
Tested on MacOS Sequoia (Apple Silicon) with the
latest Xcode command line tools, gcc 14
(Homebrew GCC 14.2.0_1) and sdl2 (Homebrew 2.30.9)

Make sure 'gcc' (and 'gcc-ar') is in your PATH
ahead of the Xcode-provided "gcc"(clang). E.g.
by setting up symlinks in /usr/local/bin that
point to gcc-14 and gcc-ar-14.

Notes:
- The appropriate bmp from uisimulator/bitmaps
  has to be manually copied to your build folder
  and renamed to UI256.bmp, if you want the sim
  background to be displayed

Change-Id: I559f33d2165065f913f30c016b85906af380fb81
2024-11-30 22:19:02 -05:00
Solomon Peachy
41abd8e32f sdlapp: Fix build with SDL2
Not sure why this didn't break in my earlier tests.

Change-Id: Idf643c7ace638d928d41606cec1b90762bc4909e
2024-10-07 12:36:44 -04:00
William Wilgus
f0c208554c [BugFix] Playback.c OOM with large voice file
with our large voice file being loaded in its entirety to the buffer
there isn't enough room to allocate the required pcm buffer
well prior to this patch we looked for 1k free to allow the talk buffer
to be given away
well the pcm buffer expects something like 5-600 kb on the clipzip
and there is 1k allocatable but not 300 more

so instead get the required pcm buffer size and check against that

Change-Id: I40a056e4170c37bc3429f0cb37af221ae7f812e5
2024-09-24 10:47:34 -04:00
Solomon Peachy
6ed8b9091c Misc: Compiling under SDL2 uncovered a few issues unrelated to SDL itself
Change-Id: I625d5dd02d3f70bc6484a8641eafdaf13812f4a7
2024-09-21 16:32:58 -04:00
Roman Artiukhin
fe5375a6cb Improve Crossfade handling in Single Mode
Crossfade (see Playback Settings -> Crossfade) now works between songs in Single Mode (see Playback Settings -> Single Mode) unless it’s the last song to be played.

Change-Id: Icfe3d48459bb35bbc050f237a68b27e793ab9152
2024-07-21 11:51: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
d1aeb7db9d [Coverity] playback.c audio_auto_change_frequency check for valid id3
Change-Id: Ia213134c690f4c1de16afba38eea740825558280
2024-05-31 23:02:28 -04:00
roman.artiukhin
63f75d22b4 Fix potential stuck on auto track change when buffering is stopped
pcmbuf  might wait for next track for proper crossfade/gapeless playback (see pcmbuf_start_track_change). It's not going to happen with stopped buffering.

Fixup for 831faa3b (#5394)

Change-Id: I969878d13a9f976566eef5b975beb1687b519a37
2023-11-01 16:24:32 +02:00
roman.artiukhin
11b8336c64 Fix rewind on resume is applied for skip length across tracks action after auto frequency switch
Add resume adjustments flag in mp3entry struct which is required for proper AUDIO_START_RESTART resume handling

Fixup for 4fb37ecb (#5196)

Change-Id: Ie9ecfe2b637bba38e442066333d71eeff01030ad
2023-10-31 13:46:07 -04:00
roman.artiukhin
f377ad3ce7 Restore clearing resume info for current track in playing_id3_sync
Regression introduced in 3d5dd97c (#5426)

Without it current playlist keeps last bookmark info so next time track is played again from bookmark.

Change-Id: Ifeff43a4a2d380056ef8a389c3c72e7254db4080
2023-10-31 03:28:55 -04:00
roman.artiukhin
831faa3b82 Rework auto playback frequency switch
Moved logic outside playback events to be executed early. Stops buffering when frequency change is detected (additional STATE_STOPPED state is introduced)

Removed no longer used AUDIO_START_REFRESH flag

Change-Id: Icfae61725a4d8ffb47380f561a011bda4841457b
2023-10-28 15:11:07 -04:00
roman.artiukhin
3d5dd97c48 Fix playing_id3_sync not properly syncing resume data
Fixes bookmark resume for tracks with different sample rates (should fix FS#13295)

Change-Id: I69c77f9397f9230381c31e7cf8b586bcbacd06fe
2023-10-22 09:26:20 -04:00
roman.artiukhin
4fb37ecbc6 Skip Length across tracks
Allows to use Prev button to skip length from the end of previous track.

Can be enabled with:
Settings -> Playback Settings -> Skip Length set to some time interval
and
Settings -> Playback Settings -> Rewind Across Tracks set to Yes

Change-Id: I99f234035a8a5acc9cbfe05ea83971ec5ddc59ea
2023-10-22 08:21:22 -04: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
roman.artiukhin
951e239517 Cache folder album art
Fixes FS#13372

Change-Id: Ia50f5252cb8375a97c093abeda89d830bf003ff3
2023-09-20 10:01:47 -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
Christian Soffke
84450dfd5d Playback: Fix 'auto' frequency not applied when paused
A frequency change didn't go into effect immediately
when a user picked "Auto" for the sample rate, while
playback was paused

Change-Id: I254853b664c5b6812264fdaf81dfb8fbfff43dbf
2023-09-11 10:57:07 -04:00
William Wilgus
79b64a3fc7 setting_list.c playback frequency cleanup
moves the callback to settings_list

audio_set_playback_frequency now accepts an actual frequency
44100 192000 etc rather than an index

Change-Id: Ieb3fc79a7fe3f1ff050465c8cd8061027e4572ff
2023-09-01 19:32:27 -04: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
William Wilgus
99839960a2 abrepeat add dummy functions and remove some of the ifdefs
Change-Id: Icae7e334e87bb1974712a7a76296cf69bbdbffba
2022-12-14 23:37:14 -05:00
William Wilgus
a634557a88 fix strptokspn, add strcspn, fix splash.c
fix off by 1 error in strptokspn, add strcspn, fix fallout in splash.c

Change-Id: I61475d9633fc35db5a8ae30cbe588f69f2f7fabc
2022-11-13 01:14:49 -05:00
Aidan MacDonald
26ffcd8f9f playback: Fix track resume from file offset
Resuming a track with "Resume Playback" or a bookmark is supposed
to pass both the file offset and elapsed time to the codec. Since
commit dfff938dff the offset has been getting zeroed because the
buffer handle wasn't open at the time of the buf_filesize() call,
causing it to return a negative error code.

Having a valid offset improves resume accuracy with some codecs,
like VBR MP3.

Change-Id: I8af7f001644f1ee1bd27ca3049a4cff2d2274149
2022-11-01 09:52:34 -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
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
Christian Soffke
4d7327b04d Album Art: Eliminate redundant check
When the 'Album Art' setting was set to
'Prefer Image File' and neither image file
nor embedded artwork were found,
playback would check for files twice.

Change-Id: Ibe392928d58ec04103e2572124841724509bd859
2022-04-18 09:13:31 -04:00
William Wilgus
359c66982f playback.c use file_exists rather than open to check for bad files
the worst case is really slow for open

Change-Id: Ifcfe366ad9bee7ff43a0572e52f15b5c6f608288
2022-03-11 19:45:58 -05:00
Christian Soffke
bc5a638594 Option to switch off album art or to prefer file over embedded
Large embedded album art can cause pauses during
playback or when skipping between tracks, especially
on older devices, but embedded art is currently loaded
even when separately stored smaller image files would be
available.

A workaround is to remove large album art from the
metadata of files.

This now adds a setting to either turn off loading of
album art completely, or to prefer loading the album art
from a separate image file and thus ignore the embedded
versions.

Change-Id: I22fb581abf56072e35e6c29d72e553747ec1a96a
2022-01-22 08:29:40 -05:00
Christian Soffke
69d08be083 Additional Single Mode options
In addition to the existing behavior of pausing
after each song, this adds options to pause
after playing current:

Album,
Album Artist,
Artist,
Composer,
Grouping / Work, or
Genre.

Allows you, for example, to only listen to the
remaining movements of a classical work
without having to purge your playlist of any
upcoming songs.

Change-Id: If18f4a5d139320026cc5fcc9adf29dd8e4e028a8
2021-12-11 11:43:39 -05:00
Christian Soffke
e6313201c1 Playback: Skip invalid entries from playlist
Reverts to the behavior pre-commit dfff938 with the additional change
that it will not skip the last entry.

Change-Id: Ia03da03b1bdccd8a9591548cd0ca9f58f4767947
2021-11-10 16:34:27 -05:00
Moshe Piekarski
13ac485625 Add single playback mode
(FS#482)

Change-Id: I8b4c3e4ffb6975122153e82f2b9848c382195163
2021-11-05 09:20:04 -04:00
Aidan MacDonald
02b940396b Be sure to wipe id3 tag after failed parse in playback.c
Change-Id: I000c78e913ab80afa9b82cae937afb5255831b79
2021-08-06 18:34:04 +00:00
Solomon Peachy
f0e3a36fe4 autoresume: Properly check the path string, not the pointer.
(the pointer is _always_ valid as it's to a fixed buffer)

Change-Id: I88489012b76ed3b5b214cf01da1a6260e259fe87
2021-07-21 15:06:28 +00:00
William Wilgus
925dc59126 OOM on Audio_Reset_Buffer
Allow the talk file to be unloaded

Change-Id: I7633c213f1bf7135894aed43171ea683e2867954
2021-03-05 00:11:08 -05:00
William Wilgus
a6eafc86f8 Remove execute bit from file permissions from recent commit
Change-Id: I415cf235d2b179ae8c58b0427308103be3e00130
2021-03-02 02:10:53 +00:00
Michael Giacomelli
ca09f91f64 Fix deadlocks when trying to buffer large album art.
Internally, buffering tries to load the entire album art file into the
audio buffer, which will fail if the file is larger than the buffer.
Playback.c interprets a file failing to buffer to mean that the buffer
is full, so it waits for more space and tries again.  This results in a
deadlock since the file will never fit.

Change bufopen to return a new error condition when an image file will
not fit on the buffer because it is too large:  ERR_BITMAP_TOO_LARGE.
Note that we arbitrarily set "too large" to be within 64KB of the
entire buffer size or larger, this could be adjusted if needed.

Change audio_load_albumart to pass through error messages from bufopen.

In playback.c, check to see why audio_load_albumart fails.  If it fails
because the file is too large to buffer, simply ignore the file.  If it
fails because the file would fit but the buffer is full, try again
later.

Change-Id: I66799ae26f124b495e1522fce7285332f4cf986f
2020-12-25 17:47:19 +00:00
Solomon Peachy
b030bf5885 xduoox3ii/x20: Proper lineout detection and volume mangling.
hotplugging hp and lineout works, without blowing out eardrums.

Change-Id: I2df5c7a618bb2d1d77d416548d45dff9cfc619db
2020-10-01 15:41:30 -04:00
Solomon Peachy
e43726df2c hosted pcm-alsa improvements
* xduoo x3ii/x20:  Better line out support
 * less granular volume settings (too many steps before)
 * Better handling of swiching sample rates
 * Log actual sample rate in debug menu

Most credit goes to Roman Stolyarov
Additional integration [re]work by myself

Change-Id: I63af3740678cf2ed3170f61534e1029c81826bb6
2020-10-01 11:56:57 -04:00
Solomon Peachy
01650b8bc9 audio: Add support for 192 and 176KHz playback
* SAMPR_CAPS_ALL -> SAMPR_CAPS_ALL_48/96/192
 * All targets claiming SAMPR_CAPS_ALL now get appropriate subset
 * No need to explicitly define HAVE_PLAY_FREQ
 * Rates that are a multiple of 44 or 48KHz can be used for playback

Inspired by a patch by Roman Stolyarov, but substantially rewritten by myself.

Change-Id: Iaca7363521b1cb9921e047ba1004d3cbe9c9c23e
2020-09-30 21:37:11 -04:00
Igor B. Poretsky
e0bcb0f2bc Automatic choice of playback frequency by the playing file properties
Change-Id: I0fdc5d32225decbf051685be819be8df84171998
2020-08-07 03:44:13 +00:00
Solomon Peachy
658026e626 [4/4] Remove HAVE_LCD_BITMAP, as it's now the only choice.
Note:  I left behind lcd_bitmap in features.txt, because removing it
would require considerable work in the manual and the translations.

Change-Id: Ia8ca7761f610d9332a0d22a7d189775fb15ec88a
2020-07-24 21:20:13 +00:00
Solomon Peachy
e9a51ae28b Fix build errors introduced in a2fbccf
Change-Id: I413989858432cd206e09d6d71dec07b4f7e06836
2020-07-08 20:02:30 +00:00
Solomon Peachy
a2fbccf194 playback: Nothing should call ata_spinup_time() directly
Change-Id: I9d20b8bfd0f1e47f33ca402f80a9e08bd00fbcd8
2020-07-08 19:36:23 +00:00