Changeset 4850:fe9aec03046c in roaraudio
- Timestamp:
- 04/09/11 21:45:29 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/vs.h
r4719 r4850 284 284 ROAR_VS_CMD_GET_LATC_MINLAG, 285 285 #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 286 290 }; 287 291 -
libroar/vs.c
r4793 r4850 45 45 #define FLAG_BUFFERED 0x0004 46 46 #define FLAG_CLOSEFILE 0x0008 47 #define FLAG_FREE_VOL 0x0010 47 48 #define FLAG_DIR_IN 0x1000 48 49 #define FLAG_DIR_OUT 0x2000 … … 805 806 struct roar_mixer_settings mixer; 806 807 size_t i; 807 register float s ;808 register float s, max_s = -100.0, scale = 65535.0; 808 809 int oldchannels; 809 810 int mode = ROAR_SET_VOL_ALL; … … 828 829 } 829 830 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 830 846 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 } 839 861 } 840 862 mixer.mixer[i] = s; 841 863 } 842 864 843 mixer.scale = 65535; 865 if ( vss->flags & FLAG_FREE_VOL ) { 866 mixer.scale = scale; 867 } else { 868 mixer.scale = 65535; 869 } 844 870 845 871 if ( channels != oldchannels ) … … 1344 1370 break; 1345 1371 #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; 1346 1381 // use ifndef here so warnings of unhandled enum values will be shown in DEBUG mode. 1347 1382 #ifndef DEBUG
Note: See TracChangeset
for help on using the changeset viewer.