Changeset 4543:14019152e072 in roaraudio


Ignore:
Timestamp:
10/24/10 13:50:12 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

implemented some very basic single sink mode, corrected streams_get_mixer_stream()

Location:
roard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roard/include/streams.h

    r4541 r4543  
    130130 
    131131int streams_set_mixer_stream(int id, int mixer); 
    132 int streams_get_mixer_stream(int id, int mixer); 
     132int streams_get_mixer_stream(int id); 
    133133 
    134134int streams_set_role   (int id, int role); 
  • roard/streams.c

    r4542 r4543  
    321321int streams_set_dir    (int id, int dir, int defaults) { 
    322322 struct roar_stream_server * ss; 
     323 int mixer; 
    323324 
    324325 _CHECK_SID(id); 
     
    367368  } 
    368369 
     370  if ( (mixer = streams_get_mixer_stream(id)) != -1 ) { 
     371   if ( g_streams[mixer]->flags & ROAR_FLAG_SINGLESINK ) { 
     372    streams_set_mixer_stream(id, -1); 
     373    return -1; 
     374   } 
     375  } 
     376 
    369377  memcpy(ss->chanmap.out, ss->chanmap.in, sizeof(ss->chanmap.out)); 
    370378  streams_set_map(id, NULL, 0); 
     
    401409} 
    402410 
    403 int streams_get_mixer_stream(int id, int mixer) { 
     411int streams_get_mixer_stream(int id) { 
    404412 struct roar_stream_server * ss; 
    405413 
     
    778786 
    779787int streams_set_single_sink(int id, int reset) { 
    780  _CHECK_SID(id); 
    781  
    782  return -1; 
     788 struct roar_stream_server * self_ss, * ss; 
     789 struct roar_stream                   *  s; 
     790 int mixer; 
     791 size_t count = 0; 
     792 int i; 
     793 int ssdir; 
     794 
     795 /* FIXME: This code only uses one refc for the mixer shared with the inputs. 
     796  *        If the flag is unset on the mixer but got set by the sources the counter 
     797  *        may/will become corrupted. 
     798  * 
     799  * TODO:  If a stream is deleted and this flag is set this rutine must be called to 
     800  *        maintain a correct count. 
     801  */ 
     802 
     803 _CHECK_SID(id); 
     804 
     805 self_ss = g_streams[id]; 
     806 
     807 mixer = self_ss->mixer_stream; 
     808 
     809 if ( id == mixer ) { 
     810  if ( reset ) { 
     811   if ( self_ss->single_sink_c > 1 ) { 
     812    self_ss->single_sink_c--; 
     813    self_ss->flags |= ROAR_FLAG_SINGLESINK; 
     814    self_ss->flags -= ROAR_FLAG_SINGLESINK; 
     815    return 0; 
     816   } 
     817  } else { 
     818   if ( self_ss->single_sink_c ) { 
     819    self_ss->single_sink_c++; 
     820    return 0; 
     821   } 
     822  } 
     823 } else if ( reset ) { 
     824  if ( (ss = g_streams[mixer])->single_sink_c == 0 ) 
     825   return -1; 
     826  ss->single_sink_c--; 
     827 
     828  if ( ss->single_sink_c == 0 ) { 
     829    self_ss->flags |= ROAR_FLAG_SINGLESINK; 
     830    self_ss->flags -= ROAR_FLAG_SINGLESINK; 
     831         ss->flags |= ROAR_FLAG_SINGLESINK; 
     832         ss->flags -= ROAR_FLAG_SINGLESINK; 
     833  } 
     834 
     835  return 0; 
     836 } 
     837 
     838 
     839 
     840 for (i = 0; i < ROAR_STREAMS_MAX; i++) { 
     841  if ( (s = ROAR_STREAM((ss = g_streams[i]))) != NULL ) { 
     842   if ( s->dir == ROAR_DIR_THRU ) 
     843    if ( s->pos_rel_id == id || s->pos_rel_id == mixer ) 
     844     return -1; 
     845 
     846   if ( ss->mixer_stream != mixer ) 
     847    continue; 
     848 
     849   ssdir = streams_get_ssdir(i); 
     850 
     851   if ( ssdir & STREAM_DIR_OUT ) { 
     852    count++; 
     853    if ( streams_thru_num ) { 
     854     return -1; 
     855    } 
     856   } 
     857  } 
     858 } 
     859 
     860 if ( count > 1 ) 
     861  return -1; 
     862 
     863 ss = g_streams[mixer]; 
     864 
     865 ss->single_sink_c++; 
     866 
     867 self_ss->flags |= ROAR_FLAG_SINGLESINK; 
     868      ss->flags |= ROAR_FLAG_SINGLESINK; 
     869 
     870 return 0; 
    783871} 
    784872 
Note: See TracChangeset for help on using the changeset viewer.