SWCODEC: Audio-related threads must be free of further tasks before returning buffers. Cleanup declarations of related functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11618 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9be9767a49
commit
97d1ca5a23
4 changed files with 32 additions and 33 deletions
|
@ -322,16 +322,6 @@ static void voice_thread(void);
|
|||
|
||||
#endif /* PLAYBACK_VOICE */
|
||||
|
||||
/* --- Shared semi-private interfaces --- */
|
||||
|
||||
/* imported */
|
||||
extern void talk_buffer_steal(void);
|
||||
#ifdef HAVE_RECORDING
|
||||
extern void pcm_rec_error_clear(void);
|
||||
extern unsigned long pcm_rec_status(void);
|
||||
#endif
|
||||
|
||||
|
||||
/* --- External interfaces --- */
|
||||
|
||||
void mp3_play_data(const unsigned char* start, int size,
|
||||
|
@ -374,12 +364,31 @@ void mpeg_id3_options(bool _v1first)
|
|||
v1first = _v1first;
|
||||
}
|
||||
|
||||
/* If voice could be swapped out - wait for it to return
|
||||
* Used by buffer claming functions.
|
||||
*/
|
||||
static void wait_for_voice_swap_in(void)
|
||||
{
|
||||
#ifdef PLAYBACK_VOICE
|
||||
if (NULL == iram_buf[CODEC_IDX_VOICE])
|
||||
return;
|
||||
|
||||
while (current_codec != CODEC_IDX_VOICE)
|
||||
yield();
|
||||
#endif /* PLAYBACK_VOICE */
|
||||
}
|
||||
|
||||
unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size)
|
||||
{
|
||||
unsigned char *buf, *end;
|
||||
|
||||
if (audio_is_initialized)
|
||||
{
|
||||
audio_stop();
|
||||
wait_for_voice_swap_in();
|
||||
voice_stop();
|
||||
}
|
||||
/* else buffer_state will be BUFFER_STATE_TRASHED at this point */
|
||||
|
||||
if (buffer_size == NULL)
|
||||
{
|
||||
|
@ -388,9 +397,6 @@ unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
buf = audiobuf;
|
||||
end = audiobufend;
|
||||
|
||||
if (talk_buf || buffer_state == BUFFER_STATE_TRASHED
|
||||
|| !talk_voice_required())
|
||||
{
|
||||
|
@ -399,24 +405,18 @@ unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size)
|
|||
if (buffer_state != BUFFER_STATE_TRASHED)
|
||||
{
|
||||
talk_buffer_steal();
|
||||
#ifdef PLAYBACK_VOICE
|
||||
if (NULL != iram_buf[CODEC_IDX_VOICE])
|
||||
{
|
||||
/* Voice could be swapped out - wait for it to return */
|
||||
while (current_codec != CODEC_IDX_VOICE)
|
||||
yield();
|
||||
}
|
||||
#endif /* PLAYBACK_VOICE */
|
||||
buffer_state = BUFFER_STATE_TRASHED;
|
||||
}
|
||||
|
||||
buf = audiobuf;
|
||||
end = audiobufend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* skip talk buffer and move pcm buffer to end */
|
||||
logf("get buffer: voice");
|
||||
mp3_play_stop();
|
||||
buf += talk_get_bufsize();
|
||||
end -= pcmbuf_init(pcmbuf_get_bufsize(), audiobufend);
|
||||
buf = audiobuf + talk_get_bufsize();
|
||||
end = audiobufend - pcmbuf_init(pcmbuf_get_bufsize(), audiobufend);
|
||||
buffer_state = BUFFER_STATE_VOICED_ONLY;
|
||||
}
|
||||
|
||||
|
@ -438,10 +438,7 @@ void audio_iram_steal(void)
|
|||
if (voice_iram_stolen)
|
||||
return;
|
||||
|
||||
/* Wait for voice to swap back in if current codec was audio */
|
||||
while (current_codec != CODEC_IDX_VOICE)
|
||||
yield();
|
||||
|
||||
wait_for_voice_swap_in();
|
||||
voice_stop();
|
||||
|
||||
/* Save voice IRAM - safe to do here since state is known */
|
||||
|
@ -466,6 +463,8 @@ unsigned char *audio_get_recording_buffer(size_t *buffer_size)
|
|||
unsigned char *end;
|
||||
|
||||
audio_stop();
|
||||
wait_for_voice_swap_in();
|
||||
voice_stop();
|
||||
talk_buffer_steal();
|
||||
|
||||
#ifdef PLAYBACK_VOICE
|
||||
|
@ -478,7 +477,6 @@ unsigned char *audio_get_recording_buffer(size_t *buffer_size)
|
|||
#endif /* PLAYBACK_VOICE */
|
||||
end = audiobufend;
|
||||
|
||||
|
||||
buffer_state = BUFFER_STATE_TRASHED;
|
||||
|
||||
*buffer_size = end - audiobuf;
|
||||
|
|
|
@ -559,7 +559,9 @@ int talk_get_bufsize(void)
|
|||
/* somebody else claims the mp3 buffer, e.g. for regular play/record */
|
||||
int talk_buffer_steal(void)
|
||||
{
|
||||
#if CONFIG_CODEC != SWCODEC
|
||||
mp3_play_stop();
|
||||
#endif
|
||||
#ifdef HAVE_MMC
|
||||
if (filehandle >= 0) /* only relevant for MMC */
|
||||
{
|
||||
|
|
|
@ -62,9 +62,8 @@ extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */
|
|||
void talk_init(void);
|
||||
bool talk_voice_required(void); /* returns true if voice codec required */
|
||||
int talk_get_bufsize(void); /* get the loaded voice file size */
|
||||
#if CONFIG_CODEC != SWCODEC
|
||||
/* talk_buffer_steal - on SWCODEC, for use by buffer functions only */
|
||||
int talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */
|
||||
#endif
|
||||
int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */
|
||||
int talk_file(const char* filename, bool enqueue); /* play a thumbnail from file */
|
||||
int talk_number(long n, bool enqueue); /* say a number */
|
||||
|
|
|
@ -47,10 +47,10 @@ void pcm_calculate_rec_peaks(int *left, int *right);
|
|||
/** General functions for high level codec recording **/
|
||||
/* pcm_rec_error_clear is deprecated for general use. audio_error_clear
|
||||
should be used */
|
||||
/* void pcm_rec_error_clear(void); */
|
||||
void pcm_rec_error_clear(void);
|
||||
/* pcm_rec_status is deprecated for general use. audio_status merges the
|
||||
results for consistency with the hardware codec version */
|
||||
/* unsigned long pcm_rec_status(void); */
|
||||
unsigned long pcm_rec_status(void);
|
||||
void pcm_rec_init(void);
|
||||
int pcm_rec_current_bitrate(void);
|
||||
int pcm_rec_encoder_afmt(void); /* AFMT_* value, AFMT_UNKNOWN if none */
|
||||
|
|
Loading…
Reference in a new issue