Changeset 4807:c29f46728c76 in roaraudio
- Timestamp:
- 03/25/11 11:00:32 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r4806 r4807 2 2 * Started with support for non-blocking server locating attempts. 3 3 * Speed up SLP lookup without DA by about 6 sec. 4 * Added source radionoise to roard. This is used to generate low energy noise 5 so codecs do not drop to (near) zero bitrate. 4 6 5 7 v. 0.4beta4 - Sun Mar 20 2011 12:15 CET -
roard/include/sources.h
r4708 r4807 64 64 int sources_add_roar (char * driver, char * device, char * container, char * options, int primary); 65 65 66 int sources_add_radionoise (int stream, char * device, int fh, char * driver); 67 66 68 #ifndef ROAR_WITHOUT_DCOMP_CDRIVER 67 69 int sources_add_cdriver (int stream , char * device, int fh, char * driver); -
roard/sources.c
r4708 r4807 40 40 {"oss", "OSS CDriver", "/dev/audio", SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_cdriver}, 41 41 #endif 42 {"radionoise", "Noise source at -102dB", NULL, SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_radionoise}, 42 43 {NULL, NULL, NULL, SRC_FLAG_NONE, 0, NULL, NULL} // EOL 43 44 }; … … 52 53 char subsys[7] = " "; 53 54 54 printf(" Source Flag Subsys - Description (devices)\n");55 printf("------------------------------------------------------ \n");55 printf(" Source Flag Subsys - Description (devices)\n"); 56 printf("-------------------------------------------------------\n"); 56 57 57 58 for (i = 0; g_source[i].name != NULL; i++) { … … 71 72 subsys[5] = 'X'; 72 73 73 printf(" %-9s %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); 74 if ( g_source[i].devices != NULL ) { 75 printf(" %-10s %c%c%c %6s - %s (devices: %s)\n", g_source[i].name, 76 g_source[i].flags & SRC_FLAG_FHSEC ? 's' : ' ', 77 g_source[i].old_open != NULL ? 'S' : ' ', 78 g_source[i].new_open != NULL ? 'N' : ' ', 79 subsys, 80 g_source[i].desc, g_source[i].devices); 81 } else { 82 printf(" %-9s %c%c%c %6s - %s\n", g_source[i].name, 83 g_source[i].flags & SRC_FLAG_FHSEC ? 's' : ' ', 84 g_source[i].old_open != NULL ? 'S' : ' ', 85 g_source[i].new_open != NULL ? 'N' : ' ', 86 subsys, 87 g_source[i].desc); 88 } 79 89 } 80 90 } … … 137 147 } 138 148 139 streams_get(stream, &ss); 149 if ( streams_get(stream, &ss) == -1 ) { 150 streams_delete(stream); 151 return -1; 152 } 153 140 154 s = ROAR_STREAM(ss); 141 155 … … 441 455 return -1; 442 456 443 streams_get(stream, &ss); 457 if ( streams_get(stream, &ss) == -1 ) 458 return -1; 444 459 445 460 if ( !strncmp(driver, "cdriver:", 8) ) … … 455 470 #endif 456 471 472 static ssize_t sources_radionoise_read (struct roar_vio_calls * vio, void *buf, size_t count) { 473 int32_t * pcm = buf; 474 int16_t noise; 475 size_t len, i; 476 477 ROAR_DBG("sources_radionoise_read(vio=%p, buf=%p, count=%llu) = 0", vio, buf, (long long unsigned int)count); 478 479 // ensure size is a multiple of 4. 480 count -= count & 0x03LLU; 481 482 if ( count == 0 ) 483 return 0; 484 485 if ( buf == NULL ) 486 return -1; 487 488 roar_random_gen_nonce(buf, count); 489 490 len = count / 4; 491 492 for (i = 0; i < len; i++) { 493 noise = pcm[i] & 0xFFFF; 494 pcm[i] = ((int32_t)noise << 16) >> 17; 495 } 496 497 ROAR_DBG("sources_radionoise_read(vio=%p, buf=%p, count=?) = %llu", vio, buf, (long long unsigned int)count); 498 return count; 499 } 500 501 static int sources_radionoise_return_zero (struct roar_vio_calls * vio) { 502 (void)vio; 503 504 ROAR_DBG("sources_radionoise_return_zero(vio=%p) = 0", vio); 505 506 return 0; 507 } 508 509 int sources_add_radionoise (int stream, char * device, int fh, char * driver) { 510 struct roar_stream_server * ss; 511 struct roar_audio_info * info; 512 513 if ( fh > -1 ) 514 return -1; 515 516 if ( streams_get(stream, &ss) == -1 ) 517 return -1; 518 519 info = &(ROAR_STREAM(ss)->info); 520 521 info->codec = ROAR_CODEC_DEFAULT; 522 info->bits = 32; 523 524 memset(&(ss->vio), 0, sizeof(struct roar_vio_calls)); 525 ss->vio.read = sources_radionoise_read; 526 ss->vio.close = sources_radionoise_return_zero; 527 ss->vio.sync = sources_radionoise_return_zero; 528 ss->vio.nonblock = (int (*)(struct roar_vio_calls * vio, int state))sources_radionoise_return_zero; 529 530 return streams_set_fh(stream, -2); 531 } 532 457 533 #endif 458 534
Note: See TracChangeset
for help on using the changeset viewer.