summaryrefslogtreecommitdiff
path: root/apps/talk.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/talk.c')
-rw-r--r--apps/talk.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 9c53bb6da5..b561d5cde8 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -131,6 +131,7 @@ static bool need_shutup; /* is there possibly any voice playing to be shutup */
131static bool force_enqueue_next; /* enqueue next utterance even if enqueue is false */ 131static bool force_enqueue_next; /* enqueue next utterance even if enqueue is false */
132static int queue_write; /* write index of queue, by application */ 132static int queue_write; /* write index of queue, by application */
133static int queue_read; /* read index of queue, by ISR context */ 133static int queue_read; /* read index of queue, by ISR context */
134static enum talk_status talk_status = TALK_STATUS_OK;
134#if CONFIG_CODEC == SWCODEC 135#if CONFIG_CODEC == SWCODEC
135/* protects queue_read, queue_write and thumbnail_buf_used */ 136/* protects queue_read, queue_write and thumbnail_buf_used */
136static struct mutex queue_mutex SHAREDBSS_ATTR; 137static struct mutex queue_mutex SHAREDBSS_ATTR;
@@ -595,6 +596,7 @@ static bool create_clip_buffer(size_t max_size)
595 return true; 596 return true;
596 597
597alloc_err: 598alloc_err:
599 talk_status = TALK_STATUS_ERR_ALLOC;
598 index_handle = core_free(index_handle); 600 index_handle = core_free(index_handle);
599 return false; 601 return false;
600} 602}
@@ -603,11 +605,17 @@ alloc_err:
603static bool load_voicefile_index(int fd) 605static bool load_voicefile_index(int fd)
604{ 606{
605 if (fd < 0) /* failed to open */ 607 if (fd < 0) /* failed to open */
608 {
609 talk_status = TALK_STATUS_ERR_NOFILE;
606 return false; 610 return false;
611 }
607 612
608 /* load the header first */ 613 /* load the header first */
609 if (!load_header(fd, &voicefile)) 614 if (!load_header(fd, &voicefile))
615 {
616 talk_status = TALK_STATUS_ERR_INCOMPATIBLE;
610 return false; 617 return false;
618 }
611 619
612 /* format check */ 620 /* format check */
613 if (voicefile.table == sizeof(struct voicefile_header)) 621 if (voicefile.table == sizeof(struct voicefile_header))
@@ -622,6 +630,7 @@ static bool load_voicefile_index(int fd)
622 } 630 }
623 } 631 }
624 632
633 talk_status = TALK_STATUS_ERR_INCOMPATIBLE;
625 logf("Incompatible voice file"); 634 logf("Incompatible voice file");
626 logf("version %d expected %d", voicefile.version, VOICE_VERSION); 635 logf("version %d expected %d", voicefile.version, VOICE_VERSION);
627 logf("target_id %d expected %d", voicefile.target_id, TARGET_ID); 636 logf("target_id %d expected %d", voicefile.target_id, TARGET_ID);
@@ -648,6 +657,7 @@ static bool load_voicefile_data(int fd)
648 if (UNLIKELY(cap < 0)) 657 if (UNLIKELY(cap < 0))
649 { 658 {
650 logf("Not enough memory for voice. Disabling...\n"); 659 logf("Not enough memory for voice. Disabling...\n");
660 talk_status = TALK_STATUS_ERR_OOM;
651 return false; 661 return false;
652 } 662 }
653 else if (voicebuf_size > (size_t)cap) 663 else if (voicebuf_size > (size_t)cap)
@@ -1629,17 +1639,25 @@ bool talk_get_debug_data(struct talk_debug_data *data)
1629 1639
1630 memset(data, 0, sizeof(*data)); 1640 memset(data, 0, sizeof(*data));
1631 1641
1632 if (!has_voicefile || index_handle <= 0) 1642 data->status = talk_status;
1633 return false;
1634 1643
1635 if (global_settings.lang_file[0] && global_settings.lang_file[0] != 0xff) 1644 if (global_settings.lang_file[0] && global_settings.lang_file[0] != 0xff)
1636 p_lang = (char *)global_settings.lang_file; 1645 p_lang = (char *)global_settings.lang_file;
1637 1646
1647 strlcpy(data->voicefile, p_lang, sizeof(data->voicefile));
1648
1649 if (!has_voicefile || index_handle <= 0)
1650 {
1651 if (data->status == TALK_STATUS_OK)
1652 data->status = TALK_STATUS_ERR_NOFILE;
1653
1654 return false;
1655 }
1656
1638 struct clip_entry *clips = core_get_data(index_handle); 1657 struct clip_entry *clips = core_get_data(index_handle);
1639 int cached = 0; 1658 int cached = 0;
1640 int real_clips = 0; 1659 int real_clips = 0;
1641 1660
1642 strlcpy(data->voicefile, p_lang, sizeof(data->voicefile));
1643 data->num_clips = voicefile.id1_max + voicefile.id2_max; 1661 data->num_clips = voicefile.id1_max + voicefile.id2_max;
1644 data->avg_clipsize = data->max_clipsize = 0; 1662 data->avg_clipsize = data->max_clipsize = 0;
1645 data->min_clipsize = INT_MAX; 1663 data->min_clipsize = INT_MAX;