summaryrefslogtreecommitdiffstats
path: root/polyp
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-09-01 13:04:03 +0000
committerLennart Poettering <lennart@poettering.net>2004-09-01 13:04:03 +0000
commit0205fc57bbfdf03e5cdd5eb3c908f5531c4fdbf1 (patch)
tree26074ef05a6212a65641efb3fc5531a368d824e8 /polyp
parent63c76bd0691a4b4b1d505ad6eac87af7c296cdab (diff)
add PA_MININFTY
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@169 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp')
-rw-r--r--polyp/oss-util.c4
-rw-r--r--polyp/sample.c4
-rw-r--r--polyp/sample.h8
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