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 /apps | |
parent | 7baa450738b20436a6179609eeea48784da2a50f (diff) | |
download | rockbox-ca2b82b7553022009085a74bb24018c7b1c07d4d.tar.gz rockbox-ca2b82b7553022009085a74bb24018c7b1c07d4d.zip |
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
Diffstat (limited to 'apps')
-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 9048226133..428f758f83 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c | |||
@@ -516,7 +516,7 @@ static void audio_reset_buffer_noalloc(void* buf, size_t bufsize); | |||
516 | static int shrink_callback(int handle, unsigned hints, void* start, size_t old_size) | 516 | static int shrink_callback(int handle, unsigned hints, void* start, size_t old_size) |
517 | { | 517 | { |
518 | long offset = audio_current_track()->offset; | 518 | long offset = audio_current_track()->offset; |
519 | int status = audio_status(); | 519 | bool playing = (audio_status() & AUDIO_STATUS_PLAY) == AUDIO_STATUS_PLAY; |
520 | /* TODO: Do it without stopping playback, if possible */ | 520 | /* TODO: Do it without stopping playback, if possible */ |
521 | /* don't call audio_hard_stop() as it frees this handle */ | 521 | /* don't call audio_hard_stop() as it frees this handle */ |
522 | if (thread_self() == audio_thread_id) | 522 | if (thread_self() == audio_thread_id) |
@@ -542,7 +542,7 @@ static int shrink_callback(int handle, unsigned hints, void* start, size_t old_s | |||
542 | audio_reset_buffer_noalloc(start + wanted_size, size); | 542 | audio_reset_buffer_noalloc(start + wanted_size, size); |
543 | break; | 543 | break; |
544 | } | 544 | } |
545 | if (!(status & AUDIO_STATUS_PAUSE)) | 545 | if (playing) |
546 | { /* safe to call even from the audio thread (due to queue_post()) */ | 546 | { /* safe to call even from the audio thread (due to queue_post()) */ |
547 | audio_play(offset); | 547 | audio_play(offset); |
548 | } | 548 | } |
@@ -555,6 +555,17 @@ static struct buflib_callbacks ops = { | |||
555 | .shrink_callback = shrink_callback, | 555 | .shrink_callback = shrink_callback, |
556 | }; | 556 | }; |
557 | 557 | ||
558 | static size_t audio_talkbuf_init(char *bufstart) | ||
559 | { | ||
560 | size_t ret = talkbuf_init(bufstart); | ||
561 | if (bufstart > (size_t)audiobuflen) /* does the voice even fit? */ | ||
562 | { | ||
563 | talk_buffer_steal(); | ||
564 | return 0; | ||
565 | } | ||
566 | return ret; | ||
567 | } | ||
568 | |||
558 | unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size) | 569 | unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size) |
559 | { | 570 | { |
560 | (void)talk_buf; /* always grab the voice buffer for now */ | 571 | (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) | |||
577 | mpeg_audiobuf = core_get_data(audiobuf_handle); | 588 | mpeg_audiobuf = core_get_data(audiobuf_handle); |
578 | /* tell talk about the new buffer, don't re-enable just yet because the | 589 | /* tell talk about the new buffer, don't re-enable just yet because the |
579 | * buffer is stolen */ | 590 | * buffer is stolen */ |
580 | talkbuf_init(mpeg_audiobuf); | 591 | audio_talkbuf_init(mpeg_audiobuf); |
581 | 592 | ||
582 | return mpeg_audiobuf; | 593 | return mpeg_audiobuf; |
583 | } | 594 | } |
@@ -2749,7 +2760,7 @@ static void audio_reset_buffer_noalloc(void* buf, size_t bufsize) | |||
2749 | mpeg_audiobuf = SKIPBYTES(mpeg_audiobuf, sizeof(struct cuesheet)); | 2760 | mpeg_audiobuf = SKIPBYTES(mpeg_audiobuf, sizeof(struct cuesheet)); |
2750 | audiobuflen -= sizeof(struct cuesheet); | 2761 | audiobuflen -= sizeof(struct cuesheet); |
2751 | } | 2762 | } |
2752 | talkbuf_init(mpeg_audiobuf); | 2763 | audio_talkbuf_init(mpeg_audiobuf); |
2753 | } | 2764 | } |
2754 | 2765 | ||
2755 | static void audio_reset_buffer(void) | 2766 | static void audio_reset_buffer(void) |
@@ -2819,7 +2830,7 @@ void audio_stop(void) | |||
2819 | playing = false; | 2830 | playing = false; |
2820 | #endif /* SIMULATOR */ | 2831 | #endif /* SIMULATOR */ |
2821 | /* give voice our entire buffer */ | 2832 | /* give voice our entire buffer */ |
2822 | talkbuf_init(mpeg_audiobuf); | 2833 | audio_talkbuf_init(mpeg_audiobuf); |
2823 | } | 2834 | } |
2824 | 2835 | ||
2825 | /* dummy */ | 2836 | /* dummy */ |