Commit graph

780 commits

Author SHA1 Message Date
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
William Wilgus
a06d9c85f7 Auto-Ranging Time Formatting For Menus (hh:mm:ss:mss)
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-12-22 12:27:21 -06:00
William Wilgus
7a132a257a Fix playback.c audio_track_count() warning
changes return to unsigned int to match underlying aliased function

Change-Id: I7015c7ad929344441249aa7c4f2af361142fcaf4
2018-10-18 09:57:20 -04:00
Michael Sevakis
dfff938dff Get rid of useless playlist probing and fix up some data types.
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-17 16:33:50 -05:00
Michael Sevakis
02d20ebc25 Fix big WTF when closing the current track.
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-15 22:39:46 -05:00
Michael Sevakis
c8564f1ca8 Get voice event out of playback.c
Purpose: A step in removing all voice references from playback code
and prelude to other changes.

Change-Id: Ic3ad7f7a33b979693e18a3456ced37eb1d2281a4
2017-12-12 20:28:56 -05:00
Michael Sevakis
65515f32b6 Fix yellow on hosted targets from c1a01be
Change-Id: I4c63efc6570368df76b6c4bbfb5b673dd081145b
2017-12-09 17:34:33 -05:00
Michael Sevakis
c1a01beded Playback: Move internal track list onto buffer
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-09 17:05:59 -05:00
Michael Sevakis
83e8e35a58 Ensure ci is properly updated if seeking before track load completes
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-07 11:33:29 -05:00
Michael Sevakis
bef75a94f8 Playback: C99-ize FOREACH_ALBUMART; make loop counter local
Change-Id: Ie6d571ef217246e22b465ef39097ad9d9d1a6436
2017-12-04 12:59:15 -05:00
Michael Sevakis
abef236081 Do playback restarts the proper way
It isn't necessary to explicitly stop and restart playback to
force it to update something that must cause rebuffering.

Change-Id: I6ff5394fcafc7374af67ef9fbf9022bb4a79b773
2017-11-24 08:55:49 -05:00
Michael Sevakis
5e4532c87c Fix a problem with audio not starting on a list of short files
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
2017-04-06 19:32:35 -04:00
Mihail Zenkov
25fc7f1860 Fix broken logf 2016-03-30 20:48:17 +00:00
Udo Schläpfer
dbabd0d9c3 iBasso DX50/DX90: Major code cleanup and reorganization.
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-02-02 21:57:55 +01:00
Thomas Jarosch
cfbd9cb22f Make a few local variables static
Change-Id: Ieb77a7f2cdf765afa3121320d03c0478cd97eb0f
2015-01-11 18:02:43 +01:00
Michael Sevakis
5b08f1a5b9 Remove I/O priority. It is harmful when used with the new file code.
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-08-30 14:01:21 -04:00
Michael Sevakis
221c495432 Fix a playback bug in shink_callback()
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-06-20 04:54:18 -04: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
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
Andrew Ryabinin
500b137308 playback: Fix build with LOGF_ENABLE.
Change-Id: I01154d4a9441f44852748c910c267419f7f4149e
2013-11-10 15:36:18 +04: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
d37bf24d90 Enable setting of global output samplerate on certain targets.
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-07-06 04:22:04 +02:00
Michael Sevakis
9b990bdab1 SWCODEC Audio: Add some INIT_ATTR's to get a few bytes back.
Change-Id: Ie7b04ecf3b3535e0ed45a6e0e8d81af89e38378e
2013-06-29 22:29:23 -04:00
Michael Sevakis
4888131972 Update software recording engine to latest codec interface.
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-30 00:40:27 +02:00
Michael Sevakis
a9ea1a4269 Fix some whitespace in files changed in following commit.
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-06-30 00:40:09 +02:00
Michael Sevakis
98c34d8723 Argh, move a comment to the (now) proper location. :)
Change-Id: I13847b99d9aeaa05efa5b22a8e4842f193f01a3c
2013-05-31 19:01:24 -04:00
Michael Sevakis
e62cb56644 Have voice fire an event when it starts and stops playing.
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-31 18:45:51 -04:00
Michael Sevakis
1b4135ec0d Should use HAVE_RECORDING, not AUDIO_HAVE_RECORDING in playback.c
SIM should work like target, sort of, when recording is initialized.

Change-Id: I12314bb98cec53d574f4b25984ef803b2c038a96
2013-05-31 06:24:06 -04:00
Michael Sevakis
344b9d0986 Some corrections after 5857c44.
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-31 04:13:39 -04:00
Michael Sevakis
5857c44017 Refactor audio thread to run both recording and playback.
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-05-31 03:20:35 -04:00
Bertrik Sikken
0de2a85ae1 Change audio_set_cuesheet parameter from int to bool (fixes cppcheck warning)
Change-Id: Icb31c8bd8605aca27765a94b609c41f1f706426f
2013-03-24 14:58:40 +01:00
Michael Sevakis
652b39b9e1 More snafu fix. Need a couple more patchups for now.
Must restore talk buffer explicitly when not taking it and promote
the buffer state.

Change-Id: Ia0341ede05837e6e94885a9ad62460c415ec6f00
2012-05-24 20:59:05 -04:00
Michael Sevakis
0ebfb937aa Fix some lockup caused by handles not being initialized to < 0...
...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-21 02:28:13 -04:00
Michael Sevakis
da6cebb6b0 Use buflib for the allocation of voice PCM resources.
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-02 17:22:28 -04:00
Sean Bartell
4bef502d4d rbcodec refactoring: autoresumable
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-05-01 11:28:38 +02:00
Sean Bartell
fe3d58004c rbcodec refactoring: get_audio_base_data_type
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-04-28 09:07:40 +02:00
Thomas Martitz
82337dda6a buflib/shrink_callback: Resume playback only if it was playing (not paused).
Change-Id: Ie4884ec4554890f8bdb03f48bcf215ece00a5560
2012-03-25 22:28:07 +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
Alexander Levin
63c4ef9f57 Rename 'mp3entry.embed_albumart' to 'mp3entry.has_embedded_albumart' (FS#12470). No functional changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31405 a1c6a512-1295-4272-9138-f99709370657
2011-12-22 18:48:43 +00:00
Nick Peskett
02fd314a0b FS #12419 : Support for embedded cuesheets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31321 a1c6a512-1295-4272-9138-f99709370657
2011-12-16 10:09:41 +00:00
Boris Gjenero
8e6030c822 FS#12378 : Remove various unused code, and comment out some unused code and data for reference or future use.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31256 a1c6a512-1295-4272-9138-f99709370657
2011-12-14 21:45:25 +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
Thomas Martitz
2a8eacdbfc Buflib: Make shrinking and buflib_available() smarter.
* shrinking now considers freespace just before the alloc-to-be-shrinked,
  that means less (or sometimes none at all) is taken from the audio buffer.
* core_available() now searches for the best free space, instead of simply the end,
  i.e. it will not return 0 if the audio buffer is allocated and there's free space
  before it. It also runs a compaction to ensure maximum contiguous memory.

audio_buffer_available() is also enhanced. It now considers the 256K reserve buffer,
and returns free buflib space instead if the audio buffer is short.

This all fixes the root problem of FS#12344 (Sansa Clip+: PANIC occurred when
dircache is enabled), that alloced from the audio buffer, even if it was very
short and buflib had many more available as free space before it.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31006 a1c6a512-1295-4272-9138-f99709370657
2011-11-17 17:55:02 +00:00