summaryrefslogtreecommitdiffstats
path: root/apps/voice_thread.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-09-20 13:29:02 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-09-20 16:08:49 -0400
commit2ffe87902dc72b4c26032c94e8250ff92d2888dc (patch)
tree9a6cf73d37a5a5e3f93813b44720c1bd5604ddd9 /apps/voice_thread.c
parentc528c01312d85e2d177bcc05ce82a29c97b803cc (diff)
downloadrockbox-2ffe87902dc72b4c26032c94e8250ff92d2888dc.tar.gz
rockbox-2ffe87902dc72b4c26032c94e8250ff92d2888dc.tar.bz2
rockbox-2ffe87902dc72b4c26032c94e8250ff92d2888dc.zip
Add Invalid Voice Announcement to the voice system FS#13216
When a voice file is invalid or fails to load the voice system splash a message 'Invalid Voice' Now we supply a single voice file (currently only english is used) the support for other languages is in but I haven't set it up to look for anything but InvalidVoice_english.talk Also adds a one time kill voice thread function ie. it doesn't allow re-init after killing the voice thread & queue Change-Id: I7b43f340c3cc65c65110190f0e0075b31218a7ac
Diffstat (limited to 'apps/voice_thread.c')
-rw-r--r--apps/voice_thread.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index 171902d10f..08c7fd6b0b 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -106,6 +106,7 @@ enum voice_state
VOICE_STATE_MESSAGE = 0,
VOICE_STATE_DECODE,
VOICE_STATE_BUFFER_INSERT,
+ VOICE_STATE_QUIT,
};
/* A delay to not bring audio back to normal level too soon */
@@ -115,6 +116,7 @@ enum voice_thread_messages
{
Q_VOICE_PLAY = 0, /* Play a clip */
Q_VOICE_STOP, /* Stop current clip */
+ Q_VOICE_KILL, /* Kill voice thread till restart*/
};
/* Structure to store clip data callback info */
@@ -383,7 +385,9 @@ static enum voice_state voice_message(struct voice_thread_data *td)
speex_decoder_ctl(td->st, SPEEX_GET_LOOKAHEAD, &td->lookahead);
return VOICE_STATE_DECODE;
-
+ case Q_VOICE_KILL:
+ queue_delete(&voice_queue);
+ return VOICE_STATE_QUIT;
case SYS_TIMEOUT:
if (voice_unplayed_frames())
{
@@ -512,7 +516,7 @@ static enum voice_state voice_buffer_insert(struct voice_thread_data *td)
}
/* Voice thread entrypoint */
-static void NORETURN_ATTR voice_thread(void)
+static void voice_thread(void)
{
struct voice_thread_data td;
enum voice_state state = VOICE_STATE_MESSAGE;
@@ -532,8 +536,20 @@ static void NORETURN_ATTR voice_thread(void)
case VOICE_STATE_BUFFER_INSERT:
state = voice_buffer_insert(&td);
break;
+ case VOICE_STATE_QUIT:
+ logf("Exiting voice thread");
+ core_free(voice_buf_hid);
+ voice_buf_hid = 0;
+ return;
}
}
+ return;
+}
+
+/* kill voice thread and dont allow re-init*/
+void voice_thread_kill(void)
+{
+ queue_send(&voice_queue, Q_VOICE_KILL, 0);
}
/* Initialize buffers, all synchronization objects and create the thread */