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 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
24 ****************************************************************************/
34 #include "settings_list.h"
35 #include "mp3_playback.h"
43 #if CONFIG_CODEC == SWCODEC
49 /* Memory layout varies between targets because the
50 Archos (MASCODEC) devices cannot mix voice and audio playback
52 MASCODEC | MASCODEC | SWCODEC
53 (playing) | (stopped) |
54 audiobuf-----------+-----------+------------
55 audio | voice | thumbnail
56 |-----------|------------
62 audiobufend----------+-----------+------------
64 SWCODEC allocates dedicated buffers, MASCODEC reuses audiobuf. */
67 /***************** Constants *****************/
69 #define QUEUE_SIZE 64 /* must be a power of two */
70 #define QUEUE_MASK (QUEUE_SIZE-1)
71 const char* const dir_thumbnail_name
= "_dirname.talk";
72 const char* const file_thumbnail_ext
= ".talk";
74 /***************** Functional Macros *****************/
76 #define QUEUE_LEVEL ((queue_write - queue_read) & QUEUE_MASK)
78 #define LOADED_MASK 0x80000000 /* MSB */
80 #if CONFIG_CODEC == SWCODEC
81 #define MAX_THUMBNAIL_BUFSIZE 0x10000
84 /***************** Data types *****************/
86 struct clip_entry
/* one entry of the index table */
88 int offset
; /* offset from start of voicefile file */
89 int size
; /* size of the clip */
92 struct voicefile
/* file format of our voice file */
94 int version
; /* version of the voicefile */
95 int target_id
; /* the rockbox target the file was made for */
96 int table
; /* offset to index table, (=header size) */
97 int id1_max
; /* number of "normal" clips contained in above index */
98 int id2_max
; /* number of "voice only" clips contained in above index */
99 struct clip_entry index
[]; /* followed by the index tables */
100 /* and finally the mp3 clips, not visible here, bitswapped
101 for SH based players */
104 struct queue_entry
/* one entry of the internal queue */
111 /***************** Globals *****************/
113 static unsigned char* p_thumbnail
= NULL
; /* buffer for thumbnail */
114 static long size_for_thumbnail
; /* leftover buffer size for it */
115 static struct voicefile
* p_voicefile
; /* loaded voicefile */
116 static bool has_voicefile
; /* a voicefile file is present */
117 static struct queue_entry queue
[QUEUE_SIZE
]; /* queue of scheduled clips */
118 static bool force_enqueue_next
; /* enqueue next utterance even if enqueue is false */
119 static int queue_write
; /* write index of queue, by application */
120 static int queue_read
; /* read index of queue, by ISR context */
121 static int sent
; /* how many bytes handed over to playback, owned by ISR */
122 static unsigned char curr_hd
[3]; /* current frame header, for re-sync */
123 static int filehandle
= -1; /* global, so the MMC variant can keep the file open */
124 static unsigned char* p_silence
; /* VOICE_PAUSE clip, used for termination */
125 static long silence_len
; /* length of the VOICE_PAUSE clip */
126 static unsigned char* p_lastclip
; /* address of latest clip, for silence add */
127 static unsigned long voicefile_size
= 0; /* size of the loaded voice file */
128 static unsigned char last_lang
[MAX_FILENAME
+1]; /* name of last used lang file (in talk_init) */
129 static bool talk_initialized
; /* true if talk_init has been called */
130 static int talk_temp_disable_count
; /* if positive, temporarily disable voice UI (not saved) */
133 /***************** Private implementation *****************/
135 static int open_voicefile(void)
138 char* p_lang
= "english"; /* default */
140 if ( global_settings
.lang_file
[0] &&
141 global_settings
.lang_file
[0] != 0xff )
142 { /* try to open the voice file of the selected language */
143 p_lang
= (char *)global_settings
.lang_file
;
146 snprintf(buf
, sizeof(buf
), LANG_DIR
"/%s.voice", p_lang
);
148 return open(buf
, O_RDONLY
);
152 /* fetch a clip from the voice file */
153 static unsigned char* get_clip(long id
, long* p_size
)
156 unsigned char* clipbuf
;
158 if (id
> VOICEONLY_DELIMITER
)
159 { /* voice-only entries use the second part of the table */
160 id
-= VOICEONLY_DELIMITER
+ 1;
161 if (id
>= p_voicefile
->id2_max
)
162 return NULL
; /* must be newer than we have */
163 id
+= p_voicefile
->id1_max
; /* table 2 is behind table 1 */
166 { /* normal use of the first table */
167 if (id
>= p_voicefile
->id1_max
)
168 return NULL
; /* must be newer than we have */
171 clipsize
= p_voicefile
->index
[id
].size
;
172 if (clipsize
== 0) /* clip not included in voicefile */
174 clipbuf
= (unsigned char *) p_voicefile
+ p_voicefile
->index
[id
].offset
;
176 #ifdef HAVE_MMC /* dynamic loading, on demand */
177 if (!(clipsize
& LOADED_MASK
))
178 { /* clip used for the first time, needs loading */
179 lseek(filehandle
, p_voicefile
->index
[id
].offset
, SEEK_SET
);
180 if (read(filehandle
, clipbuf
, clipsize
) != clipsize
)
181 return NULL
; /* read error */
183 p_voicefile
->index
[id
].size
|= LOADED_MASK
; /* mark as loaded */
186 { /* clip is in memory already */
187 clipsize
&= ~LOADED_MASK
; /* without the extra bit gives true size */
196 /* load the voice file into the mp3 buffer */
197 static void load_voicefile(void)
202 #ifdef ROCKBOX_LITTLE_ENDIAN
206 filehandle
= open_voicefile();
207 if (filehandle
< 0) /* failed to open */
210 file_size
= filesize(filehandle
);
211 if (file_size
> audiobufend
- audiobuf
) /* won't fit? */
214 #ifdef HAVE_MMC /* load only the header for now */
215 load_size
= offsetof(struct voicefile
, index
);
216 #else /* load the full file */
217 load_size
= file_size
;
220 got_size
= read(filehandle
, audiobuf
, load_size
);
221 if (got_size
!= load_size
/* failure */)
224 #ifdef ROCKBOX_LITTLE_ENDIAN
225 logf("Byte swapping voice file");
226 structec_convert(audiobuf
, "lllll", 1, true);
229 if (((struct voicefile
*)audiobuf
)->table
/* format check */
230 == offsetof(struct voicefile
, index
))
232 p_voicefile
= (struct voicefile
*)audiobuf
;
234 if (p_voicefile
->version
!= VOICE_VERSION
||
235 p_voicefile
->target_id
!= TARGET_ID
)
237 logf("Incompatible voice file");
240 #if CONFIG_CODEC != SWCODEC
241 /* MASCODEC: now use audiobuf for voice then thumbnail */
242 p_thumbnail
= audiobuf
+ file_size
;
243 p_thumbnail
+= (long)p_thumbnail
% 2; /* 16-bit align */
244 size_for_thumbnail
= audiobufend
- p_thumbnail
;
250 #ifdef ROCKBOX_LITTLE_ENDIAN
251 for (i
= 0; i
< p_voicefile
->id1_max
+ p_voicefile
->id2_max
; i
++)
252 structec_convert(&p_voicefile
->index
[i
], "ll", 1, true);
256 /* load the index table, now that we know its size from the header */
257 load_size
= (p_voicefile
->id1_max
+ p_voicefile
->id2_max
)
258 * sizeof(struct clip_entry
);
259 got_size
= read(filehandle
,
260 (unsigned char *) p_voicefile
+ offsetof(struct voicefile
, index
), load_size
);
261 if (got_size
!= load_size
) /* read error */
264 close(filehandle
); /* only the MMC variant leaves it open */
268 /* make sure to have the silence clip, if available */
269 p_silence
= get_clip(VOICE_PAUSE
, &silence_len
);
275 has_voicefile
= false; /* don't try again */
285 /* called in ISR context if mp3 data got consumed */
286 static void mp3_callback(unsigned char** start
, size_t* size
)
288 queue
[queue_read
].len
-= sent
; /* we completed this */
289 queue
[queue_read
].buf
+= sent
;
291 if (queue
[queue_read
].len
> 0) /* current clip not finished? */
292 { /* feed the next 64K-1 chunk */
293 #if CONFIG_CODEC != SWCODEC
294 sent
= MIN(queue
[queue_read
].len
, 0xFFFF);
296 sent
= queue
[queue_read
].len
;
298 *start
= queue
[queue_read
].buf
;
302 else if (sent
> 0) /* go to next entry */
304 queue_read
= (queue_read
+ 1) & QUEUE_MASK
;
309 if (QUEUE_LEVEL
!= 0) /* queue is not empty? */
310 { /* start next clip */
311 #if CONFIG_CODEC != SWCODEC
312 sent
= MIN(queue
[queue_read
].len
, 0xFFFF);
314 sent
= queue
[queue_read
].len
;
316 *start
= p_lastclip
= queue
[queue_read
].buf
;
318 curr_hd
[0] = p_lastclip
[1];
319 curr_hd
[1] = p_lastclip
[2];
320 curr_hd
[2] = p_lastclip
[3];
322 else if (p_silence
!= NULL
/* silence clip available */
323 && p_lastclip
!= p_silence
/* previous clip wasn't silence */
324 && p_lastclip
!= p_thumbnail
) /* ..or thumbnail */
325 { /* add silence clip when queue runs empty playing a voice clip */
326 queue
[queue_write
].buf
= p_silence
;
327 queue
[queue_write
].len
= silence_len
;
328 queue_write
= (queue_write
+ 1) & QUEUE_MASK
;
334 *size
= 0; /* end of data */
338 /***************** Public routines *****************/
340 /* stop the playback and the pending clips */
341 void talk_force_shutup(void)
343 /* Most of this is MAS only */
344 #if CONFIG_CODEC != SWCODEC
349 unsigned char* search
;
351 if (QUEUE_LEVEL
== 0) /* has ended anyway */
354 #if CONFIG_CPU == SH7034
355 CHCR3
&= ~0x0001; /* disable the DMA (and therefore the interrupt also) */
356 #endif /* CONFIG_CPU == SH7034 */
357 /* search next frame boundary and continue up to there */
358 pos
= search
= mp3_get_pos();
359 end
= queue
[queue_read
].buf
+ queue
[queue_read
].len
;
361 if (pos
>= queue
[queue_read
].buf
362 && pos
<= end
) /* really our clip? */
363 { /* (for strange reasons this isn't nesessarily the case) */
364 /* find the next frame boundary */
365 while (search
< end
) /* search the remaining data */
367 if (*search
++ != 0xFF) /* quick search for frame sync byte */
368 continue; /* (this does the majority of the job) */
370 /* look at the (bitswapped) rest of header candidate */
371 if (search
[0] == curr_hd
[0] /* do the quicker checks first */
372 && search
[2] == curr_hd
[2]
373 && (search
[1] & 0x30) == (curr_hd
[1] & 0x30)) /* sample rate */
375 search
--; /* back to the sync byte */
376 break; /* From looking at it, this is our header. */
381 { /* play old data until the frame end, to keep the MAS in sync */
384 queue_write
= (queue_read
+ 1) & QUEUE_MASK
; /* will be empty after next callback */
385 queue
[queue_read
].len
= sent
; /* current one ends after this */
387 #if CONFIG_CPU == SH7034
388 DTCR3
= sent
; /* let the DMA finish this frame */
389 CHCR3
|= 0x0001; /* re-enable DMA */
390 #endif /* CONFIG_CPU == SH7034 */
394 #endif /* CONFIG_CODEC != SWCODEC */
396 /* Either SWCODEC, or MAS had nothing to do (was frame boundary or not our clip) */
398 queue_write
= queue_read
= 0; /* reset the queue */
402 /* Shutup the voice, except if force_enqueue_next is set. */
403 void talk_shutup(void)
405 if (!force_enqueue_next
)
409 /* schedule a clip, at the end or discard the existing queue */
410 static void queue_clip(unsigned char* buf
, long size
, bool enqueue
)
415 talk_shutup(); /* cut off all the pending stuff */
416 /* Something is being enqueued, force_enqueue_next override is no
418 force_enqueue_next
= false;
421 return; /* safety check */
422 #if CONFIG_CPU == SH7034
423 /* disable the DMA temporarily, to be safe of race condition */
426 queue_level
= QUEUE_LEVEL
; /* check old level */
428 if (queue_level
< QUEUE_SIZE
- 1) /* space left? */
430 queue
[queue_write
].buf
= buf
; /* populate an entry */
431 queue
[queue_write
].len
= size
;
432 queue_write
= (queue_write
+ 1) & QUEUE_MASK
;
435 if (queue_level
== 0)
436 { /* queue was empty, we have to do the initial start */
438 #if CONFIG_CODEC != SWCODEC
439 sent
= MIN(size
, 0xFFFF); /* DMA can do no more */
443 mp3_play_data(buf
, sent
, mp3_callback
);
447 mp3_play_pause(true); /* kickoff audio */
451 #if CONFIG_CPU == SH7034
452 CHCR3
|= 0x0001; /* re-enable DMA */
460 /* common code for talk_init() and talk_buffer_steal() */
461 static void reset_state(void)
463 queue_write
= queue_read
= 0; /* reset the queue */
464 p_voicefile
= NULL
; /* indicate no voicefile (trashed) */
465 #if CONFIG_CODEC == SWCODEC
466 /* Allocate a dedicated thumbnail buffer - once */
467 if (p_thumbnail
== NULL
)
469 size_for_thumbnail
= audiobufend
- audiobuf
;
470 if (size_for_thumbnail
> MAX_THUMBNAIL_BUFSIZE
)
471 size_for_thumbnail
= MAX_THUMBNAIL_BUFSIZE
;
472 p_thumbnail
= buffer_alloc(size_for_thumbnail
);
475 /* Just use the audiobuf, without allocating anything */
476 p_thumbnail
= audiobuf
;
477 size_for_thumbnail
= audiobufend
- audiobuf
;
479 p_silence
= NULL
; /* pause clip not accessible */
483 /***************** Public implementation *****************/
487 talk_temp_disable_count
= 0;
488 if (talk_initialized
&& !strcasecmp(last_lang
, global_settings
.lang_file
))
490 /* not a new file, nothing to do */
495 if (filehandle
>= 0) /* MMC: An old voice file might still be open */
502 talk_initialized
= true;
503 strncpy((char *) last_lang
, (char *)global_settings
.lang_file
,
506 #if CONFIG_CODEC == SWCODEC
507 audio_get_buffer(false, NULL
); /* Must tell audio to reinitialize */
509 reset_state(); /* use this for most of our inits */
511 filehandle
= open_voicefile();
512 has_voicefile
= (filehandle
>= 0); /* test if we can open it */
517 voicefile_size
= filesize(filehandle
);
518 close(filehandle
); /* close again, this was just to detect presence */
524 #if CONFIG_CODEC == SWCODEC
525 /* return if a voice codec is required or not */
526 bool talk_voice_required(void)
528 return (voicefile_size
!= 0) /* Voice file is available */
529 || (global_settings
.talk_dir_clip
) /* Thumbnail clips are required */
530 || (global_settings
.talk_file_clip
);
534 /* return size of voice file */
535 int talk_get_bufsize(void)
537 return voicefile_size
;
540 /* somebody else claims the mp3 buffer, e.g. for regular play/record */
541 void talk_buffer_steal(void)
543 #if CONFIG_CODEC != SWCODEC
547 if (filehandle
>= 0) /* only relevant for MMC */
557 /* play a voice ID from voicefile */
558 int talk_id(int32_t id
, bool enqueue
)
561 unsigned char* clipbuf
;
565 if (talk_temp_disable_count
> 0)
566 return -1; /* talking has been disabled */
567 #if CONFIG_CODEC != SWCODEC
568 if (audio_status()) /* busy, buffer in use */
572 if (p_voicefile
== NULL
&& has_voicefile
)
573 load_voicefile(); /* reload needed */
575 if (p_voicefile
== NULL
) /* still no voices? */
578 if (id
== -1) /* -1 is an indication for silence */
581 decimals
= (((uint32_t)id
) >> DECIMAL_SHIFT
) & 0x7;
583 /* check if this is a special ID, with a value */
584 unit
= ((uint32_t)id
) >> UNIT_SHIFT
;
585 if (unit
|| decimals
)
586 { /* sign-extend the value */
587 id
= (uint32_t)id
<< (32-DECIMAL_SHIFT
);
588 id
>>= (32-DECIMAL_SHIFT
);
590 talk_value_decimal(id
, unit
, decimals
, enqueue
); /* speak it */
591 return 0; /* and stop, end of special case */
594 clipbuf
= get_clip(id
, &clipsize
);
596 return -1; /* not present */
598 queue_clip(clipbuf
, clipsize
, enqueue
);
602 /* Speaks zero or more IDs (from an array). */
603 int talk_idarray(long *ids
, bool enqueue
)
608 while(*ids
!= TALK_FINAL_ID
)
610 if((r
= talk_id(*ids
++, enqueue
)) <0)
617 /* Make sure the current utterance is not interrupted by the next one. */
618 void talk_force_enqueue_next(void)
620 force_enqueue_next
= true;
623 /* play a thumbnail from file */
624 int talk_file(const char* filename
, bool enqueue
)
628 #if CONFIG_CODEC != SWCODEC
629 struct mp3entry info
;
632 if (talk_temp_disable_count
> 0)
633 return -1; /* talking has been disabled */
634 #if CONFIG_CODEC != SWCODEC
635 if (audio_status()) /* busy, buffer in use */
639 if (p_thumbnail
== NULL
|| size_for_thumbnail
<= 0)
642 #if CONFIG_CODEC != SWCODEC
643 if(mp3info(&info
, filename
)) /* use this to find real start */
645 return 0; /* failed to open, or invalid */
649 fd
= open(filename
, O_RDONLY
);
650 if (fd
< 0) /* failed to open */
655 #if CONFIG_CODEC != SWCODEC
656 lseek(fd
, info
.first_frame_offset
, SEEK_SET
); /* behind ID data */
659 size
= read(fd
, p_thumbnail
, size_for_thumbnail
);
662 /* ToDo: find audio, skip ID headers and trailers */
664 if (size
> 0 && size
!= size_for_thumbnail
) /* Don't play missing or truncated clips */
666 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
667 bitswap(p_thumbnail
, size
);
669 queue_clip(p_thumbnail
, size
, enqueue
);
676 /* say a numeric value, this word ordering works for english,
677 but not necessarily for other languages (e.g. german) */
678 int talk_number(long n
, bool enqueue
)
680 int level
= 2; /* mille count */
681 long mil
= 1000000000; /* highest possible "-illion" */
683 if (talk_temp_disable_count
> 0)
684 return -1; /* talking has been disabled */
685 #if CONFIG_CODEC != SWCODEC
686 if (audio_status()) /* busy, buffer in use */
691 talk_shutup(); /* cut off all the pending stuff */
695 talk_id(VOICE_ZERO
, true);
701 talk_id(VOICE_MINUS
, true);
707 int segment
= n
/ mil
; /* extract in groups of 3 digits */
708 n
-= segment
* mil
; /* remove the used digits from number */
709 mil
/= 1000; /* digit place for next round */
713 int hundreds
= segment
/ 100;
714 int ones
= segment
% 100;
718 talk_id(VOICE_ZERO
+ hundreds
, true);
719 talk_id(VOICE_HUNDRED
, true);
722 /* combination indexing */
725 int tens
= ones
/10 + 18;
726 talk_id(VOICE_ZERO
+ tens
, true);
730 /* direct indexing */
732 talk_id(VOICE_ZERO
+ ones
, true);
734 /* add billion, million, thousand */
736 talk_id(VOICE_THOUSAND
+ level
, true);
744 /* Say time duration/interval. Input is time in seconds,
745 say hours,minutes,seconds. */
746 static int talk_time_unit(long secs
, bool exact
, bool enqueue
)
751 if((hours
= secs
/3600)) {
753 talk_value(hours
, UNIT_HOUR
, true);
755 if((mins
= secs
/60)) {
758 talk_value(mins
, UNIT_MIN
, true);
759 else talk_number(mins
, true); /* don't say "minutes" */
761 if((exact
&& secs
) || (!hours
&& !mins
))
762 talk_value(secs
, UNIT_SEC
, true);
763 else if(!hours
&& secs
)
764 talk_number(secs
, true);
768 void talk_fractional(char *tbuf
, int value
, int unit
)
771 /* strip trailing zeros from the fraction */
772 for (i
= strlen(tbuf
) - 1; (i
>= 0) && (tbuf
[i
] == '0'); i
--)
775 talk_number(value
, true);
778 talk_id(LANG_POINT
, true);
779 talk_spell(tbuf
, true);
784 int talk_value(long n
, int unit
, bool enqueue
)
786 return talk_value_decimal(n
, unit
, 0, enqueue
);
789 /* singular/plural aware saying of a value */
790 int talk_value_decimal(long n
, int unit
, int decimals
, bool enqueue
)
793 static const int unit_voiced
[] =
794 { /* lookup table for the voice ID of the units */
795 [0 ... UNIT_LAST
-1] = -1, /* regular ID, int, signed */
797 = VOICE_MILLISECONDS
, /* here come the "real" units */
811 = VOICE_MILLIAMPHOURS
,
821 = VOICE_KBIT_PER_SEC
,
823 = VOICE_PM_UNITS_PER_TICK
,
826 static const int pow10
[] = { /* 10^0 - 10^7 */
827 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000
833 if (talk_temp_disable_count
> 0)
834 return -1; /* talking has been disabled */
835 #if CONFIG_CODEC != SWCODEC
836 if (audio_status()) /* busy, buffer in use */
840 /* special case for time duration */
841 if (unit
== UNIT_TIME
|| unit
== UNIT_TIME_EXACT
)
842 return talk_time_unit(n
, unit
== UNIT_TIME_EXACT
, enqueue
);
844 if (unit
< 0 || unit
>= UNIT_LAST
)
847 unit_id
= unit_voiced
[unit
];
849 if ((n
==1 || n
==-1) /* singular? */
850 && unit_id
>= VOICE_SECONDS
&& unit_id
<= VOICE_HOURS
)
852 unit_id
--; /* use the singular for those units which have */
855 /* special case with a "plus" before */
856 if (n
> 0 && (unit
== UNIT_SIGNED
|| unit
== UNIT_DB
))
858 talk_id(VOICE_PLUS
, enqueue
);
864 /* needed for the "-0.5" corner case */
867 talk_id(VOICE_MINUS
, enqueue
);
871 fmt
[2] = '0' + decimals
;
873 snprintf(tbuf
, sizeof(tbuf
), fmt
, n
% pow10
[decimals
]);
874 talk_fractional(tbuf
, n
/ pow10
[decimals
], unit_id
);
879 talk_number(n
, enqueue
); /* say the number */
880 talk_id(unit_id
, true); /* say the unit, if any */
886 int talk_spell(const char* spell
, bool enqueue
)
888 char c
; /* currently processed char */
890 if (talk_temp_disable_count
> 0)
891 return -1; /* talking has been disabled */
892 #if CONFIG_CODEC != SWCODEC
893 if (audio_status()) /* busy, buffer in use */
898 talk_shutup(); /* cut off all the pending stuff */
900 while ((c
= *spell
++) != '\0')
902 /* if this grows into too many cases, I should use a table */
903 if (c
>= 'A' && c
<= 'Z')
904 talk_id(VOICE_CHAR_A
+ c
- 'A', true);
905 else if (c
>= 'a' && c
<= 'z')
906 talk_id(VOICE_CHAR_A
+ c
- 'a', true);
907 else if (c
>= '0' && c
<= '9')
908 talk_id(VOICE_ZERO
+ c
- '0', true);
910 talk_id(VOICE_MINUS
, true);
912 talk_id(VOICE_PLUS
, true);
914 talk_id(VOICE_DOT
, true);
916 talk_id(VOICE_PAUSE
, true);
922 void talk_disable(bool disable
)
925 talk_temp_disable_count
++;
927 talk_temp_disable_count
--;
930 void talk_setting(const void *global_settings_variable
)
932 const struct settings_list
*setting
;
933 if (!global_settings
.talk_menu
)
935 setting
= find_setting(global_settings_variable
, NULL
);
938 if (setting
->lang_id
)
939 talk_id(setting
->lang_id
,false);
944 void talk_date(struct tm
*tm
, bool enqueue
)
946 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, enqueue
);
947 talk_number(tm
->tm_mday
, true);
948 talk_number(1900 + tm
->tm_year
, true);
951 void talk_time(struct tm
*tm
, bool enqueue
)
953 if (global_settings
.timeformat
== 1)
956 long am_pm_id
= VOICE_AM
;
957 int hour
= tm
->tm_hour
;
965 talk_number(hour
, enqueue
);
967 /* Voice the minutes */
970 /* Say o'clock if the minute is 0. */
971 talk_id(VOICE_OCLOCK
, true);
975 /* Pronounce the leading 0 */
977 talk_id(VOICE_OH
, true);
978 talk_number(tm
->tm_min
, true);
980 talk_id(am_pm_id
, true);
984 /* Voice the time in 24 hour format */
985 talk_number(tm
->tm_hour
, enqueue
);
988 talk_id(VOICE_HUNDRED
, true);
989 talk_id(VOICE_HOUR
, true);
993 /* Pronounce the leading 0 */
995 talk_id(VOICE_OH
, true);
996 talk_number(tm
->tm_min
, true);