path: root/apps/talk.c
diff options
authorThomas Martitz <>2014-01-21 23:22:37 +0100
committerThomas Martitz <>2014-02-02 19:40:39 +0100
commite5eb74592eeff013d818ff0c56692b220dd53fbc (patch)
treee954624b31806dc57f59c8d755d866c6abc9f8f9 /apps/talk.c
parentaf02a674c539ee76260be543c000637ffa6ce2af (diff)
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
Diffstat (limited to 'apps/talk.c')
1 files changed, 11 insertions, 6 deletions
diff --git a/apps/talk.c b/apps/talk.c
index a49de09e84..ab9ca8c495 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -636,11 +636,10 @@ static bool load_voicefile_data(int fd)
return true;
-/* most, if not all, clips should be well below 32k (largest in english.lang is
- * 4.5K). Currently there is a problem with voice decoding such that clips
- * cannot be decoded in chunks. Once that is resolved this buffer could be
- * smaller and clips be decoded in multiple chunks */
-static unsigned char commit_buffer[32<<10];
+/* Use a static buffer to avoid difficulties with buflib during DMA
+ * (hwcodec)/buffer passing to the voice_thread (swcodec). Clips
+ * can be played in chunks so the size is not that important */
+static unsigned char commit_buffer[1<<10];
static void* commit_transfer(struct queue_entry *qe, size_t *size)
@@ -658,7 +657,6 @@ static void* commit_transfer(struct queue_entry *qe, size_t *size)
memcpy(bufpos, buf, sent);
*size = sent;
return commit_buffer;
@@ -674,6 +672,13 @@ static inline bool is_silence(struct queue_entry *qe)
static void mp3_callback(const void** start, size_t* size)
struct queue_entry *qe = &queue[queue_read];
+ /* voice_thread.c hints us how many of the buffer we provided it actually
+ * consumed. Because buffers have to be frame-aligned for speex
+ * it might be less than what we presented */
+ if (*size)
+ sent = *size;
qe->remaining -= sent; /* we completed this */
if (qe->remaining > 0) /* current clip not finished? */