Changeset 2274:751c834d9763 in roaraudio


Ignore:
Timestamp:
08/04/09 13:25:39 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

started with all basic operations for a new source

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/sources.c

    r2273 r2274  
    108108                     char * container, 
    109109                     char * options, int primary) { 
    110  return -1; 
     110 int  stream; 
     111 int  fh = -1; 
     112 struct roar_stream        *  s; 
     113 struct roar_stream_server * ss; 
     114 char * k, * v; 
     115 int error = 0; 
     116 int f_sync = 0, f_mmap = 0; 
     117 int codec; 
     118 
     119 if ( source == NULL ) 
     120  return -1; 
     121 
     122 if ( (stream = streams_new()) == -1 ) { 
     123  return -1; 
     124 } 
     125 
     126 streams_get(stream, &ss); 
     127 s = ROAR_STREAM(ss); 
     128 
     129 memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info)); 
     130 
     131 if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) { 
     132  streams_delete(stream); 
     133  return -1; 
     134 } 
     135 
     136 s->pos_rel_id = -1; 
     137 
     138 k = strtok(options, ","); 
     139 while (k != NULL) { 
     140  if ( (v = strstr(k, "=")) != NULL ) { 
     141   *v++ = 0; 
     142  } 
     143 
     144  if ( strcmp(k, "rate") == 0 ) { 
     145   s->info.rate = atoi(v); 
     146  } else if ( strcmp(k, "channels") == 0 ) { 
     147   s->info.channels = atoi(v); 
     148  } else if ( strcmp(k, "bits") == 0 ) { 
     149   s->info.bits = atoi(v); 
     150  } else if ( strcmp(k, "codec") == 0 ) { 
     151   if ( (codec = roar_str2codec(v)) == -1 ) { 
     152    ROAR_ERR("sources_add_new(*): unknown codec '%s'", v); 
     153    error++; 
     154   } 
     155 
     156  } else if ( strcmp(k, "name") == 0 ) { 
     157   if ( streams_set_name(stream, v) == -1 ) { 
     158    ROAR_ERR("add_output(*): Can not set Stream name"); 
     159    error++; 
     160   } 
     161 
     162  } else if ( strcmp(k, "mmap") == 0 ) { 
     163   f_mmap = 1; 
     164  } else if ( strcmp(k, "sync") == 0 ) { 
     165   f_sync = 1; 
     166  } else if ( strcmp(k, "primary") == 0 ) { 
     167   primary = 1; 
     168  } else if ( strcmp(k, "meta") == 0 ) { 
     169   streams_set_flag(stream, ROAR_FLAG_META); 
     170  } else if ( strcmp(k, "cleanmeta") == 0 ) { 
     171   streams_set_flag(stream, ROAR_FLAG_CLEANMETA); 
     172  } else if ( strcmp(k, "autoconf") == 0 ) { 
     173   streams_set_flag(stream, ROAR_FLAG_AUTOCONF); 
     174 
     175  } else { 
     176   ROAR_ERR("sources_add_new(*): unknown option '%s'", k); 
     177   error++; 
     178  } 
     179 
     180  if ( error ) { 
     181   streams_delete(stream); 
     182   if ( primary ) alive = 0; 
     183   return -1; 
     184  } 
     185 
     186  k = strtok(NULL, ","); 
     187 } 
     188 
     189 if ( primary ) 
     190  streams_mark_primary(stream); 
     191 
     192 streams_set_flag(stream, ROAR_FLAG_SOURCE); 
     193 client_stream_add(g_source_client, stream); 
     194 
     195 if ( source->new_open(stream, device, fh) == -1 ) { 
     196  streams_delete(stream); 
     197  return -1; 
     198 } 
     199 
     200 roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAMID, &stream); // ignore errors here 
     201 roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAM,   s); // ignore errors here 
     202 
     203 if ( f_sync ) { 
     204  streams_set_flag(stream, ROAR_FLAG_SYNC); 
     205 } else { 
     206  streams_reset_flag(stream, ROAR_FLAG_SYNC); 
     207 } 
     208 
     209 if ( f_mmap ) 
     210  streams_set_flag(stream, ROAR_FLAG_MMAP); 
     211 
     212 return 0; 
    111213} 
    112214 
Note: See TracChangeset for help on using the changeset viewer.