forked from len0rd/rockbox
voice: rename mp3_play_* functions to voice_play_*
Remove mp3_is_playing() entirely, in favor of pcm_is_playing() Remove mp3_play_pause() entirely, as it's a dummy/no-op call Remoce some archos-specific comments Change-Id: I4e9ff323490a93add00809efd19e0d4e3f198b2d
This commit is contained in:
parent
e404026308
commit
5d40d97585
7 changed files with 46 additions and 115 deletions
66
apps/talk.c
66
apps/talk.c
|
|
@ -46,25 +46,6 @@
|
|||
#include "panic.h"
|
||||
#include "misc.h" /* time_split_units() */
|
||||
|
||||
/* Memory layout varies between targets because the
|
||||
Archos (MASCODEC) devices cannot mix voice and audio playback
|
||||
|
||||
MASCODEC | MASCODEC | SWCODEC
|
||||
(playing) | (stopped) |
|
||||
voicebuf-----------+-----------+------------
|
||||
audio | voice | voice
|
||||
|-----------|------------
|
||||
| thumbnail | thumbnail
|
||||
| |------------
|
||||
| | filebuf
|
||||
| |------------
|
||||
| | audio
|
||||
voicebufend----------+-----------+------------
|
||||
|
||||
SWCODEC allocates dedicated buffers (except voice and thumbnail are together
|
||||
in the talkbuf), MASCODEC reuses audiobuf. */
|
||||
|
||||
|
||||
/***************** Constants *****************/
|
||||
|
||||
#define QUEUE_SIZE 64 /* must be a power of two */
|
||||
|
|
@ -128,7 +109,7 @@ static int queue_write; /* write index of queue, by application */
|
|||
static int queue_read; /* read index of queue, by ISR context */
|
||||
static enum talk_status talk_status = TALK_STATUS_OK;
|
||||
/* protects queue_read, queue_write and thumbnail_buf_used */
|
||||
static struct mutex queue_mutex SHAREDBSS_ATTR;
|
||||
static struct mutex queue_mutex SHAREDBSS_ATTR;
|
||||
#define talk_queue_lock() ({ mutex_lock(&queue_mutex); })
|
||||
#define talk_queue_unlock() ({ mutex_unlock(&queue_mutex); })
|
||||
static int sent; /* how many bytes handed over to playback, owned by ISR */
|
||||
|
|
@ -182,7 +163,7 @@ static inline bool check_audio_status(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* ISR (mp3_callback()) must not run during moving of the clip buffer,
|
||||
/* ISR (voice_callback()) must not run during moving of the clip buffer,
|
||||
* because the MAS may get out-of-sync */
|
||||
static void sync_callback(int handle, bool sync_on)
|
||||
{
|
||||
|
|
@ -269,13 +250,13 @@ static int open_voicefile(void)
|
|||
char* p_lang = DEFAULT_VOICE_LANG; /* default */
|
||||
|
||||
if ( global_settings.lang_file[0] &&
|
||||
global_settings.lang_file[0] != 0xff )
|
||||
global_settings.lang_file[0] != 0xff )
|
||||
{ /* try to open the voice file of the selected language */
|
||||
p_lang = (char *)global_settings.lang_file;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), LANG_DIR "/%s.voice", p_lang);
|
||||
|
||||
|
||||
return open(buf, O_RDONLY);
|
||||
}
|
||||
|
||||
|
|
@ -725,7 +706,7 @@ static void mp3_callback(const void** start, size_t* size)
|
|||
curr_hd[1] = commit_buffer[2];
|
||||
curr_hd[2] = commit_buffer[3];
|
||||
}
|
||||
|
||||
|
||||
talk_queue_unlock();
|
||||
}
|
||||
|
||||
|
|
@ -735,7 +716,7 @@ static void mp3_callback(const void** start, size_t* size)
|
|||
void talk_force_shutup(void)
|
||||
{
|
||||
/* Had nothing to do (was frame boundary or not our clip) */
|
||||
mp3_play_stop();
|
||||
voice_play_stop();
|
||||
talk_queue_lock();
|
||||
queue_write = queue_read = 0; /* reset the queue */
|
||||
thumbnail_buf_used = 0;
|
||||
|
|
@ -761,7 +742,7 @@ static void queue_clip(struct queue_entry *clip, bool enqueue)
|
|||
/* Something is being enqueued, force_enqueue_next override is no
|
||||
longer in effect. */
|
||||
force_enqueue_next = false;
|
||||
|
||||
|
||||
if (!clip->length)
|
||||
return; /* safety check */
|
||||
talk_queue_lock();
|
||||
|
|
@ -780,11 +761,10 @@ static void queue_clip(struct queue_entry *clip, bool enqueue)
|
|||
size_t size;
|
||||
void *buf = commit_transfer(qe, &size);
|
||||
last_clip = qe;
|
||||
mp3_play_data(buf, size, mp3_callback);
|
||||
voice_play_data(buf, size, mp3_callback);
|
||||
curr_hd[0] = commit_buffer[1];
|
||||
curr_hd[1] = commit_buffer[2];
|
||||
curr_hd[2] = commit_buffer[3];
|
||||
mp3_play_pause(true); /* kickoff audio */
|
||||
}
|
||||
|
||||
need_shutup = true;
|
||||
|
|
@ -864,7 +844,7 @@ void talk_init(void)
|
|||
}
|
||||
avg_size = total_size / non_empty;
|
||||
max_clips = MIN((int)(MAX_CLIP_BUFFER_SIZE/avg_size) + 1, non_empty);
|
||||
/* account for possible thumb clips */
|
||||
/* account for possible thumb clips */
|
||||
total_size += THUMBNAIL_RESERVE;
|
||||
max_clips += 16;
|
||||
voicefile_size = total_size;
|
||||
|
|
@ -1156,19 +1136,19 @@ int talk_number(long n, bool enqueue)
|
|||
|
||||
if (!enqueue)
|
||||
talk_shutup(); /* cut off all the pending stuff */
|
||||
|
||||
|
||||
if (n==0)
|
||||
{ /* special case */
|
||||
talk_id(VOICE_ZERO, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (n<0)
|
||||
{
|
||||
talk_id(VOICE_MINUS, true);
|
||||
n = -n;
|
||||
}
|
||||
|
||||
|
||||
while (n)
|
||||
{
|
||||
int segment = n / mil; /* extract in groups of 3 digits */
|
||||
|
|
@ -1197,7 +1177,7 @@ int talk_number(long n, bool enqueue)
|
|||
/* direct indexing */
|
||||
if (ones)
|
||||
talk_id(VOICE_ZERO + ones, true);
|
||||
|
||||
|
||||
/* add billion, million, thousand */
|
||||
if (mil)
|
||||
talk_id(VOICE_THOUSAND + level, true);
|
||||
|
|
@ -1261,21 +1241,21 @@ int talk_value(long n, int unit, bool enqueue)
|
|||
int talk_value_decimal(long n, int unit, int decimals, bool enqueue)
|
||||
{
|
||||
int unit_id;
|
||||
static const int unit_voiced[] =
|
||||
static const int unit_voiced[] =
|
||||
{ /* lookup table for the voice ID of the units */
|
||||
[0 ... UNIT_LAST-1] = -1, /* regular ID, int, signed */
|
||||
[UNIT_MS]
|
||||
= VOICE_MILLISECONDS, /* here come the "real" units */
|
||||
[UNIT_SEC]
|
||||
= VOICE_SECONDS,
|
||||
= VOICE_SECONDS,
|
||||
[UNIT_MIN]
|
||||
= VOICE_MINUTES,
|
||||
= VOICE_MINUTES,
|
||||
[UNIT_HOUR]
|
||||
= VOICE_HOURS,
|
||||
= VOICE_HOURS,
|
||||
[UNIT_KHZ]
|
||||
= VOICE_KHZ,
|
||||
= VOICE_KHZ,
|
||||
[UNIT_DB]
|
||||
= VOICE_DB,
|
||||
= VOICE_DB,
|
||||
[UNIT_PERCENT]
|
||||
= VOICE_PERCENT,
|
||||
[UNIT_MAH]
|
||||
|
|
@ -1411,7 +1391,7 @@ int talk_time_intervals(long time, int unit_idx, bool enqueue)
|
|||
int talk_spell(const char* spell, bool enqueue)
|
||||
{
|
||||
char c; /* currently processed char */
|
||||
|
||||
|
||||
if (talk_temp_disable_count > 0)
|
||||
return -1; /* talking has been disabled */
|
||||
if (!check_audio_status())
|
||||
|
|
@ -1419,7 +1399,7 @@ int talk_spell(const char* spell, bool enqueue)
|
|||
|
||||
if (!enqueue)
|
||||
talk_shutup(); /* cut off all the pending stuff */
|
||||
|
||||
|
||||
while ((c = *spell++) != '\0')
|
||||
{
|
||||
/* if this grows into too many cases, I should use a table */
|
||||
|
|
@ -1434,7 +1414,7 @@ int talk_spell(const char* spell, bool enqueue)
|
|||
else if (c == '+')
|
||||
talk_id(VOICE_PLUS, true);
|
||||
else if (c == '.')
|
||||
talk_id(VOICE_DOT, true);
|
||||
talk_id(VOICE_DOT, true);
|
||||
else if (c == ' ')
|
||||
talk_id(VOICE_PAUSE, true);
|
||||
else if (c == '/')
|
||||
|
|
@ -1448,7 +1428,7 @@ void talk_disable(bool disable)
|
|||
{
|
||||
if (disable)
|
||||
talk_temp_disable_count++;
|
||||
else
|
||||
else
|
||||
talk_temp_disable_count--;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue