Bug 520493 - Fix regression in Ogg playback. r=doublec

This commit is contained in:
Chris Pearce 2009-10-14 16:35:59 +13:00
parent 8366722865
commit 9e521230fc
12 changed files with 139 additions and 10 deletions

View File

@ -133,6 +133,7 @@ _TEST_FILES += \
bug504843.ogv \
bug506094.ogv \
bug516323.ogv \
bug520493.ogg \
chain.ogv \
dirac.ogg \
seek.ogv \

Binary file not shown.

View File

@ -45,7 +45,9 @@ var gPlayTests = [
{ name:"bug516323.ogv", type:"video/ogg", duration:4.424 },
// Encoded with vorbis beta1, includes unusually sized codebooks
{ name:"beta-phrasebook.ogg", type:"audio/ogg", duration:4 },
// Small file, only 1 frame with audio only.
{ name:"bug520493.ogg", type:"audio/ogg", duration:0.458 },
{ name:"bogus.duh", type:"bogus/duh" }
];

View File

@ -37,4 +37,8 @@ handle-read-errors.patch: Make oggplay_initialise() handle closing of stream
to 17ef4ca82df28.
bug504843.patch: Abort when decoding video excessively large video frames.
fishsound_reset.patch: Fixes bug 516323.
bug520493.patch: Ensure liboggplay returns data when all tracks
are deactivated when a callback reaches EOF.

View File

@ -0,0 +1,66 @@
diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c
--- a/media/liboggplay/src/liboggplay/oggplay.c
+++ b/media/liboggplay/src/liboggplay/oggplay.c
@@ -638,16 +638,17 @@ OggPlayErrorCode
oggplay_step_decoding(OggPlay *me) {
OggPlayCallbackInfo ** info;
int num_records;
int r;
int i;
int need_data = 0;
int chunk_count = 0;
+ int read_data = 0;
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
/*
* check whether the OggPlayDataCallback is set for the given
* OggPlay handle. If not return with error as there's no callback
@@ -686,17 +687,21 @@ read_more_data:
if (me->active_tracks == 0) {
int remaining = 0;
for (i = 0; i < me->num_tracks; i++) {
if (me->decode_data[i]->current_loc +
me->decode_data[i]->granuleperiod >= me->target + me->decode_data[i]->offset) {
remaining++;
}
}
- if (remaining == 0) {
+ if (remaining == 0 && !read_data) {
+ /*
+ * There's no more data to read, and we've not read any that needs
+ * to be sent to the buffer list via a callback, so exit.
+ */
return E_OGGPLAY_OK;
}
}
/*
* if any of the tracks have not yet met the target (modified by that
* track's offset), then retrieve more data
*/
@@ -783,16 +788,21 @@ read_more_data:
* e.g. some buffer overflow.
*/
case OGGZ_ERR_OUT_OF_MEMORY:
/* ran out of memory during decoding! */
return E_OGGPLAY_OUT_OF_MEMORY;
default:
+ /*
+ * We read some data. Set a flag so that we're guaranteed to try to
+ * send it to the buffer list via a callback.
+ */
+ read_data = 1;
break;
}
}
/*
* prepare a callback
*/
num_records = oggplay_callback_info_prepare (me, &info);
if (info != NULL) {

View File

@ -643,6 +643,7 @@ oggplay_step_decoding(OggPlay *me) {
int i;
int need_data = 0;
int chunk_count = 0;
int read_data = 0;
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
@ -691,7 +692,11 @@ read_more_data:
remaining++;
}
}
if (remaining == 0) {
if (remaining == 0 && !read_data) {
/*
* There's no more data to read, and we've not read any that needs
* to be sent to the buffer list via a callback, so exit.
*/
return E_OGGPLAY_OK;
}
}
@ -788,6 +793,11 @@ read_more_data:
return E_OGGPLAY_OUT_OF_MEMORY;
default:
/*
* We read some data. Set a flag so that we're guaranteed to try to
* send it to the buffer list via a callback.
*/
read_data = 1;
break;
}
}

View File

@ -60,4 +60,4 @@ patch -p3 < fix-17ef4ca82df28.patch
patch -p3 < handle-read-errors.patch
patch -p3 < fishsound_reset.patch
patch -p3 < bug504843.patch
patch -p3 < bug520493.patch

View File

@ -28,3 +28,6 @@ bug518169.patch: Fix bug 518169, fix faster_seek.patch.
bug504843.patch: Propogate read errors from oggz_read_sync().
bug519155.patch: Fix oggz seek's reset so that it can rollback on fail correctly.
bug520493.patch: Fix oggz seek so that it doesn't exit too early, and to use
more accurate page offsets while bisecting.

View File

@ -0,0 +1,46 @@
diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c
--- a/media/liboggz/src/liboggz/oggz_seek.c
+++ b/media/liboggz/src/liboggz/oggz_seek.c
@@ -762,40 +762,36 @@ oggz_bounded_seek_set (OGGZ * oggz,
if (abs(unit_at - unit_target) < fuzz_margin) {
// Within fuzz_margin of target, stop.
break;
}
#ifdef DEBUG
printf ("oggz_bounded_seek_set: offset_next %" PRI_OGGZ_OFF_T "d\n", offset_next);
-#endif
- if (unit_at == unit_last_iter) break;
-
-#ifdef DEBUG
printf ("oggz_bounded_seek_set: [D] want u%lld, got page u%lld @%" PRI_OGGZ_OFF_T "d g%lld\n",
unit_target, unit_at, offset_at, granule_at);
#endif
if (unit_at < unit_target) {
- offset_begin = offset_at;
+ offset_begin = offset_next;
unit_begin = unit_at;
if (unit_end == unit_begin) break;
} else if (unit_at > unit_target) {
offset_end = offset_at-1;
unit_end = unit_at;
if (unit_end == unit_begin) break;
} else {
break;
}
}
/* Reader is now approximately at the seek target. */
- offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET);
+ offset_at = oggz_reset (oggz, offset_next, unit_at, SEEK_SET);
if (offset_at == -1)
return -1;
return (long)reader->current_unit;
}
static ogg_int64_t
oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset)

View File

@ -767,16 +767,12 @@ oggz_bounded_seek_set (OGGZ * oggz,
#ifdef DEBUG
printf ("oggz_bounded_seek_set: offset_next %" PRI_OGGZ_OFF_T "d\n", offset_next);
#endif
if (unit_at == unit_last_iter) break;
#ifdef DEBUG
printf ("oggz_bounded_seek_set: [D] want u%lld, got page u%lld @%" PRI_OGGZ_OFF_T "d g%lld\n",
unit_target, unit_at, offset_at, granule_at);
#endif
if (unit_at < unit_target) {
offset_begin = offset_at;
offset_begin = offset_next;
unit_begin = unit_at;
if (unit_end == unit_begin) break;
} else if (unit_at > unit_target) {
@ -790,7 +786,7 @@ oggz_bounded_seek_set (OGGZ * oggz,
/* Reader is now approximately at the seek target. */
offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET);
offset_at = oggz_reset (oggz, offset_next, unit_at, SEEK_SET);
if (offset_at == -1)
return -1;

View File

@ -60,3 +60,4 @@ patch -p3 <bug516847.patch
patch -p3 <bug518169.patch
patch -p3 <bug504843.patch
patch -p3 <bug519155.patch
patch -p3 <bug520493.patch

View File

@ -353,7 +353,7 @@
(this.video.paused || this.video.ended
? this.video.readyState < this.video.HAVE_CURRENT_DATA
: this.video.readyState < this.video.HAVE_FUTURE_DATA) ||
(this.timeUpdateCount <= 1 &&
(this.timeUpdateCount <= 1 && !this.video.ended &&
this.video.readyState < this.video.HAVE_ENOUGH_DATA &&
this.video.networkState >= this.video.NETWORK_LOADING))
this.startFadeIn(this.statusFader, immediate);