Commit graph

357 commits

Author SHA1 Message Date
Christian Soffke
674c07d654 (Fix FS#13281) Revert "Restore playlist state as necessary before checking whether current playlist has been modified"
This reverts commit 46085c8978.

Change-Id: Id8540bb44b64546389d06593d8ff46588b634b53
2021-04-01 07:57:12 +02:00
Christian Soffke
e862816773 Fix FS#13278: error message when playing a song with Rockbox for the very first time
The function to check whether a playlist has been modified
will now only try to resume a playlist, if the global resume index
is not -1.

This also means that replacing a finished (modified) playlist will not
produce a warning anymore if Rockbox has been restarted in
between. In that respect, the behavior is identical to
what it was *before* 46085c8978.

Change-Id: Ib95f89043274f1c72c75023d1506fc093aaf4cf9
2021-03-23 05:17:56 +01:00
Christian Soffke
3bb78b468d Resume audio after user selects a new song
Music currently doesn't begin playing after the user has selected a new song from a playlist or using the database/file browser, unless another item was already playing or the previous player state was "stopped" but not "paused". This results in an inconsistent user experience. The user's likely intention is to immediately listen to a song they select regardless of the previous player state.

Change-Id: I574c3fe5c12fee544da0569182fc9573d307ac2f
2021-03-16 15:11:33 +00:00
Christian Soffke
46085c8978 Restore playlist state as necessary before checking whether current playlist has been modified
Rockbox would previously not present a warning when you were about
to replace a modified playlist after restarting the player,
unless you first resumed playback.

Change-Id: I9752228f84b105747e41ce6e1c8f95f0f9f14c10
2021-03-16 12:56:18 +00:00
William Wilgus
895ed92496 Talk.c, playlist.c fix bugs
fix bug in talk.c

playlist.c only dump voice buffer if we are out of space

Change-Id: I75705d755db4193a87e542d062dbdc96b153dbb6
2021-03-04 23:31:32 -05:00
William Wilgus
80be135d0d OOM on playlist_resume
Discovered on ClipZip but applicable to other LOW MEM targets

Back off voice buffer on playlist_resume

Change-Id: Ia316c4b7fc1bcb089d3069a13dd7c193edf2ba1e
2021-03-04 13:32:45 +00:00
Solomon Peachy
8c76c1b1c2 Revert "Always resume audio after user picks a new song from a playlist"
This reverts commit 69746d8400.

Change-Id: I33969c228a88cdba3537844a1962cac85cfa80e5
2021-02-19 13:35:15 +00:00
Christian Soffke
436e64e09e Fix playback queue bug when "Insert Next" is used with multiple songs at once
After using “Insert Next” to insert multiple songs at once (e.g. an album from the database browser or folder from the file browser), subsequent Insert operations will incorrectly insert items after the first song of all items that were previously inserted, instead of after the last song of the previously inserted items.

A bug fix was originally written by Costas Calamvokis for the file browser only. I adopted the original fix and added code analogous to it so that it works from the database browser as well.

See FS#7898, FS#7363 or this forum post for more info:
https://forums.rockbox.org/index.php/topic,53741.0.html

Change-Id: Ie2718e136df0b340000f7a171e9e806cf23a27b4
2021-02-17 11:34:59 +00:00
Christian Soffke
69746d8400 Always resume audio after user picks a new song from a playlist
Music currently doesn't begin playing after the user has selected a new song in a playlist, unless another item was already playing or the previous player state was "stopped" (but not "paused"). This results in an inconsistent user experience. The user's likely intention is to immediately listen to the song they select for playback regardless of the previous player state.

Change-Id: I68a8da01b06a81d8c3b61e351710431152bfdfaa
2021-02-17 11:32:32 +00:00
Solomon Peachy
b6a16949e8 playlist: Fix out-of-bounds array access when the directory is blank
Change-Id: Ibf59f8191f1f26cf97c5d3ffcb5e3e4c7304bca0
2020-12-13 19:20:38 -05: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
8cb555460f [3/4] Completely remove HWCODEC support
'swcodec' is now always set (and recording_swcodec for recording-capable
units) in feature.txt so the manual and language strings don't need to
all be fixed up.

Change-Id: Ib2c9d5d157af8d33653e2d4b4a12881b9aa6ddb0
2020-07-24 21:20:13 +00:00
William Wilgus
776ceae119 Playlist Viewer Fix FS#13197
While playing a track the playlist viewer may not
have a big enough temporary buffer to load and display
'max_files_in_playlist' entries

This patch attempts to load as many entries as possible

If tracks were already playing (dynamic playlist or otherwise)
The original code only gave half the plugin buffer to a playlist
loaded from file

On some targets half the plugin buffer is not enough to load all entries…

Now we attempt to get as many entries possible while at least leaving a
small buffer (MAX_PATH) for the name buffer

Change-Id: Ic06eaabc4e2550f076d625957d6d073790852743
2020-05-20 18:41:58 +02:00
Solomon Peachy
7bef453e03 FS#12887: Fix playlist order after moving a track before current
Original patch by Juan Gonzalez
Updated by Igor Poretsky

Change-Id: I913d96df906e56fb4063485a6725cd13e395f165
2019-07-24 14:20:03 -04:00
William Wilgus
929ea73cd6 playlist.c suppress playlist access error on usb plug
Change-Id: I6bf446ecb17f5526c2f37158e672f06a5435f5a9
2019-01-04 05:28:26 +01:00
William Wilgus
3f110daf30 Fix tree.c->tree_get_entry_at() buffer overflow
I observed a crash on buflib>move_block
after dumping ram I noticed that the buffer for filetypes was being corrupted

tree_get_entry_at returns a entry from the buflib 'tree entry' buffer
filetree.c->ft_load writes data to this buffer before checking if it has
reached the last entry resulting in buffer overflow that overwrites the
next entry in the buffer ['filetypes']

Patch checks that the index passed to tree_get_entry_at() is in range
otherwise it returns NULL

Added checks + panic in other functions using tree_get_entry_at()
Fixed tree_lock_cache() calls in playlist and filetree

Change-Id: Ibf9e65652b4e00445e8e509629aebbcddffcfd4d
2018-12-14 01:28:17 -06:00
William Wilgus
2fb6b2b458 Fix truncation warning playlist.c, tree.c
Change-Id: I0c62f06fea3ccb55efa21b719a44a263dedc32e2
2018-07-25 18:34:53 +02:00
Michael Sevakis
ff62528d05 Make playlist CRC the correct path when saving resume info
Playlist was CRC-ing the path from the id3, which may have been
modified to remove "bogus dirs". This would cause a CRC mismatch
in the resume information.

Now, just use the current playlist's current index and call
playlist_get_filename_crc32() to get the original path when
updating resume info.

While technically correct, if this causes any issue(s) it's just
a one-line change and painless to revert.

Change-Id: Ie595ef6c40349c342bd7acac8c542829f9cd5d76
2017-10-07 14:38:46 -04:00
Michael Sevakis
7373cf518f Restore dircache hookup in the database ramcache.
Do a few other changes to dircache and file code flags to
accomodate its demands.

Change-Id: I4742a54e8cfbe4d8b9cffb75faaf920dd907cf8a
2017-02-10 05:05:23 -05:00
Michael Sevakis
16a9f84571 Reenable database ramcache and playlist dircache
Playlist dircache references should be back in working order.

Reenabling dircache references in the database ramcache is not
yet done as it requires quite a bit of rework. Otherwise, the
database in RAM is functional again.

Some buffer compatibility changes have been made for database
commit because the dircache buffer can no longer be stolen, only
freed by an API call.

Change-Id: Ib57c3e98cb23e798d4439e9da7ebd73826e733a4
2017-01-17 15:27:47 -05:00
Michael Sevakis
5c6ccb43b5 Fix track formatting problems in playlist.c
Some changes in behavior were made with filesystem code commit
for the sake of compatibility that changed expected behavior.

* Restore substitution of drive spec in fully-qualified DOS paths
with the playlists's volume spec (or root on univolume targets).
Drive-relative paths of the form "c:foo" (no separator after
':') will be treated as purely relative.

* Restore old behavior of preserving leading whitespace in the
source path and trimming only trailing tabs and spaces.

* Multivolume: Volume substition on fully-qualified UNIX/RB paths
has NOT been reintroduced (and perhaps wasn't intended in the
first place). They will not be modified because there is no
ambiguity to resolve. Doing so would prevent a playlist on
external storage from referencing a file on main storage without
qualifying it with "/<0>...".

* Plain relative paths are and always have been interpreted as
relative to the location of the playlist.

Change-Id: Ic0800cea79c59563b7bac20f8b08abb5051906c7
2017-01-07 19:10:02 -05:00
Thomas Jarosch
f8d9e9cb6c m3u playlist parser: Check size limit before using buffer
This should only be a problem if the last line
is not terminated by \r or \n though.

cppcheck reported:
[rockbox/apps/playlist.c:234]: (style) Array index 'i' is used before limits check.

Change-Id: I8182b66272ba9c024984c81588bd2a6dbb8255b8
2014-12-20 13:14:19 +01:00
Szymon Dziok
4c6939fc3d Correct some file permissions.
Change-Id: I4a092a19d6a9c66dfeb2777c9655aa4b19d11e16
2014-09-08 16:04:39 +02:00
Michael Sevakis
7d1a47cf13 Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.

Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.

Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.

Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.

2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.

3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.

4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.

Key core changes:
1) Files and directories share core code and data structures.

2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).

3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.

4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".

5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.

6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).

Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:

1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).

2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.

3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.

4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.

5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.

Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.

2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.

3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).

4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).

5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).

Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.

To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.

2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.

Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2014-08-30 03:48:23 +02:00
Thomas Martitz
35b4ba8513 root_menu: Remove previous_music_is_wps() and change previous_music via event callback.
Change-Id: I0f3b85a8fe8010a2480ef44a72a90dc7904bc777
2014-04-15 23:54:28 +02:00
Thomas Martitz
bebf71a08b playlist: Get rid of plugin buffer use in playlist_save().
The plugin buffer was used only to avoid reparsing the playlist, so non-essential.
But when it was used it conflicted with the playlist viewer which already uses
the plugin buffer for playlist purposes simultaneously. It only works by
accident.

Since the reparse avoidance is non-essential don't do it for now. A temp buffer
can be passed to playlist_save() to enable it but the only caller (as of now)
does not do that.

Change-Id: I3f75f89d8551e1ec38800268b273105faba0efbf
2014-04-15 23:54:28 +02: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
706e6b7a75 Move VOL_NAMES definition to mv.h
Fits better and including dir.h is more messy for some places.

Change-Id: I3ec30dcc1ac2734ad3844c903238b6cc2f4e134c
2014-02-23 20:23:51 +01:00
Thomas Martitz
22e802e800 playback,talk: Share audiobuffer via core_alloc_maximum().
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-12-23 12:17:38 +01:00
Richard Quirk
212e7808d5 Use crc32 of filename to resume tracks
As well as using an index, which breaks when a file is added or
removed, use the crc32 of the filename. When the crc32 check passes the
index is used directly. When it fails, the slow path is taken checking
each file name in the playlist until the right crc is found. If that fails
the playlist is started from the beginning.

See http://www.rockbox.org/tracker/6411

Bump plugin API and nvram version numbers

Change-Id: I156f61a9f1ac428b4a682bc680379cb6b60b1b10
Reviewed-on: http://gerrit.rockbox.org/372
Tested-by: Jonathan Gordon <rockbox@jdgordon.info>
Reviewed-by: Jonathan Gordon <rockbox@jdgordon.info>
2013-01-02 08:29:38 +01:00
Michael Giacomelli
d245997667 Fix warning on previous commit.
Change-Id: Idd760f4e83fc5ade972fe88db3cab9e03c24966c
2012-06-22 11:38:35 -04:00
Michael Giacomelli
b30edcd62f Make playlist.c aware of external storage when determining paths
format_track_path currenyly corrects for things like windows volumes  and
relative paths in playlists, but does not handle external media like SD
cards correctly, resulting in some seemingly valid playlists not working
because of rockbox's mount point for external media.  Correct this by checking
to see if a playlist is on external media and then formulate the path correctly
if it is.

Unfortunately, this breaks the playlist_save logic if the CWD is on an external
device.  Its not clear to me why we should be checking the CWD when saving a
playlist, as the only apparent use of this is to let people save relative
paths on the virtual keyboard.  As far as I can tell, this is actually more
difficult to do then using an absolute path given that we insert the CWD
onto the virtualkeyboard by default.  Therefore, I'm removing the option
to use '..' in playlist save paths since its seems useless.

Change-Id: I47946cc45d776c7a72ecbd0ecc720dbf85550f6f
Reviewed-on: http://gerrit.rockbox.org/270
Reviewed-by: Michael Giacomelli <mgiacomelli@gmail.com>
Tested-by: Michael Giacomelli <mgiacomelli@gmail.com>
2012-06-22 17:05:03 +02:00
Bertrik Sikken
beb61a93c5 Not quite a fix for FS#12693 yet, but at least invalidate the playlist file descriptors after closing and removing
Change-Id: Ia43eb517d154d24a6bd581fa3aa69c99a28228ae
2012-06-18 00:45:50 +02:00
Nick Peskett
be10817e1c Option to constrain get_next_dir() to directories below 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>
2012-03-19 11:49:55 +01:00
Boris Gjenero
9c720393b2 Fix FS#12499 - Directory playback fails after saving playlist
This makes playlist_save() properly restore playlist buffer values,
so the buffer can be used afterwards.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31481 a1c6a512-1295-4272-9138-f99709370657
2011-12-31 16:47:58 +00:00
Boris Gjenero
bda8a963ad Add conditionals for functions only needed on SWCODEC targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31296 a1c6a512-1295-4272-9138-f99709370657
2011-12-15 20:58:14 +00:00
Thomas Martitz
1645c148e3 Simulate usb plugging on the sim better using sim_tasks.
Now all threads need to ack the connection like on real target, dircache is unloaded and playback stops accordingly.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31009 a1c6a512-1295-4272-9138-f99709370657
2011-11-17 18:40:00 +00:00
Björn Stenberg
0942e2a0f7 Changed the FOR_NB_SCREENS macro to always be a for loop that declares its own loop variable. This removes the need to declare this variable in the outer scope.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30756 a1c6a512-1295-4272-9138-f99709370657
2011-10-15 19:35:02 +00: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
Thomas Jarosch
12ac381408 Fix file descriptor leak on error
Credit goes to "cppcheck".

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30349 a1c6a512-1295-4272-9138-f99709370657
2011-08-25 19:39:01 +00:00
Thomas Martitz
d1322b7159 GSoC/Buflib: Replace all direct accesses to audiobuf with buffer API functions.
Namely, introduce buffer_get_buffer() and buffer_release_buffer().
buffer_get_buffer() aquires all available and grabs a lock, attempting to
call buffer_alloc() or buffer_get_buffer() while this lock is locked will cause
a panicf() (doesn't actually happen, but is for debugging purpose).
buffer_release_buffer() unlocks that lock and can additionally increment the
audiobuf buffer to make an allocation. Pass 0 to only unlock if buffer was
used temporarily only.
buffer_available() is a replacement function to query audiobuflen, i.e. what's
left in the buffer.
Buffer init is moved up in the init chain and handles ipodvideo64mb internally.

Further changes happened to mp3data.c and talk.c as to not call the above API
functions, but get the buffer from callers. The caller is the audio system
which has the buffer lock while mp3data.c and talk mess with the buffer.
mpeg.c now implements some buffer related functions of playback.h, especially
audio_get_buffer(), allowing to reduce #ifdef hell a tiny bit.

audiobuf and audiobufend are local to buffer.c now.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30308 a1c6a512-1295-4272-9138-f99709370657
2011-08-14 15:13:00 +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
Jonathan Gordon
d1fd4f08f5 Fix FS#8656 - Error saving non-current playlist file
Use the plugin buffer to save the playlist copy if there isnt enough buffer already allocated to the inram copy of the playlist

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30184 a1c6a512-1295-4272-9138-f99709370657
2011-07-21 06:40:21 +00:00
Thomas Martitz
5eb2f60afb Revert r30030 "Remove unused code path from playlist_create_ex()."
It breaks playlist viewing when playback is stopped (the code path wasn't so unused).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30150 a1c6a512-1295-4272-9138-f99709370657
2011-07-17 13:30:48 +00:00
Thomas Martitz
00dfcb8159 Fix FS#12181 - Playlist re-shuffle does not work (r30122)
Dircache IDs can be 0, so to invalidate -1 must be used.
Update the memset calls to reflect this.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30125 a1c6a512-1295-4272-9138-f99709370657
2011-07-06 19:41:39 +00:00
Miika Pekkarinen
2bc133dce9 Try to handle dircache rebuild event properly. Playlist should now
cache new pointers to dircache items when dircache goes
offline and comes back onlineagain (during tagcache commit). This
should prevent wrong filenames to appear in playlist.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30047 a1c6a512-1295-4272-9138-f99709370657
2011-06-21 17:42:31 +00:00
Thomas Martitz
af7aaae478 Dircache: Don't expose struct dircache_entry and pointers into the cache, use IDs instead.
Only integer IDs are exposed from dircache with this. This way the cache is isolated from other modules.
This is needed for my buflib gsoc project.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30038 a1c6a512-1295-4272-9138-f99709370657
2011-06-20 20:12:42 +00:00
Thomas Martitz
e063725534 Dircache: Return the size of the result string in dircache_copy_path() so that callers don't need to call strlen on it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30034 a1c6a512-1295-4272-9138-f99709370657
2011-06-20 20:12:15 +00:00
Thomas Martitz
1a86aab1a2 Remove unused code path from playlist_create_ex().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30030 a1c6a512-1295-4272-9138-f99709370657
2011-06-20 19:33:03 +00:00
Michael Sevakis
c537d5958e Commit FS#12069 - Playback rework - first stages. Gives as thorough as possible a treatment of codec management, track change and metadata logic as possible while maintaining fairly narrow focus and not rewriting everything all at once. Please see the rockbox-dev mail archive on 2011-04-25 (Playback engine rework) for a more thorough manifest of what was addressed. Plugins and codecs become incompatible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29785 a1c6a512-1295-4272-9138-f99709370657
2011-04-27 03:08:23 +00:00
Michael Sevakis
d5849e0d30 Playlists forget to set playlist.started when creating new playlist on SWCODEC and which leads to flush-and-rebuffer messages never being sent again until playback is restarted.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29697 a1c6a512-1295-4272-9138-f99709370657
2011-04-09 13:07:08 +00:00
Andree Buschmann
39d9d8bab1 Fix red and yellow. Move resume_index from mp3entry to playlist_info struct. Bump codec api.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29691 a1c6a512-1295-4272-9138-f99709370657
2011-04-07 21:38:51 +00:00
Andree Buschmann
4df825be43 Fix regressions of r29682. Update playlist index resume position when playlist changes (e.g. shuffling, inserting, removing, ...).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29690 a1c6a512-1295-4272-9138-f99709370657
2011-04-07 20:33:00 +00:00
Andree Buschmann
3184cbe10a Fix FS#12043. Next track was resumed when pausing and shutting down the player in the last seconds of a track.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29682 a1c6a512-1295-4272-9138-f99709370657
2011-04-06 19:11:40 +00:00
Thomas Jarosch
3926c30705 Make sure we don't read past the end of a C-string in format_track_path. Second part of FS #11947
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29326 a1c6a512-1295-4272-9138-f99709370657
2011-02-18 21:56:48 +00:00
Thomas Jarosch
15a5f9ca95 Don't underflow the buffer in format_track_path() if it consists of whitespaces
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29325 a1c6a512-1295-4272-9138-f99709370657
2011-02-18 21:39:59 +00:00
Thomas Jarosch
84fccff170 Fix off-by-one buffer read access in format_track_path(). Part of #11947
We need to check for "i < max" first.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29324 a1c6a512-1295-4272-9138-f99709370657
2011-02-18 21:21:50 +00:00
Michael Sevakis
b15aa47c56 All kernel objects in code shared amongs targets (core, plugins, codecs) should be declared SHAREDBSS_ATTR as any core could potentially touch them even though they seem only to involve threads on one core. The exception is target code for particular CPUs where proper allocation is fixed. playlist.c was a little odd too-- use one mutex for the current playlist and a separate one for created playlists (still pondering the necessity of more than one).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29305 a1c6a512-1295-4272-9138-f99709370657
2011-02-14 11:27:45 +00:00
Thomas Martitz
2c2416094f Get rid of get_user_file_path and do the path handling in wrappers for open() and friends.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28752 a1c6a512-1295-4272-9138-f99709370657
2010-12-06 22:26:31 +00:00
Teruaki Kawashima
47f670d3c2 FS#11725: fix duplicationg slash indicating root in filename.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28705 a1c6a512-1295-4272-9138-f99709370657
2010-11-29 12:51:44 +00:00
Rafaël Carré
1dfebdddbe playlist_shuffle(): remove unused variable
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28108 a1c6a512-1295-4272-9138-f99709370657
2010-09-19 08:16:40 +00:00
Magnus Holmgren
113764d9c0 Fix FS#11175. playlist_peek() wasn't thread safe (due to a static filename buffer), so frequent calls from the main thread would cause the audio thread to buffer the wrong track.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27773 a1c6a512-1295-4272-9138-f99709370657
2010-08-11 19:01:50 +00:00
Thomas Martitz
9c0b2479f7 Rockbox as an application: add get_user_file_path().
For RaaA it evaluates user paths at runtime. For everything but codecs/plugins it will give the path under $HOME/.config/rockbox.org if write access is needed or if the file/folder in question exists there (otherwise it gives /usr/local/share/rockbox).
This allows for installing themes under $HOME as well as having config.cfg and other important files there while installing the application (and default themes) under /usr/local.

On the DAPs it's a no-op, returing /.rockbox directly.

Not converted to use get_user_file_path() are plugins themselves, because RaaA doesn't build plugins yet.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27656 a1c6a512-1295-4272-9138-f99709370657
2010-08-01 16:15:27 +00:00
Thomas Martitz
35e8b1429a Rockbox as an application: Replace many occurences of #ifdef SIMULATOR with #if (CONFIG_PLATFORM & PLATFORM_HOSTED) (or equivalently).
The simulator defines PLATFORM_HOSTED, as RaaA will do (RaaA will not define SIMULATOR).
The new define is to (de-)select code to compile on hosted platforms generally.

Should be no functional change to targets or the simulator.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27019 a1c6a512-1295-4272-9138-f99709370657
2010-06-21 16:53:00 +00:00
Steve Bavin
b08222caec Minor const police raid.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25879 a1c6a512-1295-4272-9138-f99709370657
2010-05-07 16:35:37 +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
Thomas Martitz
0a1d7c28b7 Make open() posix compliant api-wise. A few calls (those with O_CREAT) need the additional optional mode parameter so add it. Impact for the core is almost zero, as open() is a wrapper macro for the real open function which doesn't take the variable parameter.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25844 a1c6a512-1295-4272-9138-f99709370657
2010-05-06 17:35:13 +00:00
Jonathan Gordon
a70d602f7d Aceppt FS#10945 by Tomasz Kowalczyk - Fix playlists not returning to the origional order after shuffle/unshuffle
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24525 a1c6a512-1295-4272-9138-f99709370657
2010-02-05 23:33:31 +00:00
Jonathan Gordon
d0729abb96 fix FS#10288 by Tomasz Kowalczyk. Fixes issues where resuming a "insert shuffled" playlist doesnt recreate the same playlist that was stopped.. (I'm tipsy still... read the task for more info :p )
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24303 a1c6a512-1295-4272-9138-f99709370657
2010-01-21 07:28:37 +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
Nils Wallménius
ee15637749 FS#10834 by Alex Bennee, fixing off-by-one bug in code calling format_track_path
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23879 a1c6a512-1295-4272-9138-f99709370657
2009-12-06 21:11:51 +00:00
Dave Hooper
494fd9673d Committing FS#10717 by Tomasz Kowalyczyk: add PLAYLIST_INSERT_LAST_SHUFFLED (appends the inserted folder into shuffled order to end of playlist)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23385 a1c6a512-1295-4272-9138-f99709370657
2009-10-28 22:27:38 +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
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
Dave Hooper
008f611bca Fix bug in playlist_move where the track would end up one place too early / too late if the move wrapped from one end of the playlist indices to the other end
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21708 a1c6a512-1295-4272-9138-f99709370657
2009-07-08 00:30:23 +00:00
Thomas Martitz
f0aa8ba95d playlist start can only have 1 return value (0), so make it return nothing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21142 a1c6a512-1295-4272-9138-f99709370657
2009-05-31 14:33:33 +00:00
Boris Gjenero
e84520c67e Revert FS#9531 / r19723 - It did not fix the problem, and it caused the index parameter of shuffle and unshuffle .playlist_control commands to be ignored. When those parameters were non-zero, this caused some tracks from the end of the original playlist to instead appear at the beginning of the resumed playlist.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20641 a1c6a512-1295-4272-9138-f99709370657
2009-04-07 16:16:55 +00:00
Thomas Martitz
4ae7415503 Fix insert/queue next, last and replace to update the last insert position too,
giving well defined behavior and useful interaction with insert,
and making things like insert next followed by many inserts work.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20247 a1c6a512-1295-4272-9138-f99709370657
2009-03-08 19:03:53 +00:00
Thomas Martitz
87d1744e91 Fix playlist "Insert" a bit.
If insert was used to create a new playlist (e.g. inserting without audio playing), the insert position wasn't updated. Thus, the playlist created was in reversed order (except for the first song).
This was the reason "Insert last" was actually used as Insert in this case. BUT, this one doesn't update the insert position eiterh, but the order of the songs is fine, at least (due to appending).
Now, insert always updates the insert position properly, so that the aforementioned bugs are fixed. Insert is always used now.
Other impact: If you create a playlist using insert, every subsequent insert will append songs at the end of the playlist,if you start playback pressing select on songs, every subsequent insert will insert after the current track.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20241 a1c6a512-1295-4272-9138-f99709370657
2009-03-08 17:18:18 +00:00
Bertrik Sikken
66cf3a3329 Clean up some #includes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20238 a1c6a512-1295-4272-9138-f99709370657
2009-03-08 16:10:40 +00:00
Marianne Arnold
f5ab7c028e Commit patch by JdGordon to fix FS#9531 (which applied to all targets) - correctly resume shuffled playlists.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19723 a1c6a512-1295-4272-9138-f99709370657
2009-01-08 16:22:09 +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
Nils Wallménius
2ca30a0c74 Minor clean up, move common define to a header file and use TIME_AFTER macro
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18783 a1c6a512-1295-4272-9138-f99709370657
2008-10-12 16:47:59 +00:00
Jens Arnold
a0c91ae4e2 Make the array static const char, and use it for direct lookup, saving binsize this way.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18743 a1c6a512-1295-4272-9138-f99709370657
2008-10-08 17:23:59 +00:00
Nils Wallménius
48b52aec46 Fix FS#8949 - Alphabetical directory listing reversed after "Error Accessing Directory", patch by pondlife, some long line police by me, also kill a few error splashes in functions that could be called by threads other than UI
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18742 a1c6a512-1295-4272-9138-f99709370657
2008-10-08 16:32:01 +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
Nils Wallménius
93a87685c3 Clean up use of snprintf where strncpy if suited, avoid useless copying of constant strings for wps token evaluator, minor const police too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18625 a1c6a512-1295-4272-9138-f99709370657
2008-09-24 20:03:53 +00:00
Jonathan Gordon
95f516e0b9 more slight playlist resume cleanuping... dont bother saving the playlist first index value. its reset to 0 before playlistcontrol is loaded anyway, and then reset to 0 after its finished so its completly useless in global_status.
runtimes, resume info, etc will be reset again...


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18561 a1c6a512-1295-4272-9138-f99709370657
2008-09-21 14:19:18 +00:00
Jonathan Gordon
40d713c5fc FS#9408 - dont bother saving the random seed in global status. I'm 99.9% sure this code was being ignored anyway.
If this commit causes problems with restarting playback open a bug report (getting testers was difficult...) 
Settings which are stored in the nvram.bin file will be reset with this commit. this includes  resume info, runtimes, "last screen" and a few others.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18555 a1c6a512-1295-4272-9138-f99709370657
2008-09-20 15:30:55 +00:00
Nils Wallménius
01729e7a18 FS#9281 Rename of splash functions.
* Remove gui_splash()
* Rename gui_syncsplash() to splashf() and remove its voice 
capabilities.
* Rename the internal splash() to splash_internal() and introduce an 
externally visible splash() that handles simple splashing  without 
printf functionality e.g. splash(HZ, ID2P(LANG_FOO)); or splash(HZ, 
"foo"); if a LANG_* id is passed it will be voiced.
* Adjust all places that called gui_syncsplash() to use the correct 
variant from above.
* Export both new functions to plugins and adjust places calling 
rb->splash() to use the correct variant so that we now have naming 
consistency between the core and plugins.
* Fix one latent bug that would cause my sim to crash with the above 
changes and correct P2STR and P2ID macros, thanks to pondlife.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18282 a1c6a512-1295-4272-9138-f99709370657
2008-08-15 08:27:39 +00:00
Jonathan Gordon
faf32a26b7 r10544 changed the playlist reloading so you couldnt actually abort the process. This fixes it...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18242 a1c6a512-1295-4272-9138-f99709370657
2008-08-11 13:57:26 +00:00
Dominik Riebeling
e299216908 Fix problem with utf8 playlists containing a BOM breaking all entries but the first -- the index calculation needs to take the BOM size into account.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18225 a1c6a512-1295-4272-9138-f99709370657
2008-08-09 11:43:56 +00:00
Dominik Riebeling
02103a2fa7 Unify opening of utf-8 files (FS#6203). This also adds ignoring the BOM in several places it has been missing (as FS#6071).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18185 a1c6a512-1295-4272-9138-f99709370657
2008-08-02 20:39:03 +00:00
Steve Bavin
fa98298983 Only voice track insertion splash if voice menus enabled - fix for FS#9223
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18147 a1c6a512-1295-4272-9138-f99709370657
2008-07-29 13:32:47 +00:00
Jonathan Gordon
f48cf62558 fix the random folder behaviour by not letting it start folders which dont have music in them (but were being started before because it has subdirs with music)
Hopefully fixes FS#7077


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17912 a1c6a512-1295-4272-9138-f99709370657
2008-07-02 09:16:26 +00:00
Jonathan Gordon
8f3175b779 fix FS#9119 (crash if random folder list has no entries)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17862 a1c6a512-1295-4272-9138-f99709370657
2008-06-29 02:19:53 +00:00
Daniel Stenberg
2acc0ac542 Updated our source code header to explicitly mention that we are GPL v2 or
later. We still need to hunt down snippets used that are not. 1324 modified
files...
http://www.rockbox.org/mail/archive/rockbox-dev-archive-2008-06/0060.shtml


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17847 a1c6a512-1295-4272-9138-f99709370657
2008-06-28 18:10:04 +00:00
Magnus Holmgren
82ed56bf59 When saving a .m3u8 playlist, include a byte order mark (BOM), as some applications require it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17786 a1c6a512-1295-4272-9138-f99709370657
2008-06-24 20:44:45 +00:00