Changeset 4850:fe9aec03046c in roaraudio


Ignore:
Timestamp:
04/09/11 21:45:29 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

allow amps > 1.0 for VS API in some kind of expert mode (needed by VLC, requested by maister)

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/vs.h

    r4719 r4850  
    284284 ROAR_VS_CMD_GET_LATC_MINLAG, 
    285285#define ROAR_VS_CMD_GET_LATC_MINLAG ROAR_VS_CMD_GET_LATC_MINLAG 
     286 ROAR_VS_CMD_SET_FREE_VOLUME, 
     287#define ROAR_VS_CMD_SET_FREE_VOLUME ROAR_VS_CMD_SET_FREE_VOLUME 
     288 ROAR_VS_CMD_GET_FREE_VOLUME, 
     289#define ROAR_VS_CMD_GET_FREE_VOLUME ROAR_VS_CMD_GET_FREE_VOLUME 
    286290}; 
    287291 
  • libroar/vs.c

    r4793 r4850  
    4545#define FLAG_BUFFERED  0x0004 
    4646#define FLAG_CLOSEFILE 0x0008 
     47#define FLAG_FREE_VOL  0x0010 
    4748#define FLAG_DIR_IN    0x1000 
    4849#define FLAG_DIR_OUT   0x2000 
     
    805806 struct roar_mixer_settings mixer; 
    806807 size_t i; 
    807  register float s; 
     808 register float s, max_s = -100.0, scale = 65535.0; 
    808809 int oldchannels; 
    809810 int mode = ROAR_SET_VOL_ALL; 
     
    828829 } 
    829830 
     831 if ( vss->flags & FLAG_FREE_VOL ) { 
     832  for (i = 0; i < channels; i++) { 
     833   if ( c[i] > max_s ) { 
     834    max_s = c[i]; 
     835   } else if ( c[i] < -0.01 ) { 
     836    _seterr(ROAR_ERROR_RANGE); 
     837    return -1; 
     838   } 
     839  } 
     840 
     841  if ( max_s > 1.00 ) { 
     842   scale = 65535.0 / max_s; 
     843  } 
     844 } 
     845 
    830846 for (i = 0; i < channels; i++) { 
    831   s = c[i] * 65535.0; 
    832   if ( s > 66190.0 || s < -655.0 ) { 
    833    _seterr(ROAR_ERROR_RANGE); 
    834    return -1; 
    835   } else if ( s > 65535.0 ) { 
    836    s = 65535.0; 
    837   } else if ( s <     0.0 ) { 
    838    s = 0.0; 
     847  if ( vss->flags & FLAG_FREE_VOL ) { 
     848   s = c[i] * scale; 
     849   if ( s < 0.0 ) 
     850    s = 0.0; 
     851  } else { 
     852   s = c[i] * 65535.0; 
     853   if ( s > 66190.0 || s < -655.0 ) { 
     854    _seterr(ROAR_ERROR_RANGE); 
     855    return -1; 
     856   } else if ( s > 65535.0 ) { 
     857    s = 65535.0; 
     858   } else if ( s <     0.0 ) { 
     859    s = 0.0; 
     860   } 
    839861  } 
    840862  mixer.mixer[i] = s; 
    841863 } 
    842864 
    843  mixer.scale = 65535; 
     865 if ( vss->flags & FLAG_FREE_VOL ) { 
     866  mixer.scale = scale; 
     867 } else { 
     868  mixer.scale = 65535; 
     869 } 
    844870 
    845871 if ( channels != oldchannels ) 
     
    13441370   break; 
    13451371#endif 
     1372  case ROAR_VS_CMD_SET_FREE_VOLUME: 
     1373    vss->flags |= FLAG_FREE_VOL; 
     1374    if ( !*(int*)argp ) { 
     1375     vss->flags -= FLAG_FREE_VOL; 
     1376    } 
     1377   break; 
     1378  case ROAR_VS_CMD_GET_FREE_VOLUME: 
     1379    *(int*)argp = vss->flags & FLAG_FREE_VOL ? 1 : 0; 
     1380   break; 
    13461381// use ifndef here so warnings of unhandled enum values will be shown in DEBUG mode. 
    13471382#ifndef DEBUG 
Note: See TracChangeset for help on using the changeset viewer.