diff options
Diffstat (limited to 'polyp')
-rw-r--r-- | polyp/oss-util.c | 4 | ||||
-rw-r--r-- | polyp/sample.c | 4 | ||||
-rw-r--r-- | polyp/sample.h | 8 |
3 files changed, 12 insertions, 4 deletions
diff --git a/polyp/oss-util.c b/polyp/oss-util.c index cf55a6ee..4fb2b929 100644 --- a/polyp/oss-util.c +++ b/polyp/oss-util.c @@ -138,7 +138,7 @@ int pa_oss_auto_format(int fd, struct pa_sample_spec *ss) { return 0; } -static int log2(int v) { +static int simple_log2(int v) { int k = 0; for (;;) { @@ -152,7 +152,7 @@ static int log2(int v) { int pa_oss_set_fragments(int fd, int nfrags, int frag_size) { int arg; - arg = ((int) nfrags << 16) | log2(frag_size); + arg = ((int) nfrags << 16) | simple_log2(frag_size); if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) { fprintf(stderr, "SNDCTL_DSP_SETFRAGMENT: %s\n", strerror(errno)); diff --git a/polyp/sample.c b/polyp/sample.c index 3019f93b..6ec56000 100644 --- a/polyp/sample.c +++ b/polyp/sample.c @@ -107,7 +107,7 @@ pa_volume_t pa_volume_multiply(pa_volume_t a, pa_volume_t b) { } pa_volume_t pa_volume_from_dB(double f) { - if (f <= -200) + if (f <= PA_DECIBEL_MININFTY) return PA_VOLUME_MUTED; return (pa_volume_t) (pow(10, f/20)*PA_VOLUME_NORM); @@ -115,7 +115,7 @@ pa_volume_t pa_volume_from_dB(double f) { double pa_volume_to_dB(pa_volume_t v) { if (v == PA_VOLUME_MUTED) - return -200; + return PA_DECIBEL_MININFTY; return 20*log10((double) v/PA_VOLUME_NORM); } diff --git a/polyp/sample.h b/polyp/sample.h index 95844301..4b28780d 100644 --- a/polyp/sample.h +++ b/polyp/sample.h @@ -24,6 +24,7 @@ #include <inttypes.h> #include <sys/types.h> +#include <math.h> #include "cdecl.h" @@ -108,6 +109,13 @@ pa_volume_t pa_volume_from_dB(double f); /** Convert volume from linear level to decibel. \since 0.4 */ double pa_volume_to_dB(pa_volume_t v); +#ifdef INFINITY +#define PA_DECIBEL_MININFTY -INFINITY +#else +/** This value is used as minus infinity when using pa_volume_{to,from}_dB(). \since 0.4 */ +#define PA_DECIBEL_MININFTY -200 +#endif + PA_C_DECL_END #endif |