1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2004 Jörg Hohensohn
12 * This module collects the Talkbox and voice UI functions.
13 * (Talkbox reads directory names from mp3 clips called thumbnails,
14 * the voice UI lets menus and screens "talk" from a voicefile in memory.
16 * All files in this archive are subject to the GNU General Public License.
17 * See the file COPYING in the source tree root for full license agreement.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
32 #include "settings_list.h"
33 #include "mp3_playback.h"
41 #if CONFIG_CODEC == SWCODEC
47 /* Memory layout varies between targets because the
48 Archos (MASCODEC) devices cannot mix voice and audio playback
50 MASCODEC | MASCODEC | SWCODEC
51 (playing) | (stopped) |
52 audiobuf-----------+-----------+------------
53 audio | voice | thumbnail
54 |-----------|------------
60 audiobufend----------+-----------+------------
62 SWCODEC allocates dedicated buffers, MASCODEC reuses audiobuf. */
65 /***************** Constants *****************/
67 #define QUEUE_SIZE 64 /* must be a power of two */
68 #define QUEUE_MASK (QUEUE_SIZE-1)
69 const char* const dir_thumbnail_name
= "_dirname.talk";
70 const char* const file_thumbnail_ext
= ".talk";
72 /***************** Functional Macros *****************/
74 #define QUEUE_LEVEL ((queue_write - queue_read) & QUEUE_MASK)
76 #define LOADED_MASK 0x80000000 /* MSB */
78 #if CONFIG_CODEC == SWCODEC
79 #define MAX_THUMBNAIL_BUFSIZE 0x10000
82 /***************** Data types *****************/
84 struct clip_entry
/* one entry of the index table */
86 int offset
; /* offset from start of voicefile file */
87 int size
; /* size of the clip */
90 struct voicefile
/* file format of our voice file */
92 int version
; /* version of the voicefile */
93 int target_id
; /* the rockbox target the file was made for */
94 int table
; /* offset to index table, (=header size) */
95 int id1_max
; /* number of "normal" clips contained in above index */
96 int id2_max
; /* number of "voice only" clips contained in above index */
97 struct clip_entry index
[]; /* followed by the index tables */
98 /* and finally the mp3 clips, not visible here, bitswapped
99 for SH based players */
102 struct queue_entry
/* one entry of the internal queue */
109 /***************** Globals *****************/
111 static unsigned char* p_thumbnail
= NULL
; /* buffer for thumbnail */
112 static long size_for_thumbnail
; /* leftover buffer size for it */
113 static struct voicefile
* p_voicefile
; /* loaded voicefile */
114 static bool has_voicefile
; /* a voicefile file is present */
115 static struct queue_entry queue
[QUEUE_SIZE
]; /* queue of scheduled clips */
116 static bool force_enqueue_next
; /* enqueue next utterance even if enqueue is false */
117 static int queue_write
; /* write index of queue, by application */
118 static int queue_read
; /* read index of queue, by ISR context */
119 static int sent
; /* how many bytes handed over to playback, owned by ISR */
120 static unsigned char curr_hd
[3]; /* current frame header, for re-sync */
121 static int filehandle
= -1; /* global, so the MMC variant can keep the file open */
122 static unsigned char* p_silence
; /* VOICE_PAUSE clip, used for termination */
123 static long silence_len
; /* length of the VOICE_PAUSE clip */
124 static unsigned char* p_lastclip
; /* address of latest clip, for silence add */
125 static unsigned long voicefile_size
= 0; /* size of the loaded voice file */
126 static unsigned char last_lang
[MAX_FILENAME
+1]; /* name of last used lang file (in talk_init) */
127 static bool talk_initialized
; /* true if talk_init has been called */
128 static int talk_temp_disable_count
; /* if positive, temporarily disable voice UI (not saved) */
131 /***************** Private implementation *****************/
133 static int open_voicefile(void)
136 char* p_lang
= "english"; /* default */
138 if ( global_settings
.lang_file
[0] &&
139 global_settings
.lang_file
[0] != 0xff )
140 { /* try to open the voice file of the selected language */
141 p_lang
= (char *)global_settings
.lang_file
;
144 snprintf(buf
, sizeof(buf
), LANG_DIR
"/%s.voice", p_lang
);
146 return open(buf
, O_RDONLY
);
150 /* fetch a clip from the voice file */
151 static unsigned char* get_clip(long id
, long* p_size
)
154 unsigned char* clipbuf
;
156 if (id
> VOICEONLY_DELIMITER
)
157 { /* voice-only entries use the second part of the table */
158 id
-= VOICEONLY_DELIMITER
+ 1;
159 if (id
>= p_voicefile
->id2_max
)
160 return NULL
; /* must be newer than we have */
161 id
+= p_voicefile
->id1_max
; /* table 2 is behind table 1 */
164 { /* normal use of the first table */
165 if (id
>= p_voicefile
->id1_max
)
166 return NULL
; /* must be newer than we have */
169 clipsize
= p_voicefile
->index
[id
].size
;
170 if (clipsize
== 0) /* clip not included in voicefile */
172 clipbuf
= (unsigned char *) p_voicefile
+ p_voicefile
->index
[id
].offset
;
174 #ifdef HAVE_MMC /* dynamic loading, on demand */
175 if (!(clipsize
& LOADED_MASK
))
176 { /* clip used for the first time, needs loading */
177 lseek(filehandle
, p_voicefile
->index
[id
].offset
, SEEK_SET
);
178 if (read(filehandle
, clipbuf
, clipsize
) != clipsize
)
179 return NULL
; /* read error */
181 p_voicefile
->index
[id
].size
|= LOADED_MASK
; /* mark as loaded */
184 { /* clip is in memory already */
185 clipsize
&= ~LOADED_MASK
; /* without the extra bit gives true size */
194 /* load the voice file into the mp3 buffer */
195 static void load_voicefile(void)
200 #ifdef ROCKBOX_LITTLE_ENDIAN
204 filehandle
= open_voicefile();
205 if (filehandle
< 0) /* failed to open */
208 file_size
= filesize(filehandle
);
209 if (file_size
> audiobufend
- audiobuf
) /* won't fit? */
212 #ifdef HAVE_MMC /* load only the header for now */
213 load_size
= offsetof(struct voicefile
, index
);
214 #else /* load the full file */
215 load_size
= file_size
;
218 got_size
= read(filehandle
, audiobuf
, load_size
);
219 if (got_size
!= load_size
/* failure */)
222 #ifdef ROCKBOX_LITTLE_ENDIAN
223 logf("Byte swapping voice file");
224 structec_convert(audiobuf
, "lllll", 1, true);
227 if (((struct voicefile
*)audiobuf
)->table
/* format check */
228 == offsetof(struct voicefile
, index
))
230 p_voicefile
= (struct voicefile
*)audiobuf
;
232 if (p_voicefile
->version
!= VOICE_VERSION
||
233 p_voicefile
->target_id
!= TARGET_ID
)
235 logf("Incompatible voice file");
238 #if CONFIG_CODEC != SWCODEC
239 /* MASCODEC: now use audiobuf for voice then thumbnail */
240 p_thumbnail
= audiobuf
+ file_size
;
241 p_thumbnail
+= (long)p_thumbnail
% 2; /* 16-bit align */
242 size_for_thumbnail
= audiobufend
- p_thumbnail
;
248 #ifdef ROCKBOX_LITTLE_ENDIAN
249 for (i
= 0; i
< p_voicefile
->id1_max
+ p_voicefile
->id2_max
; i
++)
250 structec_convert(&p_voicefile
->index
[i
], "ll", 1, true);
254 /* load the index table, now that we know its size from the header */
255 load_size
= (p_voicefile
->id1_max
+ p_voicefile
->id2_max
)
256 * sizeof(struct clip_entry
);
257 got_size
= read(filehandle
,
258 (unsigned char *) p_voicefile
+ offsetof(struct voicefile
, index
), load_size
);
259 if (got_size
!= load_size
) /* read error */
262 close(filehandle
); /* only the MMC variant leaves it open */
266 /* make sure to have the silence clip, if available */
267 p_silence
= get_clip(VOICE_PAUSE
, &silence_len
);
273 has_voicefile
= false; /* don't try again */
283 /* called in ISR context if mp3 data got consumed */
284 static void mp3_callback(unsigned char** start
, size_t* size
)
286 queue
[queue_read
].len
-= sent
; /* we completed this */
287 queue
[queue_read
].buf
+= sent
;
289 if (queue
[queue_read
].len
> 0) /* current clip not finished? */
290 { /* feed the next 64K-1 chunk */
291 #if CONFIG_CODEC != SWCODEC
292 sent
= MIN(queue
[queue_read
].len
, 0xFFFF);
294 sent
= queue
[queue_read
].len
;
296 *start
= queue
[queue_read
].buf
;
300 else if (sent
> 0) /* go to next entry */
302 queue_read
= (queue_read
+ 1) & QUEUE_MASK
;
307 if (QUEUE_LEVEL
!= 0) /* queue is not empty? */
308 { /* start next clip */
309 #if CONFIG_CODEC != SWCODEC
310 sent
= MIN(queue
[queue_read
].len
, 0xFFFF);
312 sent
= queue
[queue_read
].len
;
314 *start
= p_lastclip
= queue
[queue_read
].buf
;
316 curr_hd
[0] = p_lastclip
[1];
317 curr_hd
[1] = p_lastclip
[2];
318 curr_hd
[2] = p_lastclip
[3];
320 else if (p_silence
!= NULL
/* silence clip available */
321 && p_lastclip
!= p_silence
/* previous clip wasn't silence */
322 && p_lastclip
!= p_thumbnail
) /* ..or thumbnail */
323 { /* add silence clip when queue runs empty playing a voice clip */
324 queue
[queue_write
].buf
= p_silence
;
325 queue
[queue_write
].len
= silence_len
;
326 queue_write
= (queue_write
+ 1) & QUEUE_MASK
;
332 *size
= 0; /* end of data */
336 /***************** Public routines *****************/
338 /* stop the playback and the pending clips */
339 void talk_force_shutup(void)
341 /* Most of this is MAS only */
342 #if CONFIG_CODEC != SWCODEC
347 unsigned char* search
;
349 if (QUEUE_LEVEL
== 0) /* has ended anyway */
352 #if CONFIG_CPU == SH7034
353 CHCR3
&= ~0x0001; /* disable the DMA (and therefore the interrupt also) */
354 #endif /* CONFIG_CPU == SH7034 */
355 /* search next frame boundary and continue up to there */
356 pos
= search
= mp3_get_pos();
357 end
= queue
[queue_read
].buf
+ queue
[queue_read
].len
;
359 if (pos
>= queue
[queue_read
].buf
360 && pos
<= end
) /* really our clip? */
361 { /* (for strange reasons this isn't nesessarily the case) */
362 /* find the next frame boundary */
363 while (search
< end
) /* search the remaining data */
365 if (*search
++ != 0xFF) /* quick search for frame sync byte */
366 continue; /* (this does the majority of the job) */
368 /* look at the (bitswapped) rest of header candidate */
369 if (search
[0] == curr_hd
[0] /* do the quicker checks first */
370 && search
[2] == curr_hd
[2]
371 && (search
[1] & 0x30) == (curr_hd
[1] & 0x30)) /* sample rate */
373 search
--; /* back to the sync byte */
374 break; /* From looking at it, this is our header. */
379 { /* play old data until the frame end, to keep the MAS in sync */
382 queue_write
= (queue_read
+ 1) & QUEUE_MASK
; /* will be empty after next callback */
383 queue
[queue_read
].len
= sent
; /* current one ends after this */
385 #if CONFIG_CPU == SH7034
386 DTCR3
= sent
; /* let the DMA finish this frame */
387 CHCR3
|= 0x0001; /* re-enable DMA */
388 #endif /* CONFIG_CPU == SH7034 */
392 #endif /* CONFIG_CODEC != SWCODEC */
394 /* Either SWCODEC, or MAS had nothing to do (was frame boundary or not our clip) */
396 queue_write
= queue_read
= 0; /* reset the queue */
400 /* Shutup the voice, except if force_enqueue_next is set. */
401 void talk_shutup(void)
403 if (!force_enqueue_next
)
407 /* schedule a clip, at the end or discard the existing queue */
408 static void queue_clip(unsigned char* buf
, long size
, bool enqueue
)
413 talk_shutup(); /* cut off all the pending stuff */
414 /* Something is being enqueued, force_enqueue_next override is no
416 force_enqueue_next
= false;
419 return; /* safety check */
420 #if CONFIG_CPU == SH7034
421 /* disable the DMA temporarily, to be safe of race condition */
424 queue_level
= QUEUE_LEVEL
; /* check old level */
426 if (queue_level
< QUEUE_SIZE
- 1) /* space left? */
428 queue
[queue_write
].buf
= buf
; /* populate an entry */
429 queue
[queue_write
].len
= size
;
430 queue_write
= (queue_write
+ 1) & QUEUE_MASK
;
433 if (queue_level
== 0)
434 { /* queue was empty, we have to do the initial start */
436 #if CONFIG_CODEC != SWCODEC
437 sent
= MIN(size
, 0xFFFF); /* DMA can do no more */
441 mp3_play_data(buf
, sent
, mp3_callback
);
445 mp3_play_pause(true); /* kickoff audio */
449 #if CONFIG_CPU == SH7034
450 CHCR3
|= 0x0001; /* re-enable DMA */
458 /* common code for talk_init() and talk_buffer_steal() */
459 static void reset_state(void)
461 queue_write
= queue_read
= 0; /* reset the queue */
462 p_voicefile
= NULL
; /* indicate no voicefile (trashed) */
463 #if CONFIG_CODEC == SWCODEC
464 /* Allocate a dedicated thumbnail buffer - once */
465 if (p_thumbnail
== NULL
)
467 size_for_thumbnail
= audiobufend
- audiobuf
;
468 if (size_for_thumbnail
> MAX_THUMBNAIL_BUFSIZE
)
469 size_for_thumbnail
= MAX_THUMBNAIL_BUFSIZE
;
470 p_thumbnail
= buffer_alloc(size_for_thumbnail
);
473 /* Just use the audiobuf, without allocating anything */
474 p_thumbnail
= audiobuf
;
475 size_for_thumbnail
= audiobufend
- audiobuf
;
477 p_silence
= NULL
; /* pause clip not accessible */
481 /***************** Public implementation *****************/
485 talk_temp_disable_count
= 0;
486 if (talk_initialized
&& !strcasecmp(last_lang
, global_settings
.lang_file
))
488 /* not a new file, nothing to do */
493 if (filehandle
>= 0) /* MMC: An old voice file might still be open */
500 talk_initialized
= true;
501 strncpy((char *) last_lang
, (char *)global_settings
.lang_file
,
504 #if CONFIG_CODEC == SWCODEC
505 audio_get_buffer(false, NULL
); /* Must tell audio to reinitialize */
507 reset_state(); /* use this for most of our inits */
509 filehandle
= open_voicefile();
510 has_voicefile
= (filehandle
>= 0); /* test if we can open it */
515 voicefile_size
= filesize(filehandle
);
516 close(filehandle
); /* close again, this was just to detect presence */
522 #if CONFIG_CODEC == SWCODEC
523 /* return if a voice codec is required or not */
524 bool talk_voice_required(void)
526 return (voicefile_size
!= 0) /* Voice file is available */
527 || (global_settings
.talk_dir_clip
) /* Thumbnail clips are required */
528 || (global_settings
.talk_file_clip
);
532 /* return size of voice file */
533 int talk_get_bufsize(void)
535 return voicefile_size
;
538 /* somebody else claims the mp3 buffer, e.g. for regular play/record */
539 void talk_buffer_steal(void)
541 #if CONFIG_CODEC != SWCODEC
545 if (filehandle
>= 0) /* only relevant for MMC */
555 /* play a voice ID from voicefile */
556 int talk_id(int32_t id
, bool enqueue
)
559 unsigned char* clipbuf
;
563 if (talk_temp_disable_count
> 0)
564 return -1; /* talking has been disabled */
565 #if CONFIG_CODEC != SWCODEC
566 if (audio_status()) /* busy, buffer in use */
570 if (p_voicefile
== NULL
&& has_voicefile
)
571 load_voicefile(); /* reload needed */
573 if (p_voicefile
== NULL
) /* still no voices? */
576 if (id
== -1) /* -1 is an indication for silence */
579 decimals
= (((uint32_t)id
) >> DECIMAL_SHIFT
) & 0x7;
581 /* check if this is a special ID, with a value */
582 unit
= ((uint32_t)id
) >> UNIT_SHIFT
;
583 if (unit
|| decimals
)
584 { /* sign-extend the value */
585 id
= (uint32_t)id
<< (32-DECIMAL_SHIFT
);
586 id
>>= (32-DECIMAL_SHIFT
);
588 talk_value_decimal(id
, unit
, decimals
, enqueue
); /* speak it */
589 return 0; /* and stop, end of special case */
592 clipbuf
= get_clip(id
, &clipsize
);
594 return -1; /* not present */
596 queue_clip(clipbuf
, clipsize
, enqueue
);
600 /* Speaks zero or more IDs (from an array). */
601 int talk_idarray(long *ids
, bool enqueue
)
606 while(*ids
!= TALK_FINAL_ID
)
608 if((r
= talk_id(*ids
++, enqueue
)) <0)
615 /* Make sure the current utterance is not interrupted by the next one. */
616 void talk_force_enqueue_next(void)
618 force_enqueue_next
= true;
621 /* play a thumbnail from file */
622 int talk_file(const char* filename
, bool enqueue
)
626 #if CONFIG_CODEC != SWCODEC
627 struct mp3entry info
;
630 if (talk_temp_disable_count
> 0)
631 return -1; /* talking has been disabled */
632 #if CONFIG_CODEC != SWCODEC
633 if (audio_status()) /* busy, buffer in use */
637 if (p_thumbnail
== NULL
|| size_for_thumbnail
<= 0)
640 #if CONFIG_CODEC != SWCODEC
641 if(mp3info(&info
, filename
)) /* use this to find real start */
643 return 0; /* failed to open, or invalid */
647 fd
= open(filename
, O_RDONLY
);
648 if (fd
< 0) /* failed to open */
653 #if CONFIG_CODEC != SWCODEC
654 lseek(fd
, info
.first_frame_offset
, SEEK_SET
); /* behind ID data */
657 size
= read(fd
, p_thumbnail
, size_for_thumbnail
);
660 /* ToDo: find audio, skip ID headers and trailers */
662 if (size
> 0 && size
!= size_for_thumbnail
) /* Don't play missing or truncated clips */
664 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
665 bitswap(p_thumbnail
, size
);
667 queue_clip(p_thumbnail
, size
, enqueue
);
674 /* say a numeric value, this word ordering works for english,
675 but not necessarily for other languages (e.g. german) */
676 int talk_number(long n
, bool enqueue
)
678 int level
= 2; /* mille count */
679 long mil
= 1000000000; /* highest possible "-illion" */
681 if (talk_temp_disable_count
> 0)
682 return -1; /* talking has been disabled */
683 #if CONFIG_CODEC != SWCODEC
684 if (audio_status()) /* busy, buffer in use */
689 talk_shutup(); /* cut off all the pending stuff */
693 talk_id(VOICE_ZERO
, true);
699 talk_id(VOICE_MINUS
, true);
705 int segment
= n
/ mil
; /* extract in groups of 3 digits */
706 n
-= segment
* mil
; /* remove the used digits from number */
707 mil
/= 1000; /* digit place for next round */
711 int hundreds
= segment
/ 100;
712 int ones
= segment
% 100;
716 talk_id(VOICE_ZERO
+ hundreds
, true);
717 talk_id(VOICE_HUNDRED
, true);
720 /* combination indexing */
723 int tens
= ones
/10 + 18;
724 talk_id(VOICE_ZERO
+ tens
, true);
728 /* direct indexing */
730 talk_id(VOICE_ZERO
+ ones
, true);
732 /* add billion, million, thousand */
734 talk_id(VOICE_THOUSAND
+ level
, true);
742 /* Say time duration/interval. Input is time in seconds,
743 say hours,minutes,seconds. */
744 static int talk_time_unit(long secs
, bool exact
, bool enqueue
)
749 if((hours
= secs
/3600)) {
751 talk_value(hours
, UNIT_HOUR
, true);
753 if((mins
= secs
/60)) {
756 talk_value(mins
, UNIT_MIN
, true);
757 else talk_number(mins
, true); /* don't say "minutes" */
759 if((exact
&& secs
) || (!hours
&& !mins
))
760 talk_value(secs
, UNIT_SEC
, true);
761 else if(!hours
&& secs
)
762 talk_number(secs
, true);
766 void talk_fractional(char *tbuf
, int value
, int unit
)
769 /* strip trailing zeros from the fraction */
770 for (i
= strlen(tbuf
) - 1; (i
>= 0) && (tbuf
[i
] == '0'); i
--)
773 talk_number(value
, true);
776 talk_id(LANG_POINT
, true);
777 talk_spell(tbuf
, true);
782 int talk_value(long n
, int unit
, bool enqueue
)
784 return talk_value_decimal(n
, unit
, 0, enqueue
);
787 /* singular/plural aware saying of a value */
788 int talk_value_decimal(long n
, int unit
, int decimals
, bool enqueue
)
791 static const int unit_voiced
[] =
792 { /* lookup table for the voice ID of the units */
793 [0 ... UNIT_LAST
-1] = -1, /* regular ID, int, signed */
795 = VOICE_MILLISECONDS
, /* here come the "real" units */
809 = VOICE_MILLIAMPHOURS
,
819 = VOICE_KBIT_PER_SEC
,
821 = VOICE_PM_UNITS_PER_TICK
,
824 static const int pow10
[] = { /* 10^0 - 10^7 */
825 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000
831 if (talk_temp_disable_count
> 0)
832 return -1; /* talking has been disabled */
833 #if CONFIG_CODEC != SWCODEC
834 if (audio_status()) /* busy, buffer in use */
838 /* special case for time duration */
839 if (unit
== UNIT_TIME
|| unit
== UNIT_TIME_EXACT
)
840 return talk_time_unit(n
, unit
== UNIT_TIME_EXACT
, enqueue
);
842 if (unit
< 0 || unit
>= UNIT_LAST
)
845 unit_id
= unit_voiced
[unit
];
847 if ((n
==1 || n
==-1) /* singular? */
848 && unit_id
>= VOICE_SECONDS
&& unit_id
<= VOICE_HOURS
)
850 unit_id
--; /* use the singular for those units which have */
853 /* special case with a "plus" before */
854 if (n
> 0 && (unit
== UNIT_SIGNED
|| unit
== UNIT_DB
))
856 talk_id(VOICE_PLUS
, enqueue
);
862 /* needed for the "-0.5" corner case */
865 talk_id(VOICE_MINUS
, enqueue
);
869 fmt
[2] = '0' + decimals
;
871 snprintf(tbuf
, sizeof(tbuf
), fmt
, n
% pow10
[decimals
]);
872 talk_fractional(tbuf
, n
/ pow10
[decimals
], unit_id
);
877 talk_number(n
, enqueue
); /* say the number */
878 talk_id(unit_id
, true); /* say the unit, if any */
884 int talk_spell(const char* spell
, bool enqueue
)
886 char c
; /* currently processed char */
888 if (talk_temp_disable_count
> 0)
889 return -1; /* talking has been disabled */
890 #if CONFIG_CODEC != SWCODEC
891 if (audio_status()) /* busy, buffer in use */
896 talk_shutup(); /* cut off all the pending stuff */
898 while ((c
= *spell
++) != '\0')
900 /* if this grows into too many cases, I should use a table */
901 if (c
>= 'A' && c
<= 'Z')
902 talk_id(VOICE_CHAR_A
+ c
- 'A', true);
903 else if (c
>= 'a' && c
<= 'z')
904 talk_id(VOICE_CHAR_A
+ c
- 'a', true);
905 else if (c
>= '0' && c
<= '9')
906 talk_id(VOICE_ZERO
+ c
- '0', true);
908 talk_id(VOICE_MINUS
, true);
910 talk_id(VOICE_PLUS
, true);
912 talk_id(VOICE_DOT
, true);
914 talk_id(VOICE_PAUSE
, true);
920 void talk_disable(bool disable
)
923 talk_temp_disable_count
++;
925 talk_temp_disable_count
--;
928 void talk_setting(const void *global_settings_variable
)
930 const struct settings_list
*setting
;
931 if (!global_settings
.talk_menu
)
933 setting
= find_setting(global_settings_variable
, NULL
);
936 if (setting
->lang_id
)
937 talk_id(setting
->lang_id
,false);
942 void talk_date(struct tm
*tm
, bool enqueue
)
944 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, enqueue
);
945 talk_number(tm
->tm_mday
, true);
946 talk_number(1900 + tm
->tm_year
, true);
949 void talk_time(struct tm
*tm
, bool enqueue
)
951 if (global_settings
.timeformat
== 1)
954 long am_pm_id
= VOICE_AM
;
955 int hour
= tm
->tm_hour
;
963 talk_number(hour
, enqueue
);
965 /* Voice the minutes */
968 /* Say o'clock if the minute is 0. */
969 talk_id(VOICE_OCLOCK
, true);
973 /* Pronounce the leading 0 */
975 talk_id(VOICE_OH
, true);
976 talk_number(tm
->tm_min
, true);
978 talk_id(am_pm_id
, true);
982 /* Voice the time in 24 hour format */
983 talk_number(tm
->tm_hour
, enqueue
);
986 talk_id(VOICE_HUNDRED
, true);
987 talk_id(VOICE_HOUR
, true);
991 /* Pronounce the leading 0 */
993 talk_id(VOICE_OH
, true);
994 talk_number(tm
->tm_min
, true);