Changeset 3843:918695fb1760 in roaraudio


Ignore:
Timestamp:
05/16/10 22:14:27 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

use VIO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarvorbis.c

    r3790 r3843  
    6767} 
    6868 
    69 int update_stream (struct roar_connection * con, struct roar_stream * s, int * out, OggVorbis_File * vf, char * file, struct roar_audio_info * info, struct roar_vio_calls * vclt) { 
     69int update_stream (struct roar_connection * con, 
     70                   struct roar_stream     * s, 
     71                   struct roar_vio_calls  * vio, 
     72                   OggVorbis_File         * vf, 
     73                   char                   * file, 
     74                   struct roar_audio_info * info, 
     75                   struct roar_vio_calls  * vclt) { 
    7076 vorbis_info *vi = ov_info(vf, -1); 
    7177 int    bits     = 16; 
     
    7581 int j, h = 0; 
    7682 struct roar_meta   meta; 
    77  int need_new_stream = 0; 
     83 static int need_new_stream = 1; 
     84 int need_close = 0; 
    7885 int meta_ok; 
    7986 
     
    8491 } 
    8592 
    86  if ( *out == -1 ) { 
    87   need_new_stream = 1; 
    88  } else if ( info->rate != (uint16_t)vi->rate || info->channels != (uint16_t)vi->channels ) { 
    89   need_new_stream = 1; 
     93 if ( !need_new_stream ) { 
     94  if ( info->rate != (uint16_t)vi->rate || info->channels != (uint16_t)vi->channels ) { 
     95   need_close      = 1; 
     96   need_new_stream = 1; 
     97  } 
    9098 } 
    9199 
    92100 if ( need_new_stream ) { 
    93   if ( *out != -1 ) 
    94   close(*out); 
     101  if ( need_close ) 
     102   roar_vio_close(vio); 
    95103 
    96104  fprintf(stderr, "Audio: %i channel, %liHz\n\n", vi->channels, vi->rate); 
     
    99107  info->channels = vi->channels; 
    100108 
    101   if ( (*out = roar_simple_new_stream_obj(con, s, vi->rate, vi->channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
     109  if ( roar_vio_simple_new_stream_obj(vio, con, s, vi->rate, vi->channels, bits, codec, ROAR_DIR_PLAY) == -1 ) { 
    102110   roar_disconnect(con); 
    103111   return -1; 
    104112  } 
     113  need_new_stream = 0; 
    105114 } 
    106115 
     
    192201 int    i; 
    193202 FILE * in; 
    194  int    out = -1; 
    195203 struct roar_connection con; 
    196204 struct roar_stream     s; 
     205 struct roar_vio_calls  vio; 
    197206 OggVorbis_File vf; 
    198207 int eof=0; 
     
    249258#endif 
    250259 
    251  if(ov_open(in, &vf, NULL, 0) < 0) { 
     260 if( ov_open(in, &vf, NULL, 0) < 0 ) { 
    252261  fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); 
    253262  roar_disconnect(&con); 
     
    271280 
    272281  if ( last_section != current_section ) 
    273    if ( update_stream(&con, &s, &out, &vf, file, &info, vcltfile == NULL ? NULL : &vclt) == -1 ) 
     282   if ( update_stream(&con, &s, &vio, &vf, file, &info, vcltfile == NULL ? NULL : &vclt) == -1 ) 
    274283    return 1; 
    275284 
     
    278287  if (ret == 0) { 
    279288   /* EOF */ 
    280    eof=1; 
     289   eof = 1; 
    281290  } else if (ret < 0) { 
    282291   /* error in the stream.  Not a problem, just reporting it in 
    283292      case we (the app) cares.  In this case, we don't. */ 
    284293  } else { 
    285      /* we don't bother dealing with sample rate changes, etc, but 
    286         you'll have to */ 
    287 //    write(out, pcmout, ret); 
    288    roar_stream_send_data(&con, &s, pcmout, ret); 
    289   } 
    290  } 
    291  
    292   ov_clear(&vf); 
     294   roar_vio_write(&vio, pcmout, ret); 
     295  } 
     296 } 
     297 
     298 ov_clear(&vf); 
    293299 
    294300// fclose(in); 
    295  close(out); 
     301 roar_vio_close(&vio); 
    296302 roar_disconnect(&con); 
    297303 
Note: See TracChangeset for help on using the changeset viewer.