Commit graph

154 commits

Author SHA1 Message Date
Thomas Martitz
0b7a90722a talk: On hwcodec disabling DMA interrupt is required during buflib move
Even though the DMA buffer itself does not move the ISR copies from a movable
buffer into the static commit buffer. To ensure this copying yields consistent
data it must not be interrupted by this ISR..

Also bump the commit buffer size to 2k, this should reduce the overhead
considerably because many clips are smaller than that (especially on
swcodec/speex).

Change-Id: I4e1ab83074f31fc91b51a58baa1df55ce659ac73
2014-02-03 12:43:05 +01:00
Thomas Martitz
10b3bc78f6 Fix warnings.
Change-Id: If3cbcd7557797684f1b7fea8e1bb134777680dee
2014-02-03 12:33:33 +01:00
Thomas Martitz
e5eb74592e talk/voice: Reduce the size of the commit buffer.
The voice engine can now request more voice data during decoding, it does
not require the entire clip to be available before start of decoding anymore.
Therefore the commit buffer does not need to hold an entire voice clip anymore,
and can be made greatly smaller.

Change-Id: I3eca9026448e725b9b8d0dae1efca0ad185371da
2014-02-02 19:40:39 +01:00
Thomas Martitz
af02a674c5 talk.c: The new cache management is good enough to use it for .talk clips as well.
This unifies the talk.c for all possible voice payload. .talk clips are placed
onto the same unified clip cache, along with normal clips. This allows for more
effecient memory usage.

The cache handling makes a slight difference between normal clips and .talk
ones: .talk clips can be cached multiple and are always freed first.The extra
logic to avoid loading multiple copies of .talks is not necessary because the
will be freed first anyway.

Change-Id: I88d056a0a613b129f5875f50fdb757b58bac0a42
2014-02-02 19:40:39 +01:00
Thomas Martitz
03f373c9cd talk.c: The new cache management is good enough to use it on all targets.
This unifies the talk.c for all targets. The only separation is left is
TALK_PROGRESSIVE_LOAD: When this is defined the talk buffer will not be
initially prefilled. This is useful for super slow storage or when the buffer
is not large enough to prefill it with useful clips (the prefill code could
be made smarter too).

The buffer size can be adjusted. By default lowmem uses 100k while
other targets load the entire file. The bigger the more clips can be cached
but with diminishing returns.

Change-Id: Ife38fb101c53093117e6638c40c65f7d177a31d4
2014-02-02 19:40:39 +01:00
Thomas Martitz
c46f9be10a talk: Smarter cache management for TALK_PARTIAL_LOAD.
Previously the clip cache of TALK_PARTIAL_LOAD reserved space N clips, each slot
was as big as the maximum sized clip which was necessary to replace clips
in-memory in MRU-style.

The cache management now uses buflib to allocate and free each clip, using the
clip's real size. This allows the clip cache to be much more compact, because
no space is wasted for the max. sized clip. This makes use of buflib's ability
to easily manage differently-sized memory chunks by moving them to make free
space.

As an example: for english.voice TALK_PARTIAL_LOAD allocated 288k in advance.
for just 64 clips. With this patch ~70 clips can be stored in a 100k buffer.
This, the memory usage is cut by 2/3 and almost optimal (there's still the
buflib per-alloc cookie overhead).

As a result the TALK_PARTIAL_LOAD buffer is restricted to 100k which still
allows for more clips than previously, on average.

Change-Id: I257654071e9a95770cd6db2c2765f020befce412
2014-02-02 19:40:39 +01:00
Thomas Martitz
dac40fdd60 talk: Add debug menu entry to view statistics about talk engine.
This engine includes voicefile, memory usage and cache
hits/misses for TALK_PARTIAL_LOAD.

Change-Id: I331981ddda39ea30c57b4b74504accb3c556c3b9
2014-02-02 19:40:39 +01:00
Thomas Martitz
57000b513b talk: Make talk_voice_required() local to talk.c
Change-Id: I3a04760d550efab7f011a917597ef29c039b05bd
2014-02-02 19:40:39 +01:00
Thomas Martitz
60dea95cad talk/hwcodec: Do always free the clip buffer in shrink_callback().
This is necessary because when voice is active audio is disabled. But only
audio was able to shrink it's buffer to let other memory allocs succeed.
talk needs to be able to do this too when it owns the audio buffer exclusively.

Change-Id: Idea8ab90da7169f977c0c766cccb42c4fe6d6e81
2014-02-02 19:40:39 +01:00
Thomas Martitz
efc20ec164 talk: When no voice file is loaded don't even attempt to load the clip, it's hopeless.
Change-Id: I420155d7f01ca0ea301c0678ac7245d251d365b0
2014-01-27 10:05:48 +01:00
Thomas Martitz
543027564c hwcodec/talk.c: Give the thumbnail buffer regardless of the talk buffer policy.
When the policy is not set, it'll by default not give the clip buffer away.
Callers of core_alloc_maximum() suffer from this. However, the thumbnail
buffer can be easily freed when needed because nothing needs to be
reloaded from disk when it is reallocated (thumbnail clips are loaded on
demand, when in the file browser). Do this to give core_alloc_maximum() callers
a better chance to succeed with the default talk buffer policy.

Change-Id: I8c0da29c520612ca903f6c930bd7c74ae97eca3b
2014-01-26 19:14:47 +01:00
Thomas Martitz
5827e41904 hwcodec: core_alloc_maximum() returned 0 bytes if talk.c controls the audio buffer.
On hwcodec talk.c has the entire audio buffer (not just parts of it), therefore
it must give up everything and cannot count on core_alloc_maximum() to return
the remaining space. This is equivalent to it was handled before 22e802e.

You could probaby do smarter and shrink for example the .talk clip buffer
but is it really worth it?

Change-Id: Idc3431c59fb41b05338559c615093358c5d8ed9b
2013-12-24 01:16:10 +01:00
Thomas Martitz
a4d1849e24 Fix yellow.
Change-Id: Ib46e4d0896de4227a508abf5806c00ec3d59db51
2013-12-23 12:54:36 +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
Dominik Riebeling
de6f96229b Add comment to clarify calculation.
Change-Id: Ie0eaa2bb1c672c974246b3e97b5d5f3b9e1f9925
2012-06-05 22:53:21 +02: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
4b97437c23 Correct snafu in talk.c
When allocating the voice buffer, it's supposed to start at the beginning
of the audio buffer, not at the end of the voice buffer. ;-D

Might clear up a thing or two.

Change-Id: I94796ff21090bcc56813cdc569957a1a9178abcd
2012-05-24 20:47:40 -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
Michael Sevakis
d18a5cad7f Tweak paramters of mp3_play_data and callback.
Use generic void * and size_t and make mp3_play_data and its callback
agree on types. Use mp3_play_callback_t instead of prototyping
right in the function call (so it's not so messy to look at). Change
doesn't appear to require plugin API version increment.

Change-Id: Idcab2740ee316a2beb6e0a87b8f4934d9d6b3dd8
2012-03-04 14:50:47 -05: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
Jens Arnold
ae601954aa Make usage of TALK_PARTIAL_LOAD actually Ondio specific. MMC is not always slow.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30917 a1c6a512-1295-4272-9138-f99709370657
2011-11-06 14:25:33 +00:00
Jens Arnold
544fb6a5a4 Voice related fixes and cleaup
* Fix .talk clips on hwcodec. Voice does have the entire audio buffer available there.
* Get rid of the separate TALK_PROGRESSIVE_LOAD in favour of the more advanced
  TALK_PARTIAL_LOAD i.e. use the latter on the Ondios as well. This gets rid of quite
  some ifdefing, and has the advantage that the voice file can be larger than the buffer
  (at a slight binsize cost).


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30916 a1c6a512-1295-4272-9138-f99709370657
2011-11-06 13:58:17 +00:00
Thomas Martitz
79ffd047ff Fix warning and typos.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30912 a1c6a512-1295-4272-9138-f99709370657
2011-11-06 12:07:33 +00:00
Thomas Martitz
7baa450738 Fix broken voice when .talk files are used and voice buffer calculation.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30909 a1c6a512-1295-4272-9138-f99709370657
2011-11-06 12:01:38 +00:00
Thomas Martitz
59dc87db7d Properly initialize variable to get voice going again. GCC didn't catch this one introduced r30840.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30894 a1c6a512-1295-4272-9138-f99709370657
2011-11-03 21:54:26 +00:00
Thomas Martitz
5d5177931e Fix FS#12241. Voice stopped working after audio_get_buffer() calls.
Since r30308 the talk buffer was set to NULL if e.g. a plugin called
audio_get_buffer() to steal the talk buffer. Since there's no audio_release_buffer() kind of function
the talk buffer was never set back again.
When trying to talk try to get the audio buffer with audio_get_buffer() as well,
which works until the audio buffer gets properly reinitialized.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30840 a1c6a512-1295-4272-9138-f99709370657
2011-10-26 18:31:19 +00:00
Bertrik Sikken
57304d1e0c Make a few local functions static
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30744 a1c6a512-1295-4272-9138-f99709370657
2011-10-12 20:47:41 +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 Martitz
fbde6baab5 Move stuff a bit down to fix red on TALK_PARTIAL_LOAD.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30339 a1c6a512-1295-4272-9138-f99709370657
2011-08-22 10:23:11 +00:00
Thomas Martitz
b66d07a9e3 Fix red on hwcodec.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30338 a1c6a512-1295-4272-9138-f99709370657
2011-08-22 09:56:58 +00:00
Thomas Martitz
29abe81889 Talk: Unify hwcodec and swcodec handling.
Do it the hwcodec way which doesn't need a buffer_alloc(). The buffer for the
.talk files is now allocated together with the voicefile buffer.

Should also fix a panic when the .talk file buffer was allocated late at runtime.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30335 a1c6a512-1295-4272-9138-f99709370657
2011-08-21 15:05:57 +00:00
Thomas Martitz
89c8cbebf2 Add change that got lost somehow in r30308.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30312 a1c6a512-1295-4272-9138-f99709370657
2011-08-14 15:51:08 +00:00
Thomas Martitz
b8fabfef84 Fix remaining problems.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30311 a1c6a512-1295-4272-9138-f99709370657
2011-08-14 15:43:43 +00:00
Thomas Martitz
8a701e5488 Fix errors and warnings.
The buffer_offset paramter of audio_init_recording() is removed as it
was unused in both implementations.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30310 a1c6a512-1295-4272-9138-f99709370657
2011-08-14 15:37:05 +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
Andree Buschmann
460d54977a FS#11939: Simplify talk_time_unit().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29347 a1c6a512-1295-4272-9138-f99709370657
2011-02-20 15:23:18 +00:00
Andree Buschmann
e3abdb1a52 Undo unwanted commit r29310.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29311 a1c6a512-1295-4272-9138-f99709370657
2011-02-15 20:10:50 +00:00
Andree Buschmann
237ca504e1 All AAC-HE files will double the frame sample count, not only AAC-HE files with SBR upsampling. This change fixes issues with some m4a files reported in the forums.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29310 a1c6a512-1295-4272-9138-f99709370657
2011-02-15 20:00:28 +00:00
Andree Buschmann
c0b0cd5905 Do not fiddle with audiobuf in talk_init() when no voice file is present. Avoids stopping of audio playback when changing languages without using voice files. Closes FS#10479.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29300 a1c6a512-1295-4272-9138-f99709370657
2011-02-13 21:30:13 +00:00
Andree Buschmann
5d849a963e Clean up multiple definitions of RAM size. Remove -DMEM (make) and MEM (code), use the already defined MEMORYSIZE instead.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29189 a1c6a512-1295-4272-9138-f99709370657
2011-02-02 17:43:32 +00:00
Rafaël Carré
ca91d0fd7a FS#11587 : voice for SWCODEC and low memory
On these targets the full voice file can't be loaded so only load 64
clips at a time (the size of the queue)
Voice now works on clipv1

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27962 a1c6a512-1295-4272-9138-f99709370657
2010-09-01 00:08:50 +00:00
Jeffrey Goode
9e28863669 lang.h voice comments were off by 1, fixed
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26296 a1c6a512-1295-4272-9138-f99709370657
2010-05-26 03:51:13 +00:00
Jeffrey Goode
7c52a17b9f Oops, didnt mean to enable logf in talk.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26295 a1c6a512-1295-4272-9138-f99709370657
2010-05-26 03:14:30 +00:00
Jeffrey Goode
fe0f5baa73 Fix crash in talk.c logf line when outputting voice only clips, more comments in lang.h
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26294 a1c6a512-1295-4272-9138-f99709370657
2010-05-26 03:11:00 +00:00
Rafaël Carré
338e4d76aa fix inverted logic in r26047: voice works again
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26049 a1c6a512-1295-4272-9138-f99709370657
2010-05-15 11:19:25 +00:00
Rafaël Carré
77ec4b301b talk_init() : don't try to load the voice file if it won't fit in memory
now playback still works if voicing is enabled on the clipv1

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26047 a1c6a512-1295-4272-9138-f99709370657
2010-05-15 10:05:47 +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
Jeffrey Goode
433cad6446 Add logf line to talk.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25808 a1c6a512-1295-4272-9138-f99709370657
2010-05-04 14:30:47 +00:00
Bertrik Sikken
2ac91dcd98 Kill some global variables
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24888 a1c6a512-1295-4272-9138-f99709370657
2010-02-24 19:40:45 +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