summaryrefslogtreecommitdiffstats
path: root/apps/voice_thread.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-11-21 03:09:54 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-11-21 03:09:54 +0000
commit72df71a26da8e1d825bac3d70e25032d79ba8057 (patch)
tree525814aae27789ff971b2ee2e0ccded1632f0f81 /apps/voice_thread.c
parente66d60ce63fb8cc548c9f24ecf3afc5a60ccb5b2 (diff)
downloadrockbox-72df71a26da8e1d825bac3d70e25032d79ba8057.tar.gz
rockbox-72df71a26da8e1d825bac3d70e25032d79ba8057.tar.bz2
rockbox-72df71a26da8e1d825bac3d70e25032d79ba8057.zip
speex voice: Detect the end of a clip the right way.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15731 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/voice_thread.c')
-rw-r--r--apps/voice_thread.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index f7494f9587..7ebfb1bcd4 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -313,11 +313,10 @@ static void voice_thread(void)
}
voice_decode:
- /* Check if all data was exhausted for this clip */
- if (speex_bits_remaining(&td.bits) < 8)
+ /* Decode the data */
+ if (speex_decode_int(td.st, &td.bits, voice_output_buf) < 0)
{
- voice_error:
- /* Get next clip */
+ /* End of stream or error - get next clip */
td.vi.size = 0;
if (td.vi.get_more != NULL)
@@ -329,6 +328,8 @@ static void voice_thread(void)
speex_bits_set_bit_buffer(&td.bits, td.vi.start, td.vi.size);
speex_decoder_ctl(td.st, SPEEX_GET_LOOKAHEAD, &td.lookahead);
+ /* Paranoid check - be sure never to somehow get stuck in a
+ * loop without listening to the queue */
yield();
if (!queue_empty(&voice_queue))
@@ -354,13 +355,8 @@ static void voice_thread(void)
goto message_process;
}
- /* Decode the data */
- int status = speex_decode_int(td.st, &td.bits, voice_output_buf);
yield();
- if (status == -2)
- goto voice_error; /* error - try some more */
-
/* Output the decoded frame */
td.count = VOICE_FRAME_SIZE - td.lookahead;
td.src[0] = (const char *)&voice_output_buf[td.lookahead];