add PA_MININFTY

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@169 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2004-09-01 13:04:03 +00:00
parent 63c76bd069
commit 0205fc57bb
3 changed files with 12 additions and 4 deletions

View file

@ -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));

View file

@ -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);
}

View file

@ -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