summaryrefslogtreecommitdiff
path: root/apps/playback.c
AgeCommit message (Collapse)Author
2021-08-06Be sure to wipe id3 tag after failed parse in playback.cAidan MacDonald
Change-Id: I000c78e913ab80afa9b82cae937afb5255831b79
2021-07-21autoresume: Properly check the path string, not the pointer.Solomon Peachy
(the pointer is _always_ valid as it's to a fixed buffer) Change-Id: I88489012b76ed3b5b214cf01da1a6260e259fe87
2021-03-05OOM on Audio_Reset_BufferWilliam Wilgus
Allow the talk file to be unloaded Change-Id: I7633c213f1bf7135894aed43171ea683e2867954
2021-03-02Remove execute bit from file permissions from recent commitWilliam Wilgus
Change-Id: I415cf235d2b179ae8c58b0427308103be3e00130
2020-12-25Fix deadlocks when trying to buffer large album art.Michael Giacomelli
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-10-01xduoox3ii/x20: Proper lineout detection and volume mangling.Solomon Peachy
hotplugging hp and lineout works, without blowing out eardrums. Change-Id: I2df5c7a618bb2d1d77d416548d45dff9cfc619db
2020-10-01hosted pcm-alsa improvementsSolomon Peachy
* 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-09-30audio: Add support for 192 and 176KHz playbackSolomon Peachy
* 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-08-07Automatic choice of playback frequency by the playing file propertiesIgor B. Poretsky
Change-Id: I0fdc5d32225decbf051685be819be8df84171998
2020-07-24[4/4] Remove HAVE_LCD_BITMAP, as it's now the only choice.Solomon Peachy
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-08Fix build errors introduced in a2fbccfSolomon Peachy
Change-Id: I413989858432cd206e09d6d71dec07b4f7e06836
2020-07-08playback: Nothing should call ata_spinup_time() directlySolomon Peachy
Change-Id: I9d20b8bfd0f1e47f33ca402f80a9e08bd00fbcd8
2018-12-22Auto-Ranging Time Formatting For Menus (hh:mm:ss:mss)William Wilgus
Unifies time formatting in settings_list.c allows time format to display as HH:MM:SS.MSS or any consecutive combination thereof (hh:mm:ss, mm:ss, mm:ss.mss, ss.mss, hh, mm, ss ,mss) works in INT and TABLE settings with the addition of flag 'F_TIME_SETTING' Time is auto-ranged dependent on value Adds talk_time_intervals to allow time values to be spoken similar to display format: x Hours, x Minutes, x Seconds, x Milliseconds Table lookups merged or removed from recording, clip meter and lcd timeout -String_Choice replaced with TABLE_SETTING or INT_SETTING for these functions as well, cleaned-up cfg_vals that get saved to cfgfile RTL Languages ARE supported Negative values ARE supported Backlight on/off are now Always and Never to share formatter with LCD Timeout Added flag to allow ranged units to be locked to a minimum index Added flag to allow leading zero to be supressed from the largest unit merged talk_time_unit() and talk_time_intervals() optimized time_split() optimized format_time_auto() Backlight time-out list same as original Change-Id: I59027c62d3f2956bd16fdcc1a48b2ac32c084abd
2018-10-18Fix playback.c audio_track_count() warningWilliam Wilgus
changes return to unsigned int to match underlying aliased function Change-Id: I7015c7ad929344441249aa7c4f2af361142fcaf4
2017-12-17Get rid of useless playlist probing and fix up some data types.Michael Sevakis
Playback checked the files' presence before attempting to buffer the track. Just get rid of that and save an extra open/close call. It will find out if the path is bad when the metadata fails. Fix some size_t/off_t conflation. No need to update plugin version because no plugin actually uses bufopen(). Change-Id: I3db112449dc0b2eeb91c546f308880ac82494fc7
2017-12-15Fix big WTF when closing the current track.Michael Sevakis
It must be set to something else valid (unless it's the only one left) when closing it, IN ALL CASES, not just if it's first or last. Don't know what was in my head. Hopefully takes care of a reported issue. Even if it's not causing any issues, it was still incorrect. Change-Id: I594af8b35d774ec222dadce80dfa8b95138f037e
2017-12-12Get voice event out of playback.cMichael Sevakis
Purpose: A step in removing all voice references from playback code and prelude to other changes. Change-Id: Ic3ad7f7a33b979693e18a3456ced37eb1d2281a4
2017-12-09Fix yellow on hosted targets from c1a01beMichael Sevakis
Change-Id: I4c63efc6570368df76b6c4bbfb5b673dd081145b
2017-12-09Playback: Move internal track list onto bufferMichael Sevakis
Does away the statically-allocated track list which frees quite a fair amount of in-RAM size. There's no compile-time hard track limit. Recommended TODO (but not right away): Have data small enough use the handle structure as its buffer data area. Almost the entire handle structure is unused for simple allocations without any associated filesystem path. Change-Id: I74a4561e5a837e049811ac421722ec00dadc0d50
2017-12-07Ensure ci is properly updated if seeking before track load completesMichael Sevakis
If in the middle of a manual skip, playback would try to seek, and therefore start, the codec before the audio handle was available. This wasn't really a problem since the codec would just bail out and be retried later. But, it is a problem for a change I was working on with seeking where the codec could get caught in a full-speed loop trying to seek itself (stoppable, not lockup). The main side effect of this change that you may notice, if using an HDD with dircache turned on and the disk is not spinning, is that you can keep holding down prev/next if dir skipping and the WPS will start FF/RW mode. By the time the new track shows up, you will have seeked into it some amount. Well, the PBE is getting the info ASAP anyway and as far as it's concerned, the next track is under way. On that end of things, it's correct. Perhaps WPS should lock out its own seek mode at certain times. Change-Id: Ifc7409a886df399cec189d1bae2adba3872e857a
2017-12-04Playback: C99-ize FOREACH_ALBUMART; make loop counter localMichael Sevakis
Change-Id: Ie6d571ef217246e22b465ef39097ad9d9d1a6436
2017-11-24Do playback restarts the proper wayMichael Sevakis
It isn't necessary to explicitly stop and restart playback to force it to update something that must cause rebuffering. Change-Id: I6ff5394fcafc7374af67ef9fbf9022bb4a79b773
2017-04-06Fix a problem with audio not starting on a list of short filesMichael Sevakis
Forced audio start was left out when a third codec attempts to start a second track transition. Only one pending transition is allowed at a time. There wouldn't be enough PCM in the buffer to trigger audio playback and audio would just return without giving the pcm buffer a kick. Fixes FS#13100 - Player failed on short tracks Change-Id: I338b0b12022c591930451fd5ed26a2a73008835f
2016-03-30Fix broken logfMihail Zenkov
2015-02-02iBasso DX50/DX90: Major code cleanup and reorganization.Udo Schläpfer
Reorganization - Separated iBasso devices from PLATFORM_ANDROID. These are now standlone hosted targets. Most device specific code is in the firmware/target/hosted/ibasso directory. - No dependency on Android SDK, only the Android NDK is needed. 32 bit Android NDK and Android API Level 16. - Separate implementation for each device where feasible. Code cleanup - Rewrite of existing code, from simple reformat to complete reimplementation. - New backlight interface, seperating backlight from touchscreen. - Rewrite of device button handler, removing unneeded code and fixing memory leaks. - New Debug messages interface logging to Android adb logcat (DEBUGF, panicf, logf). - Rewrite of lcd device handler, removing unneeded code and fixing memory leaks. - Rewrite of audiohw device handler/pcm interface, removing unneeded code and fixing memory leaks, enabling 44.1/48kHz pthreaded playback. - Rewrite of power and powermng, proper shutdown, using batterylog results (see http://gerrit.rockbox.org/r/#/c/1047/). - Rewrite of configure (Android NDK) and device specific config. - Rewrite of the Android NDK specific Makefile. Misc - All plugins/games/demos activated. - Update tinyalsa to latest from https://github.com/tinyalsa/tinyalsa. Includes - http://gerrit.rockbox.org/r/#/c/993/ - http://gerrit.rockbox.org/r/#/c/1010/ - http://gerrit.rockbox.org/r/#/c/1035/ Does not include http://gerrit.rockbox.org/r/#/c/1007/ due to new backlight interface and new option for hold switch, touchscreen, physical button interaction. Rockbox needs the iBasso DX50/DX90 loader for startup, see http://gerrit.rockbox.org/r/#/c/1099/ The loader expects Rockbox to be installed in /mnt/sdcard/.rockbox/. If /mnt/sdcard/ is accessed as USB mass storage device, Rockbox will exit gracefully and the loader will restart Rockbox on USB disconnect. Tested on iBasso DX50. Compiled (not tested) for iBasso DX90. Compiled (not tested) for PLATFORM_ANDROID. Change-Id: I5f5e22e68f5b4cf29c28e2b40b2c265f2beb7ab7
2015-01-11Make a few local variables staticThomas Jarosch
Change-Id: Ieb77a7f2cdf765afa3121320d03c0478cd97eb0f
2014-08-30Remove I/O priority. It is harmful when used with the new file code.Michael Sevakis
HAVE_IO_PRIORITY was defined for native targets with dircache. It is already effectively disabled for the most part since dircache no longer lowers its thread's I/O priority. It existed primarily for the aforementioned configuration. Change-Id: Ia04935305397ba14df34647c8ea29c2acaea92aa
2014-06-20Fix a playback bug in shink_callback()Michael Sevakis
Invalid event data would be accessed if a play message isn't queued which will cause crash problems. It came about in the addition of time-based resume. Change-Id: I1d5219064e2bf552b4183e9db4e7b380ffbe7a67
2014-03-14events: Rework event subsystem (add_event, send_event) to be more versatile.Thomas Martitz
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-10Implement time-based resume and playback start.Michael Sevakis
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>
2013-12-23playback,talk: Share audiobuffer via core_alloc_maximum().Thomas Martitz
This fixes the radioart crash that was the result of buffering.c working on a freed buffer at the same time as buflib (radioart uses buffering.c for the images). With this change the buffer is owned by buflib exclusively so this cannot happen. As a result, audio_get_buffer() doesn't exist anymore. Callers should call core_alloc_maximum() directly. This buffer needs to be protected as usual against movement if necessary (previously it was not protected at all which cased the radioart crash), To get most of it they can adjust the willingness of the talk engine to give its buffer away (at the expense of disabling voice interface) with the new talk_buffer_set_policy() function. Change-Id: I52123012208d04967876a304451d634e2bef3a33
2013-11-10playback: Fix build with LOGF_ENABLE.Andrew Ryabinin
Change-Id: I01154d4a9441f44852748c910c267419f7f4149e
2013-07-13Get rid of some superfluous single-purpose functions in playback.Michael Sevakis
* 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-06Enable setting of global output samplerate on certain targets.Michael Sevakis
Replaces the NATIVE_FREQUENCY constant with a configurable frequency. The user may select 48000Hz if the hardware supports it. The default is still 44100Hz and the minimum is 44100Hz. The setting is located in the playback settings, under "Frequency". "Frequency" was duplicated in english.lang for now to avoid having to fix every .lang file for the moment and throwing everything out of sync because of the new play_frequency feature in features.txt. The next cleanup should combine it with the one included for recording and generalize the ID label. If the hardware doesn't support 48000Hz, no setting will be available. On particular hardware where very high rates are practical and desireable, the upper bound can be extended by patching. The PCM mixer can be configured to play at the full hardware frequency range. The DSP core can configure to the hardware minimum up to the maximum playback setting (some buffers must be reserved according to the maximum rate). If only 44100Hz is supported or possible on a given target for playback, using the DSP and mixer at other samperates is possible if the hardware offers them. Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622 Reviewed-on: http://gerrit.rockbox.org/479 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
2013-06-29SWCODEC Audio: Add some INIT_ATTR's to get a few bytes back.Michael Sevakis
Change-Id: Ie7b04ecf3b3535e0ed45a6e0e8d81af89e38378e
2013-06-30Update software recording engine to latest codec interface.Michael Sevakis
Basically, just give it a good rewrite. Software codec recording can be implemented in a more straightforward and simple manner and made more robust through the better codec control now available. Encoded audio buffer uses a packed format instead of fixed-size chunks and uses smaller data headers leading to more efficient usage. The greatest benefit is with a VBR format like wavpack which needs to request a maximum size but only actually ends up committing part of that request. No guard buffers are used for either PCM or encoded audio. PCM is read into the codec's provided buffer and mono conversion done at that time in the core if required. Any highly-specialized sample conversion is still done within the codec itself, such as 32-bit (wavpack) or interleaved mono (mp3). There is no longer a separate filename array. All metadata goes onto the main encoded audio buffer, eliminating any predermined file limit on the buffer as well as not wasting the space for unused path queue slots. The core and codec interface is less awkward and a bit more sensible. Some less useful interface features were removed. Threads are kept on narrow code paths ie. the audio thread never calls encoding functions and the codec thread never calls file functions as before. Codecs no longer call file functions directly. Writes are buffered in the core and data written to storage in larger chunks to speed up flushing of data. In fact, codecs are no longer aware of the stream being a file at all and have no access to the fd. SPDIF frequency detection no longer requires a restart of recording or plugging the source before entering the screen. It will poll for changes and update when stopped or prerecording (which does discard now-invalid prerecorded data). I've seen to it that writing a proper header on full disk works when the format makes it reasonably practical to do so. Other cases may have incorrect data sizes but sample info will be in tact. File left that way may play anyway. mp3_enc.codec acquires the ability to write 'Info' headers with LAME tags to make it gapless (bonus). Change-Id: I670685166d5eb32ef58ef317f50b8af766ceb653 Reviewed-on: http://gerrit.rockbox.org/493 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
2013-06-30Fix some whitespace in files changed in following commit.Michael Sevakis
Change-Id: Ie3f43e43076e0dcae9a10f1b0b9e4698b398acee Reviewed-on: http://gerrit.rockbox.org/492 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
2013-05-31Argh, move a comment to the (now) proper location. :)Michael Sevakis
Change-Id: I13847b99d9aeaa05efa5b22a8e4842f193f01a3c
2013-05-31Have voice fire an event when it starts and stops playing.Michael Sevakis
Further decouples voice_thread.c from other playback areas. Also allows other audio sources, such as FM radio, to be attenuated when voice is playing by implementing a callback. Defined as another playback event rather than a new event class: PLAYBACK_EVENT_VOICE_PLAYING Change-Id: I2e3e218be6cd6bebbf39e7883a8c0e4ed42b62bb
2013-05-31Should use HAVE_RECORDING, not AUDIO_HAVE_RECORDING in playback.cMichael Sevakis
SIM should work like target, sort of, when recording is initialized. Change-Id: I12314bb98cec53d574f4b25984ef803b2c038a96
2013-05-31Some corrections after 5857c44.Michael Sevakis
Playback needs to receive a couple of settings-related messages even when not playing. Put the message reply back where it was when loading an encoder for recording. Change-Id: I8cc80f46e42a0afd119991d698510e1ebef38ead
2013-05-31Refactor audio thread to run both recording and playback.Michael Sevakis
Eliminates the pcmrec thread and keeps playback and recording engine operation mutually-exclusive. audio_thread.c contains the audio thread which branches to the correct engine depending upon the request. It also handles the main audio initialization. Moves pcm_init into main.c just before dsp_init because I don't want that one in audio_init in the new file. (Also makes revision df6e1bc pointless ;) Change-Id: Ifc1db24404e6d8dd9ac42d9f4dfbc207aa9a26e1
2013-03-24Change audio_set_cuesheet parameter from int to bool (fixes cppcheck warning)Bertrik Sikken
Change-Id: Icb31c8bd8605aca27765a94b609c41f1f706426f
2012-05-24More snafu fix. Need a couple more patchups for now.Michael Sevakis
Must restore talk buffer explicitly when not taking it and promote the buffer state. Change-Id: Ia0341ede05837e6e94885a9ad62460c415ec6f00
2012-05-21Fix some lockup caused by handles not being initialized to < 0...Michael Sevakis
...by default where they would be interpreted as valid but not actually be which would cause calls to buffering while it was not initialized. Add BUFFER_EVENT_BUFFER_RESET to inform users of buffering that the buffer is being reinitialized. Basically, this wraps all the functionality being provided by three events (...START_PLAYBACK, RECORDING_EVENT_START, RECORDING_EVENT_STOP) into one for radioart.c, the only user of those events (perhaps remove them?) and closes some loopholes. Change-Id: I99ec46b9b5fb4e36605db5944c60ed986163db3a
2012-05-02Use buflib for the allocation of voice PCM resources.Michael Sevakis
Buffers are not allocated and thread is not created until the first call where voice is required. Adds a different callback (sync_callback) to buflib so that other sorts of synchonization are possible, such as briefly locking-out the PCM callback for a buffer move. It's sort of a messy addition but it is needed so voice decoding won't have to be stopped when its buffer is moved. Change-Id: I4d4d8c35eed5dd15fb7ee7df9323af3d036e92b3
2012-05-01rbcodec refactoring: autoresumableSean Bartell
Moved to playback.c, since it doesn't use metadata from the music file. Change-Id: I5c3ad7750d94b36754f64eb302f96ec163785cb9 Reviewed-on: http://gerrit.rockbox.org/142 Reviewed-by: Nils Wallménius <nils@rockbox.org>
2012-04-28rbcodec refactoring: get_audio_base_data_typeSean Bartell
This function has been changed to rbcodec_format_is_atomic, which doesn't require an enum from the kernel. Change-Id: I1d537605087fe130a9b545509d7b8a340806dbf2 Reviewed-on: http://gerrit.rockbox.org/141 Reviewed-by: Nils Wallménius <nils@rockbox.org> Tested-by: Nils Wallménius <nils@rockbox.org>
2012-03-25buflib/shrink_callback: Resume playback only if it was playing (not paused).Thomas Martitz
Change-Id: Ie4884ec4554890f8bdb03f48bcf215ece00a5560
2012-03-19Option to constrain get_next_dir() to directories below ↵Nick Peskett
global_settings.start_directory. When enabled, if the user has set "Start File Browser Here" (config.cfg: start directory) to anything other than root and "Auto-Change Directory" is set to "Yes" or "Random", the directory returned when an auto change is required will be constrained to the value of "start directory" or below. Change-Id: Iaab773868c4cab5a54f6ae67bdb22e84642a9e4b Reviewed-on: http://gerrit.rockbox.org/182 Reviewed-by: Nick Peskett <rockbox@peskett.co.uk> Tested-by: Nick Peskett <rockbox@peskett.co.uk>