Changeset 713

Show
Ignore:
Timestamp:
2005-01-23 18:46:28 (4 years ago)
Author:
conrad
Message:

update seek-stress to be a bit smarter about finding the start of data

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • liboggz/trunk/src/examples/seek-stress.c

    r575 r713  
    3333#include <stdio.h> 
    3434#include <stdlib.h> 
     35#include <string.h> 
    3536#include <oggz/oggz.h> 
    3637 
    37 static int got_an_eos = 0; 
     38static int has_skeleton = 0; 
    3839 
    3940static int 
    4041read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data) 
    4142{ 
     43 unsigned char * header = op->packet; 
     44  
    4245#if 0 
    4346  if (got_an_eos) { 
     
    5659#endif 
    5760 
    58   return OGGZ_STOP_OK; 
     61  if (op->b_o_s) { 
     62    if (op->bytes >= 8 && !strncmp ((char *)header, "fishead", 8)) 
     63      has_skeleton = 1; 
     64    return OGGZ_CONTINUE; 
     65  } else if (op->e_o_s) { 
     66    return OGGZ_STOP_OK; 
     67  } else { 
     68    if (has_skeleton) return OGGZ_CONTINUE; 
     69    else return OGGZ_STOP_OK; 
     70  } 
     71  return OGGZ_CONTINUE; 
    5972} 
    6073 
     
    6477  printf ("Attempt seek to %lld ms:\n", units); 
    6578  units = oggz_seek_units (oggz, units, SEEK_SET); 
    66   printf ("%08llx: %lld ms\n", oggz_tell (oggz), oggz_tell_units (oggz)); 
     79  printf ("%08lx: %lld ms\n", oggz_tell (oggz), oggz_tell_units (oggz)); 
    6780  return units; 
    6881} 
     
    87100 
    88101  while ((n = oggz_read (oggz, 1024)) > 0); 
    89   while ((n = oggz_read (oggz, 1024)) > 0); 
    90   while ((n = oggz_read (oggz, 1024)) > 0); 
    91102  oggz_set_data_start (oggz, oggz_tell (oggz)); 
    92103   
    93104  max_units = oggz_seek_units (oggz, 0, SEEK_END); 
    94   printf ("%08llx: %lld ms\n", oggz_tell (oggz), oggz_tell_units (oggz)); 
     105  printf ("%08lx: %lld ms\n", oggz_tell (oggz), oggz_tell_units (oggz)); 
    95106 
    96107  try_seek_units (oggz, max_units / 2);