Changeset 3843:918695fb1760 in roaraudio
- Timestamp:
- 05/16/10 22:14:27 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarvorbis.c
r3790 r3843 67 67 } 68 68 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) { 69 int 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) { 70 76 vorbis_info *vi = ov_info(vf, -1); 71 77 int bits = 16; … … 75 81 int j, h = 0; 76 82 struct roar_meta meta; 77 int need_new_stream = 0; 83 static int need_new_stream = 1; 84 int need_close = 0; 78 85 int meta_ok; 79 86 … … 84 91 } 85 92 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 } 90 98 } 91 99 92 100 if ( need_new_stream ) { 93 if ( *out != -1)94 close(*out);101 if ( need_close ) 102 roar_vio_close(vio); 95 103 96 104 fprintf(stderr, "Audio: %i channel, %liHz\n\n", vi->channels, vi->rate); … … 99 107 info->channels = vi->channels; 100 108 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 ) { 102 110 roar_disconnect(con); 103 111 return -1; 104 112 } 113 need_new_stream = 0; 105 114 } 106 115 … … 192 201 int i; 193 202 FILE * in; 194 int out = -1;195 203 struct roar_connection con; 196 204 struct roar_stream s; 205 struct roar_vio_calls vio; 197 206 OggVorbis_File vf; 198 207 int eof=0; … … 249 258 #endif 250 259 251 if( ov_open(in, &vf, NULL, 0) < 0) {260 if( ov_open(in, &vf, NULL, 0) < 0 ) { 252 261 fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); 253 262 roar_disconnect(&con); … … 271 280 272 281 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 ) 274 283 return 1; 275 284 … … 278 287 if (ret == 0) { 279 288 /* EOF */ 280 eof =1;289 eof = 1; 281 290 } else if (ret < 0) { 282 291 /* error in the stream. Not a problem, just reporting it in 283 292 case we (the app) cares. In this case, we don't. */ 284 293 } 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); 293 299 294 300 // fclose(in); 295 close(out);301 roar_vio_close(&vio); 296 302 roar_disconnect(&con); 297 303
Note: See TracChangeset
for help on using the changeset viewer.