Changeset 122:150a6d2fdfbc in roaraudio


Ignore:
Timestamp:
07/13/08 15:30:14 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

only open a new stream if decoder infos changed, not every time we have a new logical bitstream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarvorbis.c

    r121 r122  
    2727} 
    2828 
    29 int update_stream (struct roar_connection * con, struct roar_stream * s, int * out, OggVorbis_File * vf, char * file) { 
     29int update_stream (struct roar_connection * con, struct roar_stream * s, int * out, OggVorbis_File * vf, char * file, struct roar_audio_info * info) { 
    3030 vorbis_info *vi = ov_info(vf, -1); 
    3131 int    bits     = 16; 
     
    3535 int j, h = 0; 
    3636 struct roar_meta   meta; 
     37 int need_new_stream = 0; 
    3738 
    3839 fprintf(stderr, "\n"); 
    3940 
    40  if ( *out != -1 ) 
     41 if ( *out == -1 ) { 
     42  need_new_stream = 1; 
     43 } else if ( info->rate != vi->rate || info->channels != vi->channels ) { 
     44  need_new_stream = 1; 
     45 } 
     46 
     47 if ( need_new_stream ) { 
     48  if ( *out != -1 ) 
    4149  close(*out); 
    4250 
    43  fprintf(stderr, "Audio: %i channel, %liHz\n\n", vi->channels, vi->rate); 
     51  fprintf(stderr, "Audio: %i channel, %liHz\n\n", vi->channels, vi->rate); 
    4452 
    45  if ( (*out = roar_simple_new_stream_obj(con, s, vi->rate, vi->channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
    46   roar_disconnect(con); 
    47   return -1; 
     53  info->rate     = vi->rate; 
     54  info->channels = vi->channels; 
     55 
     56  if ( (*out = roar_simple_new_stream_obj(con, s, vi->rate, vi->channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
     57   roar_disconnect(con); 
     58   return -1; 
     59  } 
    4860 } 
    4961 
     
    91103 int current_section; 
    92104 int last_section = -1; 
     105 struct roar_audio_info info; 
    93106 char pcmout[4096]; 
    94107 
     
    138151 
    139152  if ( last_section != current_section ) 
    140    if ( update_stream(&con, &s, &out, &vf, file) == -1 ) 
     153   if ( update_stream(&con, &s, &out, &vf, file, &info) == -1 ) 
    141154    return -1; 
    142155 
Note: See TracChangeset for help on using the changeset viewer.