[0] | 1 | //sources.c: |
---|
| 2 | |
---|
[668] | 3 | /* |
---|
[4708] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011 |
---|
[668] | 5 | * |
---|
| 6 | * This file is part of roard a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[668] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
[0] | 26 | #include "roard.h" |
---|
| 27 | |
---|
[2485] | 28 | #ifndef ROAR_WITHOUT_DCOMP_SOURCES |
---|
| 29 | |
---|
[5194] | 30 | static int g_source_client = -1; |
---|
| 31 | |
---|
[3061] | 32 | #define ROAR_SOURCE_DEFAULT "cf" |
---|
| 33 | |
---|
[2270] | 34 | struct roar_source g_source[] = { |
---|
[5242] | 35 | {"raw", "DSTR source", "/some/file", SRC_FLAG_FHSEC, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_dstr}, |
---|
[2275] | 36 | {"cf", "Old CF source", "/some/file.ext", SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, sources_add_cf, NULL}, |
---|
[4919] | 37 | {"roar", "New simple RoarAudio source", "some.host", SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_roar}, |
---|
[2507] | 38 | #ifndef ROAR_WITHOUT_DCOMP_CDRIVER |
---|
[2286] | 39 | {"oss", "OSS CDriver", "/dev/audio", SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_cdriver}, |
---|
[2507] | 40 | #endif |
---|
[4807] | 41 | {"radionoise", "Noise source at -102dB", NULL, SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_radionoise}, |
---|
[2269] | 42 | {NULL, NULL, NULL, SRC_FLAG_NONE, 0, NULL, NULL} // EOL |
---|
| 43 | }; |
---|
| 44 | |
---|
[0] | 45 | int sources_init (void) { |
---|
| 46 | return 0; |
---|
| 47 | } |
---|
| 48 | |
---|
[2270] | 49 | void print_sourcelist (void) { |
---|
| 50 | int i; |
---|
| 51 | char subsys[7] = " "; |
---|
| 52 | |
---|
[4807] | 53 | printf(" Source Flag Subsys - Description (devices)\n"); |
---|
| 54 | printf("-------------------------------------------------------\n"); |
---|
[2270] | 55 | |
---|
| 56 | for (i = 0; g_source[i].name != NULL; i++) { |
---|
| 57 | strncpy(subsys, " ", 6); |
---|
| 58 | |
---|
| 59 | if ( g_source[i].subsystems & ROAR_SUBSYS_WAVEFORM ) |
---|
| 60 | subsys[0] = 'W'; |
---|
| 61 | if ( g_source[i].subsystems & ROAR_SUBSYS_MIDI ) |
---|
| 62 | subsys[1] = 'M'; |
---|
| 63 | if ( g_source[i].subsystems & ROAR_SUBSYS_CB ) |
---|
| 64 | subsys[2] = 'C'; |
---|
| 65 | if ( g_source[i].subsystems & ROAR_SUBSYS_LIGHT ) |
---|
| 66 | subsys[3] = 'L'; |
---|
| 67 | if ( g_source[i].subsystems & ROAR_SUBSYS_RAW ) |
---|
| 68 | subsys[4] = 'R'; |
---|
[2681] | 69 | if ( g_source[i].subsystems & ROAR_SUBSYS_COMPLEX ) |
---|
| 70 | subsys[5] = 'X'; |
---|
[2270] | 71 | |
---|
[4807] | 72 | if ( g_source[i].devices != NULL ) { |
---|
| 73 | printf(" %-10s %c%c%c %6s - %s (devices: %s)\n", g_source[i].name, |
---|
| 74 | g_source[i].flags & SRC_FLAG_FHSEC ? 's' : ' ', |
---|
| 75 | g_source[i].old_open != NULL ? 'S' : ' ', |
---|
| 76 | g_source[i].new_open != NULL ? 'N' : ' ', |
---|
| 77 | subsys, |
---|
| 78 | g_source[i].desc, g_source[i].devices); |
---|
| 79 | } else { |
---|
| 80 | printf(" %-9s %c%c%c %6s - %s\n", g_source[i].name, |
---|
| 81 | g_source[i].flags & SRC_FLAG_FHSEC ? 's' : ' ', |
---|
| 82 | g_source[i].old_open != NULL ? 'S' : ' ', |
---|
| 83 | g_source[i].new_open != NULL ? 'N' : ' ', |
---|
| 84 | subsys, |
---|
| 85 | g_source[i].desc); |
---|
| 86 | } |
---|
[2270] | 87 | } |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
[64] | 91 | int sources_set_client (int client) { |
---|
| 92 | if ( client >= 0 ) { |
---|
| 93 | g_source_client = client; |
---|
| 94 | return 0; |
---|
| 95 | } else { |
---|
| 96 | return -1; |
---|
| 97 | } |
---|
| 98 | } |
---|
[0] | 99 | |
---|
| 100 | int sources_free (void) { |
---|
| 101 | return 0; |
---|
| 102 | } |
---|
| 103 | |
---|
[65] | 104 | int sources_add (char * driver, char * device, char * container, char * options, int primary) { |
---|
[2272] | 105 | int i; |
---|
| 106 | |
---|
[3061] | 107 | if ( driver == NULL ) |
---|
| 108 | driver = ROAR_SOURCE_DEFAULT; |
---|
| 109 | |
---|
[2272] | 110 | for (i = 0; g_source[i].name != NULL; i++) { |
---|
| 111 | if ( !strcmp(g_source[i].name, driver) ) { |
---|
| 112 | if ( g_source[i].new_open != NULL ) { |
---|
[2273] | 113 | return sources_add_new(&(g_source[i]), driver, device, container, options, primary); |
---|
[2272] | 114 | } else if ( g_source[i].old_open != NULL ) { |
---|
| 115 | return g_source[i].old_open(driver, device, container, options, primary); |
---|
| 116 | } else { |
---|
| 117 | ROAR_ERR("sources_add(driver='%s', ...): Found source but did not find any open rutine", driver); |
---|
| 118 | return -1; |
---|
| 119 | } |
---|
| 120 | } |
---|
[67] | 121 | } |
---|
[65] | 122 | |
---|
[2272] | 123 | ROAR_ERR("sources_add(driver='%s', ...): Source not found", driver); |
---|
[0] | 124 | return -1; |
---|
| 125 | } |
---|
| 126 | |
---|
[2273] | 127 | int sources_add_new (struct roar_source * source, |
---|
| 128 | char * driver, char * device, |
---|
| 129 | char * container, |
---|
| 130 | char * options, int primary) { |
---|
[2274] | 131 | int stream; |
---|
| 132 | int fh = -1; |
---|
| 133 | struct roar_stream * s; |
---|
| 134 | struct roar_stream_server * ss; |
---|
| 135 | char * k, * v; |
---|
| 136 | int error = 0; |
---|
| 137 | int f_sync = 0, f_mmap = 0; |
---|
| 138 | int codec; |
---|
[5210] | 139 | char * strtok_store; |
---|
[2274] | 140 | |
---|
| 141 | if ( source == NULL ) |
---|
| 142 | return -1; |
---|
| 143 | |
---|
| 144 | if ( (stream = streams_new()) == -1 ) { |
---|
| 145 | return -1; |
---|
| 146 | } |
---|
| 147 | |
---|
[4807] | 148 | if ( streams_get(stream, &ss) == -1 ) { |
---|
| 149 | streams_delete(stream); |
---|
| 150 | return -1; |
---|
| 151 | } |
---|
| 152 | |
---|
[2274] | 153 | s = ROAR_STREAM(ss); |
---|
| 154 | |
---|
| 155 | memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info)); |
---|
| 156 | |
---|
[2275] | 157 | codec = s->info.codec; |
---|
| 158 | |
---|
[2274] | 159 | if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) { |
---|
| 160 | streams_delete(stream); |
---|
| 161 | return -1; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | s->pos_rel_id = -1; |
---|
| 165 | |
---|
[5246] | 166 | if ( options == NULL ) { |
---|
| 167 | k = NULL; |
---|
| 168 | } else { |
---|
| 169 | k = roar_mm_strtok_r(options, ",", &strtok_store); |
---|
| 170 | } |
---|
[2274] | 171 | while (k != NULL) { |
---|
| 172 | if ( (v = strstr(k, "=")) != NULL ) { |
---|
| 173 | *v++ = 0; |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | if ( strcmp(k, "rate") == 0 ) { |
---|
[4920] | 177 | s->info.rate = roar_str2rate(v); |
---|
[2274] | 178 | } else if ( strcmp(k, "channels") == 0 ) { |
---|
[4920] | 179 | s->info.channels = roar_str2channels(v); |
---|
[2274] | 180 | } else if ( strcmp(k, "bits") == 0 ) { |
---|
[4920] | 181 | s->info.bits = roar_str2bits(v); |
---|
[2274] | 182 | } else if ( strcmp(k, "codec") == 0 ) { |
---|
| 183 | if ( (codec = roar_str2codec(v)) == -1 ) { |
---|
| 184 | ROAR_ERR("sources_add_new(*): unknown codec '%s'", v); |
---|
| 185 | error++; |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | } else if ( strcmp(k, "name") == 0 ) { |
---|
| 189 | if ( streams_set_name(stream, v) == -1 ) { |
---|
| 190 | ROAR_ERR("add_output(*): Can not set Stream name"); |
---|
| 191 | error++; |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | } else if ( strcmp(k, "mmap") == 0 ) { |
---|
| 195 | f_mmap = 1; |
---|
| 196 | } else if ( strcmp(k, "sync") == 0 ) { |
---|
| 197 | f_sync = 1; |
---|
| 198 | } else if ( strcmp(k, "primary") == 0 ) { |
---|
| 199 | primary = 1; |
---|
| 200 | } else if ( strcmp(k, "meta") == 0 ) { |
---|
| 201 | streams_set_flag(stream, ROAR_FLAG_META); |
---|
| 202 | } else if ( strcmp(k, "cleanmeta") == 0 ) { |
---|
| 203 | streams_set_flag(stream, ROAR_FLAG_CLEANMETA); |
---|
| 204 | } else if ( strcmp(k, "autoconf") == 0 ) { |
---|
| 205 | streams_set_flag(stream, ROAR_FLAG_AUTOCONF); |
---|
| 206 | |
---|
| 207 | } else { |
---|
| 208 | ROAR_ERR("sources_add_new(*): unknown option '%s'", k); |
---|
| 209 | error++; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | if ( error ) { |
---|
| 213 | streams_delete(stream); |
---|
| 214 | if ( primary ) alive = 0; |
---|
| 215 | return -1; |
---|
| 216 | } |
---|
| 217 | |
---|
[5210] | 218 | k = roar_mm_strtok_r(NULL, ",", &strtok_store); |
---|
[2274] | 219 | } |
---|
| 220 | |
---|
| 221 | if ( primary ) |
---|
| 222 | streams_mark_primary(stream); |
---|
| 223 | |
---|
| 224 | streams_set_flag(stream, ROAR_FLAG_SOURCE); |
---|
| 225 | client_stream_add(g_source_client, stream); |
---|
| 226 | |
---|
[2275] | 227 | if ( codec == ROAR_CODEC_ALAW || codec == ROAR_CODEC_MULAW ) |
---|
| 228 | s->info.bits = 8; // needed to open OSS driver, will be overriden by codecfilter |
---|
| 229 | |
---|
| 230 | s->info.codec = codec; |
---|
| 231 | ROAR_STREAM_SERVER(s)->codec_orgi = codec; |
---|
| 232 | |
---|
[2285] | 233 | if ( source->new_open(stream, device, fh, driver) == -1 ) { |
---|
[2274] | 234 | streams_delete(stream); |
---|
| 235 | return -1; |
---|
| 236 | } |
---|
| 237 | |
---|
[5162] | 238 | _LIBROAR_IGNORE_RET(roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAMID, &stream)); // ignore errors here |
---|
| 239 | _LIBROAR_IGNORE_RET(roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAM, s)); // ignore errors here |
---|
[2274] | 240 | |
---|
| 241 | if ( f_sync ) { |
---|
| 242 | streams_set_flag(stream, ROAR_FLAG_SYNC); |
---|
| 243 | } else { |
---|
| 244 | streams_reset_flag(stream, ROAR_FLAG_SYNC); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | if ( f_mmap ) |
---|
| 248 | streams_set_flag(stream, ROAR_FLAG_MMAP); |
---|
| 249 | |
---|
| 250 | return 0; |
---|
[2273] | 251 | } |
---|
| 252 | |
---|
[5242] | 253 | int sources_add_dstr (int stream , const char * device, int fh, const char * driver) { |
---|
[2275] | 254 | struct roar_stream_server * ss; |
---|
[5242] | 255 | struct roar_vio_defaults def; |
---|
| 256 | |
---|
| 257 | if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 ) |
---|
| 258 | return -1; |
---|
[566] | 259 | |
---|
[2275] | 260 | streams_get(stream, &ss); |
---|
[1609] | 261 | |
---|
[5162] | 262 | if ( fh > -1 ) { |
---|
| 263 | if ( roar_vio_open_fh(&(ss->vio), fh) == -1 ) |
---|
| 264 | return -1; |
---|
| 265 | } else { |
---|
[5242] | 266 | if ( roar_vio_open_dstr(&(ss->vio), device, &def, 1) == -1 ) |
---|
[5162] | 267 | return -1; |
---|
| 268 | } |
---|
[65] | 269 | |
---|
[2275] | 270 | return streams_set_fh(stream, -2); |
---|
[65] | 271 | } |
---|
| 272 | |
---|
[1614] | 273 | #define _ret(x) streams_delete(stream); return (x) |
---|
[542] | 274 | |
---|
[5242] | 275 | int sources_add_cf (const char * driver, const char * device, const char * container, const char * options, int primary) { |
---|
[555] | 276 | int stream; |
---|
| 277 | int codec; |
---|
| 278 | int len; |
---|
| 279 | char buf[64]; |
---|
[1499] | 280 | struct roar_stream * s; |
---|
| 281 | struct roar_vio_calls * vio; |
---|
[1614] | 282 | struct roar_vio_defaults def; |
---|
| 283 | |
---|
| 284 | if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 ) |
---|
| 285 | return -1; |
---|
[555] | 286 | |
---|
[542] | 287 | if ( (stream = streams_new()) == -1 ) { |
---|
| 288 | return -1; |
---|
| 289 | } |
---|
| 290 | |
---|
[4521] | 291 | streams_get_clientobj(stream, &s); |
---|
[542] | 292 | |
---|
| 293 | memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info)); |
---|
| 294 | |
---|
[1609] | 295 | if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) { |
---|
| 296 | streams_delete(stream); |
---|
| 297 | return -1; |
---|
| 298 | } |
---|
| 299 | |
---|
[542] | 300 | s->pos_rel_id = -1; |
---|
[1499] | 301 | |
---|
| 302 | /* |
---|
| 303 | if ( (fh = open(device, O_RDONLY, 0644)) == -1 ) { |
---|
| 304 | return -1; |
---|
| 305 | } |
---|
| 306 | */ |
---|
| 307 | |
---|
| 308 | vio = &(ROAR_STREAM_SERVER(s)->vio); |
---|
| 309 | |
---|
[1614] | 310 | //if ( roar_vio_open_file(vio, device, O_RDONLY, 0644) == -1 ) { |
---|
| 311 | if ( roar_vio_open_dstr(vio, device, &def, 1) == -1 ) { |
---|
[4964] | 312 | roar_vio_clear_calls(vio); // clear the VIO object again |
---|
[4419] | 313 | // from things roar_vio_open_dstr() left. |
---|
[1499] | 314 | _ret(-1); |
---|
| 315 | } |
---|
| 316 | |
---|
[1614] | 317 | ROAR_DBG("sources_add_cf(*) = ?"); |
---|
| 318 | |
---|
[5242] | 319 | // TODO: find out a better way of doing auto detetion without need for seek! |
---|
[1499] | 320 | if ( options == NULL ) { |
---|
| 321 | if ( (len = roar_vio_read(vio, buf, 64)) < 1 ) { |
---|
| 322 | _ret(-1); |
---|
| 323 | } |
---|
| 324 | |
---|
[5278] | 325 | if ( roar_vio_lseek(vio, -len, SEEK_CUR) == (roar_off_t)-1 ) { |
---|
[1499] | 326 | _ret(-1); |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | if ( (codec = roar_file_codecdetect(buf, len)) == -1 ) { |
---|
| 330 | _ret(-1); |
---|
| 331 | } |
---|
| 332 | } else { |
---|
| 333 | if ( !strncmp(options, "codec=", 6) ) |
---|
| 334 | options += 6; |
---|
| 335 | |
---|
| 336 | if ( (codec = roar_str2codec(options)) == -1 ) { |
---|
| 337 | _ret(-1); |
---|
| 338 | } |
---|
| 339 | } |
---|
| 340 | |
---|
[542] | 341 | s->info.codec = codec; |
---|
| 342 | |
---|
[566] | 343 | ROAR_STREAM_SERVER(s)->codec_orgi = codec; |
---|
| 344 | |
---|
[1614] | 345 | ROAR_DBG("sources_add_cf(*) = ?"); |
---|
[1504] | 346 | streams_set_fh(stream, -2); |
---|
[1614] | 347 | ROAR_DBG("sources_add_cf(*) = ?"); |
---|
[644] | 348 | streams_set_socktype(stream, ROAR_SOCKET_TYPE_FILE); |
---|
| 349 | |
---|
| 350 | if ( primary ) |
---|
| 351 | streams_mark_primary(stream); |
---|
[542] | 352 | |
---|
[1031] | 353 | streams_set_flag(stream, ROAR_FLAG_SOURCE); |
---|
[542] | 354 | client_stream_add(g_source_client, stream); |
---|
| 355 | |
---|
| 356 | return 0; |
---|
| 357 | } |
---|
| 358 | |
---|
[1499] | 359 | #undef _ret |
---|
| 360 | |
---|
[2507] | 361 | #ifndef ROAR_WITHOUT_DCOMP_CDRIVER |
---|
[5242] | 362 | int sources_add_cdriver (int stream , const char * device, int fh, const char * driver) { |
---|
[2286] | 363 | struct roar_stream_server * ss; |
---|
| 364 | |
---|
| 365 | if ( fh > -1 ) |
---|
| 366 | return -1; |
---|
| 367 | |
---|
[4807] | 368 | if ( streams_get(stream, &ss) == -1 ) |
---|
| 369 | return -1; |
---|
[2286] | 370 | |
---|
| 371 | if ( !strncmp(driver, "cdriver:", 8) ) |
---|
| 372 | driver += 8; |
---|
| 373 | |
---|
[2290] | 374 | ROAR_DBG("sources_add_cdriver(stream=%i, device='%s', fh=%i, driver='%s') = ?", stream, device, fh, driver); |
---|
| 375 | |
---|
[2286] | 376 | if ( roar_cdriver_open(&(ss->vio), driver, device, &(ROAR_STREAM(ss)->info), ROAR_DIR_RECORD) == -1 ) |
---|
| 377 | return -1; |
---|
| 378 | |
---|
| 379 | return streams_set_fh(stream, -2); |
---|
| 380 | } |
---|
[2507] | 381 | #endif |
---|
[2286] | 382 | |
---|
[4807] | 383 | static ssize_t sources_radionoise_read (struct roar_vio_calls * vio, void *buf, size_t count) { |
---|
| 384 | int32_t * pcm = buf; |
---|
| 385 | int16_t noise; |
---|
| 386 | size_t len, i; |
---|
| 387 | |
---|
| 388 | ROAR_DBG("sources_radionoise_read(vio=%p, buf=%p, count=%llu) = 0", vio, buf, (long long unsigned int)count); |
---|
| 389 | |
---|
| 390 | // ensure size is a multiple of 4. |
---|
| 391 | count -= count & 0x03LLU; |
---|
| 392 | |
---|
| 393 | if ( count == 0 ) |
---|
| 394 | return 0; |
---|
| 395 | |
---|
| 396 | if ( buf == NULL ) |
---|
| 397 | return -1; |
---|
| 398 | |
---|
| 399 | roar_random_gen_nonce(buf, count); |
---|
| 400 | |
---|
| 401 | len = count / 4; |
---|
| 402 | |
---|
| 403 | for (i = 0; i < len; i++) { |
---|
| 404 | noise = pcm[i] & 0xFFFF; |
---|
| 405 | pcm[i] = ((int32_t)noise << 16) >> 17; |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | ROAR_DBG("sources_radionoise_read(vio=%p, buf=%p, count=?) = %llu", vio, buf, (long long unsigned int)count); |
---|
| 409 | return count; |
---|
| 410 | } |
---|
| 411 | |
---|
| 412 | static int sources_radionoise_return_zero (struct roar_vio_calls * vio) { |
---|
| 413 | (void)vio; |
---|
| 414 | |
---|
| 415 | ROAR_DBG("sources_radionoise_return_zero(vio=%p) = 0", vio); |
---|
| 416 | |
---|
| 417 | return 0; |
---|
| 418 | } |
---|
| 419 | |
---|
[5278] | 420 | static int sources_radionoise_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) { |
---|
[5276] | 421 | if ( cmd == ROAR_VIO_CTL_NONBLOCK ) |
---|
| 422 | return 0; |
---|
| 423 | |
---|
| 424 | roar_err_set(ROAR_ERROR_BADRQC); |
---|
| 425 | return -1; |
---|
| 426 | } |
---|
| 427 | |
---|
[5242] | 428 | int sources_add_radionoise (int stream, const char * device, int fh, const char * driver) { |
---|
[4807] | 429 | struct roar_stream_server * ss; |
---|
| 430 | struct roar_audio_info * info; |
---|
| 431 | |
---|
| 432 | if ( fh > -1 ) |
---|
| 433 | return -1; |
---|
| 434 | |
---|
| 435 | if ( streams_get(stream, &ss) == -1 ) |
---|
| 436 | return -1; |
---|
| 437 | |
---|
| 438 | info = &(ROAR_STREAM(ss)->info); |
---|
| 439 | |
---|
| 440 | info->codec = ROAR_CODEC_DEFAULT; |
---|
| 441 | info->bits = 32; |
---|
| 442 | |
---|
| 443 | memset(&(ss->vio), 0, sizeof(struct roar_vio_calls)); |
---|
| 444 | ss->vio.read = sources_radionoise_read; |
---|
| 445 | ss->vio.close = sources_radionoise_return_zero; |
---|
| 446 | ss->vio.sync = sources_radionoise_return_zero; |
---|
[5276] | 447 | ss->vio.ctl = sources_radionoise_ctl; |
---|
[4807] | 448 | |
---|
| 449 | return streams_set_fh(stream, -2); |
---|
| 450 | } |
---|
| 451 | |
---|
[5242] | 452 | int sources_add_roar (int stream, const char * device, int fh, const char * driver) { |
---|
[4919] | 453 | struct roar_stream_server * ss; |
---|
| 454 | struct roar_stream * s; |
---|
| 455 | |
---|
| 456 | if ( fh > -1 ) |
---|
| 457 | return -1; |
---|
| 458 | |
---|
| 459 | if ( streams_get(stream, &ss) == -1 ) |
---|
| 460 | return -1; |
---|
| 461 | |
---|
| 462 | s = ROAR_STREAM(ss); |
---|
| 463 | |
---|
| 464 | if ( roar_vio_simple_stream(&(ss->vio), s->info.rate, s->info.channels, s->info.bits, s->info.codec, |
---|
[5289] | 465 | device, ROAR_DIR_MONITOR, "roard", -1) == -1 ) |
---|
[4919] | 466 | return -1; |
---|
| 467 | |
---|
| 468 | return streams_set_fh(stream, -2); |
---|
| 469 | } |
---|
| 470 | |
---|
[2485] | 471 | #endif |
---|
| 472 | |
---|
[0] | 473 | //ll |
---|