diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2011-11-06 12:01:43 +0000 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2011-11-06 12:01:43 +0000 |
| commit | ca2b82b7553022009085a74bb24018c7b1c07d4d (patch) | |
| tree | 0668b9e02c39838f0a0514a40777a33ea0c84d00 | |
| parent | 7baa450738b20436a6179609eeea48784da2a50f (diff) | |
| download | rockbox-ca2b82b7553022009085a74bb24018c7b1c07d4d.zip rockbox-ca2b82b7553022009085a74bb24018c7b1c07d4d.tar.gz rockbox-ca2b82b7553022009085a74bb24018c7b1c07d4d.tar.bz2 rockbox-ca2b82b7553022009085a74bb24018c7b1c07d4d.tar.xz | |
hwcodec: fix shrink_callback resuming playback wrongly, and add checks
if the voice is bigger than the audiobuffer. NOTE: This is the case on the sim
so voice doesn't appear to work currently on hwcodec. Someone needs to verify
on a real target.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30910 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/mpeg.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/mpeg.c b/apps/mpeg.c index 9048226..428f758 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c @@ -516,7 +516,7 @@ static void audio_reset_buffer_noalloc(void* buf, size_t bufsize); static int shrink_callback(int handle, unsigned hints, void* start, size_t old_size) { long offset = audio_current_track()->offset; - int status = audio_status(); + bool playing = (audio_status() & AUDIO_STATUS_PLAY) == AUDIO_STATUS_PLAY; /* TODO: Do it without stopping playback, if possible */ /* don't call audio_hard_stop() as it frees this handle */ if (thread_self() == audio_thread_id) @@ -542,7 +542,7 @@ static int shrink_callback(int handle, unsigned hints, void* start, size_t old_s audio_reset_buffer_noalloc(start + wanted_size, size); break; } - if (!(status & AUDIO_STATUS_PAUSE)) + if (playing) { /* safe to call even from the audio thread (due to queue_post()) */ audio_play(offset); } @@ -555,6 +555,17 @@ static struct buflib_callbacks ops = { .shrink_callback = shrink_callback, }; +static size_t audio_talkbuf_init(char *bufstart) +{ + size_t ret = talkbuf_init(bufstart); + if (bufstart > (size_t)audiobuflen) /* does the voice even fit? */ + { + talk_buffer_steal(); + return 0; + } + return ret; +} + unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size) { (void)talk_buf; /* always grab the voice buffer for now */ @@ -577,7 +588,7 @@ unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size) mpeg_audiobuf = core_get_data(audiobuf_handle); /* tell talk about the new buffer, don't re-enable just yet because the * buffer is stolen */ - talkbuf_init(mpeg_audiobuf); + audio_talkbuf_init(mpeg_audiobuf); return mpeg_audiobuf; } @@ -2749,7 +2760,7 @@ static void audio_reset_buffer_noalloc(void* buf, size_t bufsize) mpeg_audiobuf = SKIPBYTES(mpeg_audiobuf, sizeof(struct cuesheet)); audiobuflen -= sizeof(struct cuesheet); } - talkbuf_init(mpeg_audiobuf); + audio_talkbuf_init(mpeg_audiobuf); } static void audio_reset_buffer(void) @@ -2819,7 +2830,7 @@ void audio_stop(void) playing = false; #endif /* SIMULATOR */ /* give voice our entire buffer */ - talkbuf_init(mpeg_audiobuf); + audio_talkbuf_init(mpeg_audiobuf); } /* dummy */ |