Changeset 762:b0fafbce8cc5 in roaraudio


Ignore:
Timestamp:
09/07/08 03:04:30 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added a more complete roar_file_play_full()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/file.h

    r690 r762  
    4545ssize_t roar_file_send_raw   (int out, int in); 
    4646ssize_t roar_file_play       (struct roar_connection * con, char * file, int exec); 
     47ssize_t roar_file_play_full  (struct roar_connection * con, char * file, int exec, int passfh, struct roar_stream * s); 
    4748 
    4849ssize_t roar_file_map        (char * filename, int flags, mode_t mode, size_t len, void ** mem); 
  • libroar/file.c

    r701 r762  
    157157 
    158158ssize_t roar_file_play (struct roar_connection * con, char * file, int exec) { 
     159 struct roar_stream s; 
     160 
     161 return roar_file_play_full(con, file, exec, 0, &s); 
     162} 
     163 
     164ssize_t roar_file_play_full  (struct roar_connection * con, char * file, int exec, int passfh, struct roar_stream * s) { 
    159165 int codec = -1; 
    160166 int in, out = -1; 
    161  struct roar_stream s; 
    162167 ssize_t r = 0; 
    163168 int len; 
     
    171176  return -1; 
    172177 
     178 if ( exec && passfh ) 
     179  return -1; 
     180 
    173181 if ( (in = open(file, O_RDONLY, 0644)) == -1 ) { 
    174182  return -1; 
     
    188196 
    189197 if ( exec ) { 
    190   if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) { 
    191    close(in); 
    192    return -1; 
    193   } 
    194  
    195   if ( roar_stream_connect(con, &s, ROAR_DIR_PLAY) == -1 ) { 
    196    close(in); 
    197    return -1; 
    198   } 
    199  
    200   if ( roar_stream_exec(con, &s) == -1 ) { 
     198  if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
     199   close(in); 
     200   return -1; 
     201  } 
     202 
     203  if ( roar_stream_connect(con, s, ROAR_DIR_PLAY) == -1 ) { 
     204   close(in); 
     205   return -1; 
     206  } 
     207 
     208  if ( roar_stream_exec(con, s) == -1 ) { 
    201209   close(in); 
    202210   return -1; 
     
    215223 write(out, buf, len); 
    216224 
    217  r = roar_file_send_raw(out, in); 
    218  
    219  close(out); 
    220  
    221  if ( exec ) { 
    222   con->fh = -1; 
    223  } 
    224  
    225  close(in); 
     225 if ( !passfh ) { 
     226  r = roar_file_send_raw(out, in); 
     227 
     228  close(out); 
     229 
     230  if ( exec ) { 
     231   con->fh = -1; 
     232  } 
     233 
     234  close(in); 
     235 } else { 
     236  if ( roar_stream_passfh(con, s, in) == -1 ) { 
     237   return -1; 
     238  } 
     239  close(out); 
     240  close(in); 
     241  return 0; 
     242 } 
    226243 
    227244 return r; 
Note: See TracChangeset for help on using the changeset viewer.