Commit Graph

154 Commits

Author SHA1 Message Date
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
Michael Hohmuth 8207a4a267 FS#12132 patch 8: retrieve_entries: Decrease binsize by reenabling
inlining format_str() and avoiding a string copy by printing directly
into the name buffer.

Also uses quite a bit less stack space.

En passant, made basename printing more robust by not limiting the
buffer into which the file pathname is fetched by the max size of the
resulting basename string.  Also, fixed a potential buffer overrun in
format_str.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30248 a1c6a512-1295-4272-9138-f99709370657
2011-08-04 10:23:18 +00:00
Michael Hohmuth e7c2449d07 Database: Fix array-bounds calculation when applying a format using
%strip to partially loaded (chunked) database results.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30247 a1c6a512-1295-4272-9138-f99709370657
2011-08-04 10:21:52 +00:00
Thomas Martitz 98096970e0 Cleanup tree.c cache handling a bit.
* Rename stuff to not re-use the term dircache
 * Move cache to own struct
 * Encapsulate retrieving entries a bit

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30242 a1c6a512-1295-4272-9138-f99709370657
2011-08-03 09:49:25 +00:00
Michael Hohmuth eab7e74778 FS#12132 patch 6, part 2: tagnavi.config: Add support for "basename"
in formats and conditions.  The basename is the non-directory part of
a file's pathname.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30230 a1c6a512-1295-4272-9138-f99709370657
2011-07-31 16:26:35 +00:00
Michael Hohmuth accea18ded FS#12132 patch 6, part 1: tagnavi.config: Add support for string
truncation in tagnavi %formats using the standard
"%{width}.{truncation}s" format syntax.

String truncation is especially useful when using part of a string
tag, filename, or basename for sorting and %strip'ing.  (Basename
support is forthcoming in a subsequent commit.)

Also renovated the format_str() code a bit (improved structuring,
removed code duplication) and increased the maximum length of a printf
conversion specification to 20 characters.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30229 a1c6a512-1295-4272-9138-f99709370657
2011-07-31 16:26:31 +00:00
Thomas Martitz 1b7ff725c6 Revert "Introduce bsearch() and use it in tagtree.c."
It was committed by accident (it's on FS still).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30157 a1c6a512-1295-4272-9138-f99709370657
2011-07-18 18:57:50 +00:00
Thomas Martitz 74ab227b58 Introduce bsearch() and use it in tagtree.c.
bsearch() is a general purpose binary search function for arrays.
It's supposedly faster than looping over arrays.
The array needs to be sorted in ascending order under the provided
comparison function. If the key and array element are of the same kind,
then the same compare function can be used for qsort() and bsearch().

Code taken from glibc.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30155 a1c6a512-1295-4272-9138-f99709370657
2011-07-18 18:55:20 +00:00
Miika Pekkarinen d0084ffd7a Fixed a regression caused in r30021: tagnavi_custom.config parsing
fails if lines ended with <CR><LF> sequence.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30058 a1c6a512-1295-4272-9138-f99709370657
2011-06-23 20:22:00 +00:00
Thomas Martitz 316f9a0238 tagtree: Refactor memory allocation to local functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30029 a1c6a512-1295-4272-9138-f99709370657
2011-06-20 19:32:56 +00:00
Thomas Martitz 19d08c2664 Move struct search_instruction into struct menu root, as they're not allocated or used independently.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30028 a1c6a512-1295-4272-9138-f99709370657
2011-06-20 19:32:52 +00:00
Michael Hohmuth 851cac848a Prevent out-of-bounds array access when a tagnavi config file defines too many %format specifications
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30006 a1c6a512-1295-4272-9138-f99709370657
2011-06-14 20:54:26 +00:00
Michael Hohmuth 05a1984eb3 FS#12065 - Fix two regressions introduced with r26192 (FS#10976 /
FS#10992 - make the <Untagged> string translatable):

* The translation was done too early: before the tagnavi format
  clauses were checked.  This prevented comparisons against
  "<Untagged>" when a non-English translation was active.

* The code overwrote the buffer containing the constant string
  "<Untagged>" with the translation.  This is neither safe nor
  necessary: The result pointer simply can be swapped with a pointer
  to the translation.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29941 a1c6a512-1295-4272-9138-f99709370657
2011-06-01 08:00:37 +00:00
Nils Wallménius f42a305b57 Accept FS#12136: Save some binsize in tagtree.c. Thanks to sideral for testing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29937 a1c6a512-1295-4272-9138-f99709370657
2011-05-31 19:44:21 +00:00
Michael Hohmuth 6a24a7a903 tagnavi.config: Add a logical-OR operator ("|") for tagnavi conditionals.
Logical-AND ("&") always takes precedence over logical-OR.
(Parentheses are not supported.)

Fight binsize increase by storing some common expressions in local
variables. This avoids repeated reevaluations involving memory
accesses.

check_clauses: Fail clause (return false) in case of errors (tag too
long, DB entry deleted).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29851 a1c6a512-1295-4272-9138-f99709370657
2011-05-10 10:25:41 +00:00
Magnus Holmgren ed2cfb8c1d Don't (partially) apply changes to max entries in the file browser immediately. The setting affects a buffer that is allocated during boot, so code using that buffer should use the value that was in effect during boot. Add a note to the manual that a reboot is needed for the changes to be applied.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29798 a1c6a512-1295-4272-9138-f99709370657
2011-04-30 11:00:26 +00:00
Michael Sevakis 6510973223 Give playback engine better control over the codec. Codec simply follows commands and doesn't concern itself with audio state. Get track change notification in on the actual last buffer insert of the track because now audio simply waits for a track change notify from PCM on the last track and it must be sent reliably. This is still at an intermediate stage but works. Codecs and plugins become incompatible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29387 a1c6a512-1295-4272-9138-f99709370657
2011-02-23 14:31:13 +00:00
Michael Hohmuth 4844142e16 Do not update resume information and do not log statistics when a
track is interrupted within the first 15 seconds.

Regard a rewind to 0:00 as a track restart (updating resume position /
playback statistics before the rewind and starting the 15 s delay).

This allows skipping forward across an unplayed track without changing
its resume offset.  Also, it is possible to skip backward to the
previous track after rewinding to the current track to 0:00 (pressing
Left twice) without losing the current track's resume position.

Initially contributed by Dave Slusher

Caveats:

* Works only for SWCODEC
* Skipping forward without altering the resume position does not work
  when skip to outro has been turned on.
* The 15-second window in which the resume offset will not be updated
  should start at the initial resume position, not at 0:00.  This
  would allow skipping over partially played tracks without altering
  the resume position.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29250 a1c6a512-1295-4272-9138-f99709370657
2011-02-08 20:31:27 +00:00
Dominik Riebeling d2cc5ce58e Fix player becoming unresponsive on Stop / Pause in some cases.
Fix for FS#11856: In tagtree_buffer_event, do not wait for database to
come online as that may never happen.  Rather, wait until it either
has come online or has decided that this will never happen.  Added a
new function to tagcache.c to export this information.

Flyspray: FS#11865
Author: Michael Hohmuth


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29081 a1c6a512-1295-4272-9138-f99709370657
2011-01-17 22:28:36 +00:00
Michael Giacomelli cacc64a4fe Blind commit a 'fix' for automatic resume on HWCODEC since I don't understand HWCODEC and have no way to test builds for it. For now just disable it. In the long term it would be nice to support this on HWCODEC, or failing that, clean this up a little more.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28943 a1c6a512-1295-4272-9138-f99709370657
2011-01-02 03:48:40 +00:00
Michael Giacomelli 66e8fc0f0d Commit part of FS#11748 by Michael Hohmuth. Adds support for automatically resuming any song that is not played to completion at any point later in time, regardless of how many intermediate tracks are played. This is accomplished by expanding the database to record incompletely played tracks. Currently, the feature is simply on or off, in which case all tracks automatically resume, or they do not. The remainder of patches in the task expand this feature by allowing only certain file to automatically resume, only resuming in certain circumstances, etc but are not included until we reach agreement on what should be included. Additionally, the manual will need to be updated once we agree on the available settings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28942 a1c6a512-1295-4272-9138-f99709370657
2011-01-02 02:49:13 +00:00
Jonathan Gordon 7270e5eafd Accept FS#11722 by Michael Hohmuth
Wait for the db to be ready before trying to to any runtime stats

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28608 a1c6a512-1295-4272-9138-f99709370657
2010-11-16 13:17:37 +00:00
Thomas Martitz 6eaab4d004 Ged rid of uisimulator/common/io.c for android builds.
Use host's functions for file i/o directly (open(), close() ,etc.), not the sim_* variants.
Some dir functions need to be wrapped still because we need to cache the parents dir's path (host's dirent doesn't let us know).
For the same reason (incompatibility) with host's dirent) detach some members from Rockbox' dirent struct and put it into an extra one,
the values can be retrieved via the new dir_get_info().

Get rid of the sim_ prefix for sleep as well and change the signature to unix sleep().

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27968 a1c6a512-1295-4272-9138-f99709370657
2010-09-01 21:29:34 +00:00
Jonathan Gordon 0e263d5b77 accept FS#10992 by Rui Araújo to fix FS#10976 - make the <Untagged> string translatable
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26192 a1c6a512-1295-4272-9138-f99709370657
2010-05-20 13:24:50 +00:00
Thomas Martitz 50a6ca39ad Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes).
This is to a) to cleanup firmware/common and firmware/include a bit, but also b) for Rockbox as an application which should use the host system's c library and headers, separating makes it easy to exclude our files from the build.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25850 a1c6a512-1295-4272-9138-f99709370657
2010-05-06 21:04:40 +00:00
Jonathan Gordon 6643a3bc74 Fix FS#9660 - make warn on playlist erase work correctly when creating a new playlist from the database (a bit of a hack, but not bad enough to outright reject)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24089 a1c6a512-1295-4272-9138-f99709370657
2009-12-21 05:44:00 +00:00
Jeffrey Goode 9d842683eb Comment out LOGF_ENABLE defines everywhere, replace evil comments
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23497 a1c6a512-1295-4272-9138-f99709370657
2009-11-03 16:25:03 +00:00
Jeffrey Goode 9a4420bf96 FS#10739: playback.c code split
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23444 a1c6a512-1295-4272-9138-f99709370657
2009-10-31 19:17:36 +00:00
Thomas Martitz 774bacc692 Correct wrong usage of event callbacks all over the place. It's not supposed to return anything, and should take a data parameter.
Fixing it because correcting the event api prototypes causes many warnings.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23301 a1c6a512-1295-4272-9138-f99709370657
2009-10-20 21:54:44 +00:00
Thomas Martitz 16983afae7 Fix displaying of the database browser's progress splash so that it works as intended (according to r16432: hide until 0.5s have passed, but never if the disk isn't spinning).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22442 a1c6a512-1295-4272-9138-f99709370657
2009-08-20 19:31:09 +00:00
Thomas Martitz 18e40e0f4c Make kbd_input() show a cancel splash to indicate user abort better and for better consistency all over the place. Change checking for its return value (style-wise) at some places too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22269 a1c6a512-1295-4272-9138-f99709370657
2009-08-12 14:38:25 +00:00
Nils Wallménius 3d4701a6e4 FS#10080
* Move strncpy() from core to the pluginlib
* Introduce strlcpy() and use that instead in most places (use memcpy in a few) in core and some plugins
* Drop strncpy() from the codec api as no codec used it
* Bump codec and plugin api versions


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21863 a1c6a512-1295-4272-9138-f99709370657
2009-07-14 13:57:45 +00:00
Miika Pekkarinen 8e2bdcaab6 A bunch of stability fixes into tagcache engine and database browser. Mainly data retrieval problems, races, data corruption of sorted index files at the end with junk data, access to unitialized memory and so on. Should fix FS#8710 and may fix FS#8414.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21402 a1c6a512-1295-4272-9138-f99709370657
2009-06-20 16:17:54 +00:00
Andrew Mahone 1248a0dc1f Replace arrays of tags that are numeric/sorted/uniqued with bitfields flagging each tag that is a member of the set, and replace the membership tests with a shift and bitwise and. The test is still done inside a function on SH, as this saves some space vs the macro used on other targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21175 a1c6a512-1295-4272-9138-f99709370657
2009-06-03 08:19:32 +00:00
Thomas Martitz 38d5175b52 Rename struct root_menu and the global int root_menu to avoid clashes with #including plugin.h (which #includes root_menu.h), which will be needed for pictureflow in the database (I have some code for that).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21137 a1c6a512-1295-4272-9138-f99709370657
2009-05-30 16:35:28 +00:00
Thomas Martitz fc502e0b15 Move enum table into tagtree.c as it's not used elsewhere and switch to uppercase for its constants as per docs/CONTRIBUTING.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21135 a1c6a512-1295-4272-9138-f99709370657
2009-05-30 16:10:34 +00:00
Bertrik Sikken 2dc2054319 Remove some unused declarations
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21010 a1c6a512-1295-4272-9138-f99709370657
2009-05-21 12:32:26 +00:00
Bertrik Sikken b24fafbf14 Yet more #include cleanups
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20249 a1c6a512-1295-4272-9138-f99709370657
2009-03-08 20:28:15 +00:00
Frank Gevaerts 2f8a0081c6 Apply FS#9500. This adds a storage_*() abstraction to replace ata_*(). To do that, it also introduces sd_*, nand_*, and mmc_*.
This should be a good first step to allow multi-driver targets, like the Elio (ATA/SD), or the D2 (NAND/SD).


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18960 a1c6a512-1295-4272-9138-f99709370657
2008-11-01 16:14:28 +00:00
Jonathan Gordon 71898e5c54 Accept FS#9480 - centralise and organise the events in the apps/ layer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18819 a1c6a512-1295-4272-9138-f99709370657
2008-10-16 10:38:03 +00:00
Frank Gevaerts 46573019a5 add HAVE_DISK_STORAGE, and use that instead of HAVE_FLASH_STORAGE when checking for an actual disk (i.e. related to spindown, skipping,...)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18735 a1c6a512-1295-4272-9138-f99709370657
2008-10-07 19:37:33 +00:00
Jonathan Gordon a3b9bfc763 dont let the database create a new playlist when party mode is on. (fixes FS#8292)
its not consistant with the filebrowser though, i.e you have to open the context menu for the item to add it to the playlist (whereas in the filebrowser it automatically gets queued if its selected)
still better than ignoreing the setting though


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18316 a1c6a512-1295-4272-9138-f99709370657
2008-08-19 12:05:01 +00:00