diff --git a/apps/talk.c b/apps/talk.c index 601b7b4b88..1b2b1e7631 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -634,7 +634,7 @@ int talk_id(int32_t id, bool enqueue) return 0; } /* Speaks zero or more IDs (from an array). */ -int talk_idarray(long *ids, bool enqueue) +int talk_idarray(const long *ids, bool enqueue) { int r; if(!ids) @@ -657,7 +657,8 @@ void talk_force_enqueue_next(void) /* play a thumbnail from file */ /* Returns size of spoken thumbnail, so >0 means something is spoken, <=0 means something went wrong. */ -static int _talk_file(const char* filename, long *prefix_ids, bool enqueue) +static int _talk_file(const char* filename, + const long *prefix_ids, bool enqueue) { int fd; int size; @@ -729,9 +730,8 @@ static int _talk_file(const char* filename, long *prefix_ids, bool enqueue) return size; } -int -talk_file(const char *root, const char *dir, const char *file, - const char *ext, long *prefix_ids, bool enqueue) +int talk_file(const char *root, const char *dir, const char *file, + const char *ext, const long *prefix_ids, bool enqueue) /* Play a thumbnail file */ { char buf[MAX_PATH]; @@ -746,9 +746,8 @@ talk_file(const char *root, const char *dir, const char *file, return _talk_file(buf, prefix_ids, enqueue); } -static int -talk_spell_basename(const char *path, - long *prefix_ids, bool enqueue) +static int talk_spell_basename(const char *path, + const long *prefix_ids, bool enqueue) { if(prefix_ids) { @@ -771,7 +770,7 @@ talk_spell_basename(const char *path, /* Play a file's .talk thumbnail, fallback to spelling the filename, or go straight to spelling depending on settings. */ int talk_file_or_spell(const char *dirname, const char *filename, - long *prefix_ids, bool enqueue) + const long *prefix_ids, bool enqueue) { if (global_settings.talk_file_clip) { /* .talk clips enabled */ @@ -788,7 +787,7 @@ int talk_file_or_spell(const char *dirname, const char *filename, /* Play a directory's .talk thumbnail, fallback to spelling the filename, or go straight to spelling depending on settings. */ int talk_dir_or_spell(const char* dirname, - long *prefix_ids, bool enqueue) + const long *prefix_ids, bool enqueue) { if (global_settings.talk_dir_clip) { /* .talk clips enabled */ @@ -802,33 +801,6 @@ int talk_dir_or_spell(const char* dirname, return 0; } -/* Speak thumbnail for each component of a full path, again falling - back or going straight to spelling depending on settings. */ -int talk_fullpath(const char* path, bool enqueue) -{ - if (!enqueue) - talk_shutup(); - if(path[0] != '/') - /* path ought to start with /... */ - return talk_spell(path, true); - talk_id(VOICE_CHAR_SLASH, true); - char buf[MAX_PATH]; - strncpy(buf, path, MAX_PATH); - char *start = buf+1; /* start of current component */ - char *ptr = strchr(start, '/'); /* end of current component */ - while(ptr) { /* There are more slashes ahead */ - /* temporarily poke a NULL at end of component to truncate string */ - *ptr = '\0'; - talk_dir_or_spell(buf, NULL, true); - *ptr = '/'; /* restore string */ - talk_id(VOICE_CHAR_SLASH, true); - start = ptr+1; /* setup for next component */ - ptr = strchr(start, '/'); - } - /* no more slashes, final component is a filename */ - return talk_file_or_spell(NULL, buf, NULL, true); -} - /* say a numeric value, this word ordering works for english, but not necessarily for other languages (e.g. german) */ int talk_number(long n, bool enqueue) @@ -1099,14 +1071,14 @@ void talk_setting(const void *global_settings_variable) #if CONFIG_RTC -void talk_date(struct tm *tm, bool enqueue) +void talk_date(const struct tm *tm, bool enqueue) { talk_id(LANG_MONTH_JANUARY + tm->tm_mon, enqueue); talk_number(tm->tm_mday, true); talk_number(1900 + tm->tm_year, true); } -void talk_time(struct tm *tm, bool enqueue) +void talk_time(const struct tm *tm, bool enqueue) { if (global_settings.timeformat == 1) { diff --git a/apps/talk.h b/apps/talk.h index b0a26c3053..fc1bfe5a2d 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -86,15 +86,13 @@ bool is_voice_queued(void); /* Are there more voice clips to be spoken? */ int talk_id(int32_t id, bool enqueue); /* play a voice ID from voicefont */ /* play a thumbnail from file */ int talk_file(const char *root, const char *dir, const char *file, - const char *ext, long *prefix_ids, bool enqueue); + const char *ext, const long *prefix_ids, bool enqueue); /* play file's thumbnail or spell name */ int talk_file_or_spell(const char *dirname, const char* filename, - long *prefix_ids, bool enqueue); + const long *prefix_ids, bool enqueue); /* play dir's thumbnail or spell name */ int talk_dir_or_spell(const char* filename, - long *prefix_ids, bool enqueue); -/* play thumbnails for each components of full path, or spell */ -int talk_fullpath(const char* path, bool enqueue); + const long *prefix_ids, bool enqueue); int talk_number(long n, bool enqueue); /* say a number */ int talk_value(long n, int unit, bool enqueue); /* say a numeric value */ int talk_value_decimal(long n, int unit, int decimals, bool enqueue); @@ -108,8 +106,8 @@ void talk_shutup(void); /* Interrupt voice, as when enqueue is false */ void talk_fractional(char *tbuf, int value, int unit); #if CONFIG_RTC -void talk_time(struct tm *tm, bool enqueue); -void talk_date(struct tm *tm, bool enqueue); +void talk_time(const struct tm *tm, bool enqueue); +void talk_date(const struct tm *tm, bool enqueue); #endif /* CONFIG_RTC */ /* This (otherwise invalid) ID signals the end of the array. */ @@ -120,7 +118,7 @@ void talk_date(struct tm *tm, bool enqueue); void talk_force_enqueue_next(void); /* speaks one or more IDs (from an array)). */ -int talk_idarray(long *idarray, bool enqueue); +int talk_idarray(const long *idarray, bool enqueue); /* This makes an initializer for the array of IDs and takes care to put the final sentinel element at the end. */ #define TALK_IDARRAY(ids...) ((long[]){ids,TALK_FINAL_ID})