Commit 0d7fc6e0 authored by shans's avatar shans

Added code to capture "hole in the data" warnings from ogg_stream_packetout

and continue (these occur when page sequence numbers are not monotonic 
increasing for a stream and do not seem to matter)



git-svn-id: http://svn.annodex.net/liboggz/trunk@2395 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent ef6830c0
import sys
# import Test()
SConscript(['scons/SConsTest'])
Import('enable_test')
my_cppdefines = {}
# Check endianness
if sys.byteorder == "big":
print "Host is big endian"
my_cppdefines['WORDS_BIGENDIAN'] = 1
else:
print "Host is little endian"
opts = Options()
opts.Add(BoolOption('enable_read', 'Set to 0 to disable reading support', 1))
my_cppdefines['OGGZ_CONFIG_READ'] = '${enable_read}'
opts.Add(BoolOption('enable_write', 'Set to 0 to disable writing support', 1))
my_cppdefines['OGGZ_CONFIG_WRITE'] = '${enable_write}'
libenv = Environment(options = opts,
CPPPATH = '#/scons',
CPPDEFINES = my_cppdefines)
Export('libenv')
progenv = libenv.Copy()
progenv.Append(LIBS = ['oggz', 'ogg'])
progenv.Append(LIBPATH = '../liboggz')
progenv.Dictionary('ENV')['LD_LIBRARY_PATH'] = './src/liboggz/'
enable_test (progenv)
Export('progenv')
dict = libenv.Dictionary()
enable_read = dict['enable_read']
Export('enable_read')
enable_write = dict['enable_write']
Export('enable_write')
SConscript(['src/SConscript'])
import os
def test_build_function (target, source, env):
return None
def test_emitter (target, source, env):
env.Append (TESTTARGETS = source)
return target, source
test_bld = Builder(action = test_build_function, emitter = test_emitter,
suffix = '.test')
def check_build_one (source, env):
ret = env.Execute (source.abspath)
if ret == 0:
print "PASS: %s" % source
else:
print "FAIL: %s" % source
return ret
def check_pretty_print (s):
l = len(s)
print '=' * l
print s
print '=' * l
def check_build_function (target, source, env):
nr_success = 0
nr_fail = 0
t = env.Dictionary('TESTTARGETS')
for s in t:
ret = check_build_one (s, env)
if ret == 0:
nr_success += 1
else:
nr_fail += 1
if nr_fail == 0:
check_pretty_print ("All %d tests passed" % (nr_success))
return 0
else:
check_pretty_print ("%d of %d tests failed" %
(nr_fail, nr_fail + nr_success))
return 1
check_bld = Builder (action = check_build_function,
suffix = '.check', src_suffix = ".test")
def enable_test (env):
env.Append(BUILDERS = {'Test' : test_bld})
env.Append(BUILDERS = {'Check' : check_bld})
check_target = env.Check ('#/scons/phony.test')
AlwaysBuild (check_target)
env.Alias ('check', check_target)
Export ('enable_test')
#define VERSION "0.8.5"
# DO NOT REMOVE
SConscript(['liboggz/SConscript'])
SConscript(['examples/SConscript'])
SConscript(['tools/SConscript'])
SConscript(['tests/SConscript'])
Import('progenv')
Import('enable_read')
Import('enable_write')
sources = []
if enable_read and enable_write:
sources += ['identity.c']
if enable_read:
sources += ['read-file.c', 'read-io.c', 'seek-stress.c']
if enable_write:
sources += ['write-feed.c', 'write-hungry.c']
examples = map (progenv.Program, sources)
Default(examples)
......@@ -60,8 +60,8 @@
#include "oggz_compat.h"
#include "oggz_private.h"
/*#define DEBUG*/
/*#define DEBUG_VERBOSE*/
/* #define DEBUG */
/* #define DEBUG_VERBOSE */
#define CHUNKSIZE 65536
......@@ -258,84 +258,101 @@ oggz_read_sync (OGGZ * oggz)
/* handle one packet. Try to fetch it from current stream state */
/* extract packets from page */
while(cb_ret == 0){
while(cb_ret == 0) {
if (reader->current_serialno != -1) {
/* process a packet if we can. If the machine isn't loaded,
neither is a page */
while(cb_ret == 0) {
ogg_int64_t granulepos;
int result;
while(cb_ret == 0) {
ogg_int64_t granulepos;
int result;
serialno = reader->current_serialno;
serialno = reader->current_serialno;
stream = oggz_get_stream (oggz, serialno);
stream = oggz_get_stream (oggz, serialno);
if (stream == NULL) {
/* new stream ... check bos etc. */
if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
/* error -- could not add stream */
return -7;
}
}
os = &stream->ogg_stream;
if (stream == NULL) {
/* new stream ... check bos etc. */
if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
/* error -- could not add stream */
return -7;
}
}
os = &stream->ogg_stream;
result = ogg_stream_packetout(os, op);
result = ogg_stream_packetout(os, op);
if(result == -1) {
if(result == -1) {
#ifdef DEBUG
printf ("oggz_read_sync: hole in the data\n");
printf ("oggz_read_sync: hole in the data\n");
#endif
return -7;
}
result = ogg_stream_packetout(os, op);
if (result == -1) {
#ifdef DEBUG
/*
* libogg flags "holes in the data" (which are really
* inconsistencies in the page sequence number) by returning
* -1. This occurs in some files and pretty much doesn't matter,
* so we silently swallow the notification and reget the packet.
* If the result is *still* -1 then something strange is happening.
*/
printf ("shouldn't get here");
#endif
return -7;
}
}
if(result > 0){
int content;
/* got a packet. process it */
granulepos = op->granulepos;
if(result > 0){
int content;
/* got a packet. process it */
granulepos = op->granulepos;
content = oggz_stream_get_content(oggz, serialno);
content = oggz_stream_get_content(oggz, serialno);
/*
* if we have no metrics for this stream yet, then generate them
*/
if
(
(!stream->metric || (content == OGGZ_CONTENT_SKELETON))
&&
(oggz->flags & OGGZ_AUTO)
)
{
oggz_auto_get_granulerate (oggz, op, serialno, NULL);
}
/* attempt to determine granulepos for this packet */
if (oggz->flags & OGGZ_AUTO) {
reader->current_granulepos = oggz_auto_calculate_granulepos (content,
granulepos, stream, op);
} else {
reader->current_granulepos = granulepos;
}
stream->last_granulepos = reader->current_granulepos;
/*
* if we have no metrics for this stream yet, then generate them
*/
if
(
(!stream->metric || (content == OGGZ_CONTENT_SKELETON))
&&
(oggz->flags & OGGZ_AUTO)
)
{
oggz_auto_get_granulerate (oggz, op, serialno, NULL);
}
/* attempt to determine granulepos for this packet */
if (oggz->flags & OGGZ_AUTO) {
reader->current_granulepos =
oggz_auto_calculate_granulepos (content, granulepos, stream, op);
} else {
reader->current_granulepos = granulepos;
}
stream->last_granulepos = reader->current_granulepos;
/* set unit on last packet of page */
if ((oggz->metric || stream->metric) && reader->current_granulepos != -1) {
reader->current_unit = oggz_get_unit (oggz, serialno,
/* set unit on last packet of page */
if
(
(oggz->metric || stream->metric) && reader->current_granulepos != -1
)
{
reader->current_unit = oggz_get_unit (oggz, serialno,
reader->current_granulepos);
}
if (stream->read_packet) {
cb_ret =
stream->read_packet (oggz, op, serialno, stream->read_user_data);
} else if (reader->read_packet) {
cb_ret =
reader->read_packet (oggz, op, serialno, reader->read_user_data);
}
}
if (stream->read_packet) {
cb_ret =
stream->read_packet (oggz, op, serialno, stream->read_user_data);
} else if (reader->read_packet) {
cb_ret =
reader->read_packet (oggz, op, serialno, reader->read_user_data);
}
}
else
break;
}
else
break;
}
}
/* If we've got a stop already, don't read more data in */
......@@ -352,8 +369,8 @@ oggz_read_sync (OGGZ * oggz)
if (stream == NULL) {
/* new stream ... check bos etc. */
if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
/* error -- could not add stream */
return -7;
/* error -- could not add stream */
return -7;
}
/* identify stream type */
......@@ -376,18 +393,18 @@ oggz_read_sync (OGGZ * oggz)
stream->page_granulepos = granulepos;
if ((oggz->metric || stream->metric) && granulepos != -1) {
reader->current_unit = oggz_get_unit (oggz, serialno, granulepos);
reader->current_unit = oggz_get_unit (oggz, serialno, granulepos);
} else if (granulepos == 0) {
reader->current_unit = 0;
reader->current_unit = 0;
}
}
if (stream->read_page) {
cb_ret =
stream->read_page (oggz, &og, serialno, stream->read_page_user_data);
stream->read_page (oggz, &og, serialno, stream->read_page_user_data);
} else if (reader->read_page) {
cb_ret = reader->read_page (oggz, &og, serialno,
reader->read_page_user_data);
reader->read_page_user_data);
}
#if 0
......
Import('progenv')
Import('enable_read')
Import('enable_write')
sources = []
if enable_write:
sources = sources + [
'write-bad-guard.c',
'write-unmarked-guard.c',
'write-recursive.c',
'write-bad-bytes.c',
'write-bad-bos.c',
'write-dup-bos.c',
'write-bad-eos.c',
'write-bad-granulepos.c',
'write-bad-packetno.c'
]
if enable_read and enable_write:
sources = sources + [
'read-generated.c',
'read-stop-ok.c',
'read-stop-err.c',
'io-read.c',
'io-seek.c',
'io-write.c',
'io-read-single.c',
'io-write-flush.c'
]
tests = map (progenv.Program, sources)
Default(tests)
progenv.Test (tests)
Import('progenv')
Import('enable_read')
Import('enable_write')
sources = []
if enable_read:
sources += ['oggzinfo.c', 'oggzed.c', 'oggzdump.c']
if enable_read and enable_write:
sources += ['oggzmerge.c', 'oggzrip.c']
tools = map (progenv.Program, sources)
Default(tools)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment