diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2006-11-28 15:00:56 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2006-11-28 15:00:56 +0000 |
commit | 97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9 (patch) | |
tree | cbb2526852c17dbeb2ad361a8362f36fd0ad693f | |
parent | 9be9767a49fea9b12ff0437acabb0ad0e30b3d52 (diff) | |
download | rockbox-97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9.tar.gz rockbox-97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9.zip |
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
-rw-r--r-- | apps/playback.c | 56 | ||||
-rw-r--r-- | apps/talk.c | 2 | ||||
-rw-r--r-- | apps/talk.h | 3 | ||||
-rw-r--r-- | firmware/export/pcm_record.h | 4 |
4 files changed, 32 insertions, 33 deletions
diff --git a/apps/playback.c b/apps/playback.c index f88c7f6d18..02af5b6ec4 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -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; diff --git a/apps/talk.c b/apps/talk.c index cabc93576b..107cb72e6e 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -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 */ { diff --git a/apps/talk.h b/apps/talk.h index 4c1ef7c625..e863a3d25b 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -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 */ diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h index 84db80680d..38ec202cdc 100644 --- a/firmware/export/pcm_record.h +++ b/firmware/export/pcm_record.h @@ -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 */ |