Bug 519155 - reset oggz seek on failure. r=doublec

This commit is contained in:
Chris Pearce 2009-10-03 17:08:12 +13:00
Родитель 9a94880e1e
Коммит c7497caf98
7 изменённых файлов: 91 добавлений и 2 удалений

Просмотреть файл

@ -132,6 +132,7 @@ _TEST_FILES += \
bug504843.ogv \ bug504843.ogv \
bug506094.ogv \ bug506094.ogv \
bug516323.ogv \ bug516323.ogv \
chain.ogv \
dirac.ogg \ dirac.ogg \
seek.ogv \ seek.ogv \
short-video.ogv \ short-video.ogv \

Двоичные данные
content/media/test/chain.ogv Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -13,6 +13,7 @@ var gSmallTests = [
{ name:"bug498855-2.ogv", type:"video/ogg", duration:0.2 }, { name:"bug498855-2.ogv", type:"video/ogg", duration:0.2 },
{ name:"bug498855-3.ogv", type:"video/ogg", duration:0.2 }, { name:"bug498855-3.ogv", type:"video/ogg", duration:0.2 },
{ name:"bug504644.ogv", type:"video/ogg", duration:1.56 }, { name:"bug504644.ogv", type:"video/ogg", duration:1.56 },
{ name:"chain.ogv", type:"video/ogg", duration:Number.NaN },
{ name:"bogus.duh", type:"bogus/duh" } { name:"bogus.duh", type:"bogus/duh" }
]; ];

Просмотреть файл

@ -26,3 +26,5 @@ bug516847.patch: Fix for bug 516847 (duplicate frame handling).
bug518169.patch: Fix bug 518169, fix faster_seek.patch. bug518169.patch: Fix bug 518169, fix faster_seek.patch.
bug504843.patch: Propogate read errors from oggz_read_sync(). bug504843.patch: Propogate read errors from oggz_read_sync().
bug519155.patch: Fix oggz seek's reset so that it can rollback on fail correctly.

Просмотреть файл

@ -0,0 +1,73 @@
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
@@ -154,17 +154,17 @@ oggz_reset_seek (OGGZ * oggz, oggz_off_t
if (offset_at == -1) return -1;
oggz->offset = offset_at;
#ifdef DEBUG
printf ("reset to %" PRI_OGGZ_OFF_T "d\n", offset_at);
#endif
- if (unit != -1) reader->current_unit = unit;
+ reader->current_unit = unit;
return offset_at;
}
static long
oggz_reset (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence)
{
oggz_reset_streams (oggz);
@@ -800,38 +800,49 @@ oggz_bounded_seek_set (OGGZ * oggz,
static ogg_int64_t
oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset)
{
oggz_off_t offset_orig, offset_at, offset_end;
ogg_int64_t granulepos;
ogg_int64_t unit_end;
long serialno;
ogg_page * og;
+ OggzReader * reader = &oggz->x.reader;
og = &oggz->current_page;
offset_orig = oggz->offset;
offset_at = oggz_seek_raw (oggz, 0, SEEK_END);
if (offset_at == -1) return -1;
offset_end = oggz_get_prev_start_page (oggz, og, &granulepos, &serialno);
if (offset_end < 0) {
oggz_reset (oggz, offset_orig, -1, SEEK_SET);
return -1;
}
unit_end = oggz_get_unit (oggz, serialno, granulepos);
-
+
#ifdef DEBUG
printf ("*** oggz_seek_end: found packet (%lld) at @%" PRI_OGGZ_OFF_T "d [%lld]\n",
unit_end, offset_end, granulepos);
#endif
+ if (unit_end == -1) {
+ /* Failed to get time at the end, reset and fail. */
+ oggz_reset (oggz, offset_orig, -1, SEEK_SET);
+ return -1;
+ }
+
+ reader->current_unit = unit_end;
+ if (unit_offset == 0) {
+ return unit_end;
+ }
return oggz_bounded_seek_set (oggz, unit_end + unit_offset, 0, -1, 0);
}
off_t
oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence)
{
OggzReader * reader;
ogg_int64_t units = -1;

Просмотреть файл

@ -159,7 +159,7 @@ oggz_reset_seek (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence)
printf ("reset to %" PRI_OGGZ_OFF_T "d\n", offset_at); printf ("reset to %" PRI_OGGZ_OFF_T "d\n", offset_at);
#endif #endif
if (unit != -1) reader->current_unit = unit; reader->current_unit = unit;
return offset_at; return offset_at;
} }
@ -805,6 +805,7 @@ oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset)
ogg_int64_t unit_end; ogg_int64_t unit_end;
long serialno; long serialno;
ogg_page * og; ogg_page * og;
OggzReader * reader = &oggz->x.reader;
og = &oggz->current_page; og = &oggz->current_page;
@ -827,6 +828,16 @@ oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset)
unit_end, offset_end, granulepos); unit_end, offset_end, granulepos);
#endif #endif
if (unit_end == -1) {
/* Failed to get time at the end, reset and fail. */
oggz_reset (oggz, offset_orig, -1, SEEK_SET);
return -1;
}
reader->current_unit = unit_end;
if (unit_offset == 0) {
return unit_end;
}
return oggz_bounded_seek_set (oggz, unit_end + unit_offset, 0, -1, 0); return oggz_bounded_seek_set (oggz, unit_end + unit_offset, 0, -1, 0);
} }

Просмотреть файл

@ -59,3 +59,4 @@ patch -p3 <faster_seek.patch
patch -p3 <bug516847.patch patch -p3 <bug516847.patch
patch -p3 <bug518169.patch patch -p3 <bug518169.patch
patch -p3 <bug504843.patch patch -p3 <bug504843.patch
patch -p3 <bug519155.patch