Changeset 2061:a9543462cad6 in roaraudio


Ignore:
Timestamp:
07/08/09 02:55:31 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

started with a new mixbuffer filler: streams_fill_mixbuffer2()

Location:
roard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roard/include/streams.h

    r1928 r2061  
    112112int stream_add_buffer     (int id, struct roar_buffer *  buf); 
    113113//int stream_get_buffer     (int id, struct roar_buffer ** buf); 
     114int stream_shift_out_buffer   (int id, void * data, size_t * len); 
    114115int stream_shift_buffer   (int id, struct roar_buffer ** buf); 
    115116int stream_unshift_buffer (int id, struct roar_buffer *  buf); 
     
    122123int streams_get_outputbuffer (int id, void ** buffer, size_t size); 
    123124int streams_fill_mixbuffer   (int id, struct roar_audio_info * info); 
     125int streams_fill_mixbuffer2  (int id, struct roar_audio_info * info); 
    124126 
    125127ssize_t stream_vio_read (int stream, void *buf, size_t count); 
  • roard/streams.c

    r2021 r2061  
    821821} 
    822822 
     823int streams_fill_mixbuffer2 (int id, struct roar_audio_info * info) { 
     824 size_t   outlen = ROAR_OUTPUT_CALC_OUTBUFSIZE(info); 
     825 void   * outdata; 
     826 size_t   inlen; 
     827 size_t   inlen_got; 
     828 void   * indata = NULL; 
     829 int      is_the_same = 0; 
     830 struct roar_audio_info    * stream_info; 
     831 struct roar_stream        * s; 
     832 struct roar_stream_server * ss; 
     833 
     834 if ( (s = ROAR_STREAM(ss = g_streams[id])) == NULL ) 
     835  return -1; 
     836 
     837 // set up stream_info 
     838 stream_info = &(s->info); 
     839 
     840 // calc todo_in 
     841 inlen = ROAR_OUTPUT_CALC_OUTBUFSIZE(stream_info); 
     842 
     843 if ( inlen == 0 ) { 
     844  ROAR_WARN("streams_fill_mixbuffer2(id=%i, info=%p{...}): inlen == 0, this should not happen!", id, info); 
     845  return -1; 
     846 } 
     847 
     848 if ( streams_get_outputbuffer(id, &outdata, outlen) == -1 ) { 
     849  return -1; 
     850 } 
     851 
     852 if ( outdata == NULL ) { 
     853  return -1; 
     854 } 
     855 
     856 ROAR_DBG("streams_fill_mixbuffer2(*): outdata=%p, len=%i->%i (in->out)", outdata, inlen, outlen); 
     857 
     858 is_the_same = stream_info->rate     == info->rate     && stream_info->bits  == info->bits && 
     859               stream_info->channels == info->channels && stream_info->codec == info->codec; 
     860 
     861 ROAR_DBG("streams_fill_mixbuffer2(*): is_the_same=%i", is_the_same); 
     862 
     863 if ( inlen > outlen ) { 
     864  // this is not supported at the moment 
     865  memset(outdata, 0, outlen); 
     866  return -1; 
     867 } else { 
     868  indata = outdata; 
     869 } 
     870 
     871 inlen_got = inlen; 
     872 
     873 if ( stream_shift_out_buffer(id, indata, &inlen_got) == -1 ) { 
     874  if ( ss->is_new ) { 
     875   ss->pre_underruns++; 
     876  } else { 
     877   ROAR_WARN("streams_fill_mixbuffer2(id=%i info=...): underrun in stream", id); 
     878   ss->post_underruns++; 
     879  } 
     880  memset(outdata, 0, outlen); 
     881  return 0; 
     882 } 
     883 
     884 if ( ss->is_new ) { 
     885  ROAR_WARN("streams_fill_mixbuffer2(id=%i info=...): stream state: new->old", id); 
     886 } 
     887 
     888 ss->is_new = 0; 
     889 
     890 if ( is_the_same ) { 
     891  if ( indata != outdata ) 
     892   memcpy(outdata, indata, inlen); 
     893 
     894  if ( inlen < outlen ) 
     895   memset(outdata+inlen, 0, outlen-inlen); 
     896 
     897  return 0; 
     898 } else { 
     899  memset(outdata, 0, outlen); 
     900 } 
     901 
     902 return -1; 
     903} 
     904 
    823905 
    824906int streams_get_mixbuffers (void *** bufferlist, struct roar_audio_info * info, unsigned int pos) { 
     
    837919    continue; 
    838920   } 
    839    if ( streams_fill_mixbuffer(i, info) == -1 ) { 
     921   if ( streams_fill_mixbuffer2(i, info) == -1 ) { 
    840922    ROAR_ERR("streams_get_mixbuffer(*): Can not fill output buffer for stream %i, this should not happen", i); 
    841923    continue; 
     
    876958 ROAR_DBG("stream_add_buffer(id=%i, buf=%p) = ?", id, buf); 
    877959 return roar_buffer_add(g_streams[id]->buffer, buf); 
     960} 
     961 
     962int stream_shift_out_buffer   (int id, void * data, size_t * len) { 
     963 if ( g_streams[id] == NULL ) 
     964  return -1; 
     965 
     966 if ( g_streams[id]->buffer == NULL ) 
     967  return -1; 
     968 
     969 return roar_buffer_shift_out(&(g_streams[id]->buffer), data, len); 
    878970} 
    879971 
Note: See TracChangeset for help on using the changeset viewer.