1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
9 * by the XIPHOPHORUS Company http://www.xiph.org/ *
11 ********************************************************************
13 function: illustrate seeking, and test it too
14 last mod: $Id: seeking_example.c,v 1.7 2001/02/26 03:50:38 xiphmont Exp $
16 ********************************************************************/
20 #include "vorbis/codec.h"
21 #include "vorbis/vorbisfile.h"
22 #include "../lib/misc.h"
28 /* open the file/pipe on stdin */
29 if(ov_open(stdin,&ov,NULL,-1)<0){
30 printf("Could not open input as an OggVorbis file.\n\n");
34 /* print details about each logical bitstream in the input */
36 double length=ov_time_total(&ov,-1);
37 printf("testing seeking to random places in %g seconds....\n",length);
39 double val=(double)rand()/RAND_MAX*length;
40 ov_time_seek(&ov,val);
41 printf("\r\t%d [%gs]... ",i,val);
45 printf("\r \nOK.\n\n");
47 printf("Standard input was not seekable.\n");