From 4ce4ec7859e7f8074341cfb00af1c207f5d24d3f Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 11 Jul 2009 10:03:10 +0000 Subject: Merge recent vorbifile changes, extensions and fixes back from reference 1.2.2 and 1.2.3 into tremor. git-svn-id: https://svn.xiph.org/trunk/Tremor@16259 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- iseeking_example.c | 259 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 iseeking_example.c (limited to 'iseeking_example.c') diff --git a/iseeking_example.c b/iseeking_example.c new file mode 100644 index 0000000..aaf0d39 --- /dev/null +++ b/iseeking_example.c @@ -0,0 +1,259 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2009 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: illustrate seeking, and test it too + last mod: $Id: iseeking_example.c 16037 2009-05-26 21:10:58Z xiphmont $ + + ********************************************************************/ + +#include +#include +#include +#include + +#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ +# include +# include +#endif + +void _verify(OggVorbis_File *ov, + ogg_int64_t val, + ogg_int64_t pcmval, + ogg_int64_t timeval, + ogg_int64_t pcmlength, + char *bigassbuffer){ + int j; + long bread; + char buffer[4096]; + int dummy; + ogg_int64_t pos; + + /* verify the raw position, the pcm position and position decode */ + if(val!=-1 && ov_raw_tell(ov)pcmval){ + fprintf(stderr,"pcm position out of tolerance: requested %ld, got %ld\n", + (long)pcmval,(long)ov_pcm_tell(ov)); + exit(1); + } + if(timeval!=-1 && ov_time_tell(ov)>timeval){ + fprintf(stderr,"time position out of tolerance: requested %ld, got %ld\n", + (long)timeval,(long)ov_time_tell(ov)); + exit(1); + } + pos=ov_pcm_tell(ov); + if(pos<0 || pos>pcmlength){ + fprintf(stderr,"pcm position out of bounds: got %ld\n",(long)pos); + exit(1); + } + bread=ov_read(ov,buffer,4096,&dummy); + for(j=0;jchannels!=2){ + fprintf(stderr,"Sorry; right now seeking_test can only use Vorbis files\n" + "that are entirely stereo.\n\n"); + exit(1); + } + } + + /* because we want to do sample-level verification that the seek + does what it claimed, decode the entire file into memory */ + pcmlength=ov_pcm_total(&ov,-1); + timelength=ov_time_total(&ov,-1); + bigassbuffer=malloc(pcmlength*4); /* w00t */ + i=0; + while(ival+1){ + fprintf(stderr,"Declared position didn't perfectly match request: %ld != %ld\n", + (long)val,(long)ov_time_tell(&ov)); + exit(1); + } + + _verify(&ov,-1,-1,val,pcmlength,bigassbuffer); + + } + } + + fprintf(stderr,"\r \nOK.\n\n"); + + + }else{ + fprintf(stderr,"Standard input was not seekable.\n"); + } + + ov_clear(&ov); + return 0; +} + + + + + + + + + + + + + -- cgit v1.2.1