From f512558650175b8834d3a2125d4d3d5a3df78606 Mon Sep 17 00:00:00 2001 From: Steve Bavin Date: Wed, 25 Oct 2006 06:19:27 +0000 Subject: Only flush PCM buffered voice data when explicitly told to. Patch by Stephane Doyen. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11331 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 18 +++++++++++++----- apps/playback.h | 2 +- apps/talk.c | 11 ++++++++++- docs/CREDITS | 1 + 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/apps/playback.c b/apps/playback.c index ddb6019537..db47b0be6f 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -328,6 +328,14 @@ void mp3_play_stop(void) #endif } +void mp3_play_abort(void) +{ +#ifdef PLAYBACK_VOICE + LOGFQUEUE("mp3 > voice Q_VOICE_STOP"); + queue_post(&voice_queue, Q_VOICE_STOP, (void *)1); +#endif +} + bool mp3_pause_done(void) { return pcm_is_paused(); @@ -952,6 +960,10 @@ static void* voice_request_buffer_callback(size_t *realsize, size_t reqsize) case Q_VOICE_STOP: LOGFQUEUE("voice < Q_VOICE_STOP"); + if (ev.data == (void *)1 && !playing && pcm_is_playing()) + /* Aborting: Slight hack - flush PCM buffer if + only being used for voice */ + pcmbuf_play_stop(); if (voice_is_playing) { /* Clear the current buffer */ @@ -980,10 +992,6 @@ static void* voice_request_buffer_callback(size_t *realsize, size_t reqsize) LOGFQUEUE("voice < Q_VOICE_PLAY"); if (!voice_is_playing) { - /* Slight hack - flush PCM buffer if only being used for voice */ - if (!playing && pcm_is_playing()) - pcmbuf_play_stop(); - /* Set up new voice data */ struct voice_info *voice_data; voice_is_playing = true; @@ -3018,7 +3026,7 @@ static void audio_play_start(size_t offset) /* Invalidates all but currently playing track. */ -void audio_invalidate_tracks(void) +static void audio_invalidate_tracks(void) { if (audio_have_tracks()) { last_peek_offset = 0; diff --git a/apps/playback.h b/apps/playback.h index decb709384..6d66581fa9 100644 --- a/apps/playback.h +++ b/apps/playback.h @@ -64,8 +64,8 @@ void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3, bool last_track)); void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3, bool last_track)); -void audio_invalidate_tracks(void); void voice_init(void); +void mp3_play_abort(void); void voice_stop(void); #if CONFIG_CODEC == SWCODEC /* This #ifdef is better here than gui/gwps.c */ diff --git a/apps/talk.c b/apps/talk.c index d03fead233..b5fa06d750 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -318,14 +318,20 @@ re_check: /* stop the playback and the pending clips, but at frame boundary */ static int shutup(void) { +#if CONFIG_CODEC != SWCODEC unsigned char* pos; unsigned char* search; unsigned char* end; +#endif if (QUEUE_LEVEL == 0) /* has ended anyway */ { +#if CONFIG_CODEC == SWCODEC + mp3_play_abort(); +#endif return 0; } +#if CONFIG_CODEC != SWCODEC #if CONFIG_CPU == SH7034 CHCR3 &= ~0x0001; /* disable the DMA (and therefore the interrupt also) */ #endif @@ -366,9 +372,12 @@ static int shutup(void) return 0; } } +#endif /* nothing to do, was frame boundary or not our clip */ - mp3_play_stop(); +#if CONFIG_CODEC == SWCODEC + mp3_play_abort(); +#endif queue_write = queue_read = 0; /* reset the queue */ return 0; diff --git a/docs/CREDITS b/docs/CREDITS index e70dcab317..b39c9c6009 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -243,3 +243,4 @@ Robert Kukla David Quesada Jared Stafford Martin Hensel +Stéphane Doyen -- cgit v1.2.3