Changeset 2091:d988fc5c90d8 in roaraudio


Ignore:
Timestamp:
07/20/09 18:26:45 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

use a additioal buffer if max(in,out) > max(insize,outsize)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/streams.c

    r2089 r2091  
    827827 size_t   inlen_got; 
    828828 void   * indata = NULL; 
     829 size_t   buflen; 
     830 void   * bufdata = NULL; 
     831 struct roar_buffer * bufbuf = NULL; 
    829832 int      is_the_same = 0; 
    830833 struct roar_audio_info    * stream_info; 
     
    841844 inlen = ROAR_OUTPUT_CALC_OUTBUFSIZE(stream_info); 
    842845 
     846 buflen = ROAR_OUTPUT_CALC_OUTBUFSIZE_MAX(info, stream_info); 
     847 
    843848 if ( inlen == 0 ) { 
    844849  ROAR_WARN("streams_fill_mixbuffer2(id=%i, info=%p{...}): inlen == 0, this should not happen!", id, info); 
     
    861866 ROAR_DBG("streams_fill_mixbuffer2(*): is_the_same=%i", is_the_same); 
    862867 
    863  if ( inlen > outlen ) { 
     868 if ( !is_the_same && buflen > outlen ) { 
     869/* 
    864870  // this is not supported at the moment 
    865871  memset(outdata, 0, outlen); 
    866872  return -1; 
     873*/ 
     874 
     875  if ( roar_buffer_new(&bufbuf, buflen) == -1 ) 
     876   return -1; 
     877 
     878  if ( roar_buffer_get_data(bufbuf, &bufdata) == -1 ) 
     879   return -1; 
    867880 } else { 
    868   indata = outdata; 
     881  indata  = outdata; 
     882  bufdata = outdata; 
    869883 } 
    870884 
     
    896910 } else { 
    897911  if ( roar_conv(outdata, indata, (8*inlen_got*info->rate)/(stream_info->rate * stream_info->bits), stream_info, info) == -1 ) { 
     912   if ( bufbuf != NULL ) 
     913    roar_buffer_free(bufbuf); 
    898914   return -1; 
    899915  } 
    900916 
    901917//  memset(outdata, 0, outlen); 
     918 } 
     919 
     920 if ( bufbuf != NULL ) { 
     921  memcpy(outdata, bufdata, outlen); 
     922  roar_buffer_free(bufbuf); 
    902923 } 
    903924 
Note: See TracChangeset for help on using the changeset viewer.