summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-11-28 15:00:56 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-11-28 15:00:56 +0000
commit97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9 (patch)
treecbb2526852c17dbeb2ad361a8362f36fd0ad693f /apps
parent9be9767a49fea9b12ff0437acabb0ad0e30b3d52 (diff)
downloadrockbox-97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9.zip
rockbox-97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9.tar.gz
rockbox-97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9.tar.bz2
rockbox-97d1ca5a238b9fa676fd59cb81cb0ec9069a4ba9.tar.xz
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
Diffstat (limited to 'apps')
-rw-r--r--apps/playback.c56
-rw-r--r--apps/talk.c2
-rw-r--r--apps/talk.h3
3 files changed, 30 insertions, 31 deletions
diff --git a/apps/playback.c b/apps/playback.c
index f88c7f6..02af5b6 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 cabc935..107cb72 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 4c1ef7c..e863a3d 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 */