diff options
author | Thomas Martitz <kugel@rockbox.org> | 2013-05-30 11:24:16 +0200 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2013-12-23 12:17:38 +0100 |
commit | 22e802e80048defd401462e062afcb10093ac793 (patch) | |
tree | 09d24f7eb2a3b18e6563e838398b2715394f7c4c /apps/talk.h | |
parent | 64b9e1fa7b645daa36ca0018dc168d4f871fd538 (diff) |
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
Diffstat (limited to 'apps/talk.h')
-rw-r--r-- | apps/talk.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/talk.h b/apps/talk.h index 55e7208f1d..28be71884f 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -71,6 +71,26 @@ enum { /* convenience macro to have both virtual pointer and ID as arguments */ #define STR(id) ID2P(id), id +/* Policy values for how hard to try to keep the talk/voice buffers. + * Affects how genereous talk.c is when it's asked for memory in + * shrink_callbacks(). + * + * I.e. setting the policy to TALK_BUFFER_LOOSE, it will happily give its + * entire bufer away if asked for, e.g. due to a another module + * calling core_alloc_maximum(), TALK_BUFFER_HOLD on the other hand will + * make it keep the buffers so that a call to core_alloc_maximum() does not + * stop the speech-interface. + */ +enum talk_buffer_policies { + TALK_BUFFER_DEFAULT, + TALK_BUFFER_LOOSE, + TALK_BUFFER_HOLD, +}; + +/* This sets the actual policy. Call this before core_alloc_maximum() to + * get the desired outcome */ +void talk_buffer_set_policy(int policy); + /* publish these strings, so they're stored only once (better than #define) */ extern const char* const dir_thumbnail_name; /* "_dirname.talk" */ extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */ @@ -81,7 +101,6 @@ bool talk_voice_required(void); /* returns true if voice codec required */ #endif int talk_get_bufsize(void); /* get the loaded voice file size */ size_t talkbuf_init(char* bufstart); -void talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */ bool is_voice_queued(void); /* Are there more voice clips to be spoken? */ int talk_id(int32_t id, bool enqueue); /* play a voice ID from voicefont */ /* play a thumbnail from file */ |