diff options
author | William Wilgus <me.theuser@yahoo.com> | 2020-05-21 12:55:32 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2020-05-22 06:35:22 -0500 |
commit | 74f358cf8b909aab5d1b9a157765ef6dcd8fe9dc (patch) | |
tree | b23f607f4141bbd49a3537fe03d97fdd92110dd0 /apps/talk.c | |
parent | bbe8c73bb8c036e33e1f5e30af4a392f11bd0f25 (diff) | |
download | rockbox-74f358cf8b909aab5d1b9a157765ef6dcd8fe9dc.tar.gz rockbox-74f358cf8b909aab5d1b9a157765ef6dcd8fe9dc.zip |
talk.h add init status to debug menu
g#2272 adds checks for incompatible version & proper number of clips
Currently incompatible talk files will logf when failure to load occurs
Adds a message to Debug > Talk engine stats
'Talk Status: OK'
'Talk Status: ERR Incompatible voice file'
'Talk Status: ERR (#)' -- OOM, Alloc Error
Change-Id: Ifd2c1f38f710541c9cd929b8abf67bba4363ca53
Diffstat (limited to 'apps/talk.c')
-rw-r--r-- | apps/talk.c | 24 |
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 */ | |||
131 | static bool force_enqueue_next; /* enqueue next utterance even if enqueue is false */ | 131 | static bool force_enqueue_next; /* enqueue next utterance even if enqueue is false */ |
132 | static int queue_write; /* write index of queue, by application */ | 132 | static int queue_write; /* write index of queue, by application */ |
133 | static int queue_read; /* read index of queue, by ISR context */ | 133 | static int queue_read; /* read index of queue, by ISR context */ |
134 | static 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 */ |
136 | static struct mutex queue_mutex SHAREDBSS_ATTR; | 137 | static 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 | ||
597 | alloc_err: | 598 | alloc_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: | |||
603 | static bool load_voicefile_index(int fd) | 605 | static 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; |