Changeset 776:1d9ce44598b2 in roaraudio


Ignore:
Timestamp:
09/07/08 16:43:20 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

better support passfh on seekable streams

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/file.c

    r774 r776  
    164164 int in, out = -1; 
    165165 ssize_t r = 0; 
     166 int seek; 
    166167 int len; 
    167168 char buf[BUFSIZE]; 
     
    192193 codec = roar_file_codecdetect(buf, len); 
    193194 
     195 seek = lseek(in, 0, SEEK_SET) == (off_t) -1 ? 0 : 1; 
     196 
    194197 if ( codec == -1 ) { 
    195198  close(in); 
    196199  return -1; 
     200 } 
     201 
     202 if ( passfh && !seek ) { 
     203  ROAR_WARN("roar_file_play_full(*): passfh on non seekable file: this may produce incorrect playback"); 
    197204 } 
    198205 
     
    217224  out = con->fh; 
    218225 } else { 
    219   if ( (out = roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
    220    close(in); 
    221    return -1; 
    222   } 
    223  } 
    224  
    225  write(out, buf, len); 
     226  if ( !(passfh && seek) ) { 
     227   if ( (out = roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
     228    close(in); 
     229    return -1; 
     230   } 
     231  } else { 
     232   if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
     233    close(in); 
     234    return -1; 
     235   } 
     236 
     237   if ( roar_stream_connect(con, s, ROAR_DIR_PLAY) == -1 ) { 
     238    close(in); 
     239    return -1; 
     240   } 
     241  } 
     242 } 
     243 
     244 if ( !seek ) 
     245  write(out, buf, len); 
    226246 
    227247 if ( !passfh ) { 
Note: See TracChangeset for help on using the changeset viewer.