Changeset 4807:c29f46728c76 in roaraudio


Ignore:
Timestamp:
03/25/11 11:00:32 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Added source radionoise to roard. This is used to generate low energy noise so codecs do not drop to (near) zero bitrate.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r4806 r4807  
    22        * Started with support for non-blocking server locating attempts. 
    33        * 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. 
    46 
    57v. 0.4beta4 - Sun Mar 20 2011 12:15 CET 
  • roard/include/sources.h

    r4708 r4807  
    6464int sources_add_roar (char * driver, char * device, char * container, char * options, int primary); 
    6565 
     66int sources_add_radionoise (int stream, char * device, int fh, char * driver); 
     67 
    6668#ifndef ROAR_WITHOUT_DCOMP_CDRIVER 
    6769int sources_add_cdriver (int stream   , char * device, int fh, char * driver); 
  • roard/sources.c

    r4708 r4807  
    4040 {"oss",  "OSS CDriver",                 "/dev/audio",     SRC_FLAG_NONE,  ROAR_SUBSYS_WAVEFORM, NULL, sources_add_cdriver}, 
    4141#endif 
     42 {"radionoise", "Noise source at -102dB", NULL,            SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_radionoise}, 
    4243 {NULL, NULL, NULL, SRC_FLAG_NONE, 0, NULL, NULL} // EOL 
    4344}; 
     
    5253 char subsys[7] = "      "; 
    5354 
    54  printf("  Source   Flag Subsys - Description (devices)\n"); 
    55  printf("------------------------------------------------------\n"); 
     55 printf("  Source    Flag Subsys - Description (devices)\n"); 
     56 printf("-------------------------------------------------------\n"); 
    5657 
    5758 for (i = 0; g_source[i].name != NULL; i++) { 
     
    7172   subsys[5] = 'X'; 
    7273 
    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  } 
    7989 } 
    8090} 
     
    137147 } 
    138148 
    139  streams_get(stream, &ss); 
     149 if ( streams_get(stream, &ss) == -1 ) { 
     150  streams_delete(stream); 
     151  return -1; 
     152 } 
     153 
    140154 s = ROAR_STREAM(ss); 
    141155 
     
    441455  return -1; 
    442456 
    443  streams_get(stream, &ss); 
     457 if ( streams_get(stream, &ss) == -1 ) 
     458  return -1; 
    444459 
    445460 if ( !strncmp(driver, "cdriver:", 8) ) 
     
    455470#endif 
    456471 
     472static 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 
     501static 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 
     509int 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 
    457533#endif 
    458534 
Note: See TracChangeset for help on using the changeset viewer.