mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
Mega patch:
* implement inner loops using liboil * drop "typeid" stuff * add support for channel maps * add support for seperate volumes per channel * add support for hardware mixer settings (only module-oss implements this for now) * fix a lot of types for _t suffix git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@463 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
759721cbbc
commit
dd10c98241
114 changed files with 2584 additions and 1329 deletions
|
|
@ -30,29 +30,29 @@
|
|||
|
||||
#include "sample.h"
|
||||
|
||||
size_t pa_frame_size(const pa_sample_spec *spec) {
|
||||
size_t b = 1;
|
||||
size_t pa_sample_size(const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
|
||||
switch (spec->format) {
|
||||
case PA_SAMPLE_U8:
|
||||
case PA_SAMPLE_ULAW:
|
||||
case PA_SAMPLE_ALAW:
|
||||
b = 1;
|
||||
break;
|
||||
return 1;
|
||||
case PA_SAMPLE_S16LE:
|
||||
case PA_SAMPLE_S16BE:
|
||||
b = 2;
|
||||
break;
|
||||
return 2;
|
||||
case PA_SAMPLE_FLOAT32LE:
|
||||
case PA_SAMPLE_FLOAT32BE:
|
||||
b = 4;
|
||||
break;
|
||||
return 4;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
return b * spec->channels;
|
||||
size_t pa_frame_size(const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
|
||||
return pa_sample_size(spec) * spec->channels;
|
||||
}
|
||||
|
||||
size_t pa_bytes_per_second(const pa_sample_spec *spec) {
|
||||
|
|
@ -69,10 +69,11 @@ pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) {
|
|||
int pa_sample_spec_valid(const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
|
||||
if (spec->rate <= 0 || spec->channels <= 0)
|
||||
return 0;
|
||||
|
||||
if (spec->format >= PA_SAMPLE_MAX || spec->format < 0)
|
||||
if (spec->rate <= 0 ||
|
||||
spec->channels <= 0 ||
|
||||
spec->channels > PA_CHANNELS_MAX ||
|
||||
spec->format >= PA_SAMPLE_MAX ||
|
||||
spec->format < 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
|
@ -84,15 +85,15 @@ int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) {
|
|||
return (a->format == b->format) && (a->rate == b->rate) && (a->channels == b->channels);
|
||||
}
|
||||
|
||||
const char *pa_sample_format_to_string(pa_sample_format f) {
|
||||
const char *pa_sample_format_to_string(pa_sample_format_t f) {
|
||||
static const char* const table[]= {
|
||||
[PA_SAMPLE_U8] = "U8",
|
||||
[PA_SAMPLE_ALAW] = "ALAW",
|
||||
[PA_SAMPLE_ULAW] = "ULAW",
|
||||
[PA_SAMPLE_S16LE] = "S16LE",
|
||||
[PA_SAMPLE_S16BE] = "S16BE",
|
||||
[PA_SAMPLE_FLOAT32LE] = "FLOAT32LE",
|
||||
[PA_SAMPLE_FLOAT32BE] = "FLOAT32BE",
|
||||
[PA_SAMPLE_U8] = "u8",
|
||||
[PA_SAMPLE_ALAW] = "aLaw",
|
||||
[PA_SAMPLE_ULAW] = "uLaw",
|
||||
[PA_SAMPLE_S16LE] = "s16le",
|
||||
[PA_SAMPLE_S16BE] = "s16be",
|
||||
[PA_SAMPLE_FLOAT32LE] = "float32le",
|
||||
[PA_SAMPLE_FLOAT32BE] = "float32be",
|
||||
};
|
||||
|
||||
if (f >= PA_SAMPLE_MAX)
|
||||
|
|
@ -112,44 +113,6 @@ char *pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec) {
|
|||
return s;
|
||||
}
|
||||
|
||||
pa_volume_t pa_volume_multiply(pa_volume_t a, pa_volume_t b) {
|
||||
uint64_t p = a;
|
||||
p *= b;
|
||||
p /= PA_VOLUME_NORM;
|
||||
|
||||
return (pa_volume_t) p;
|
||||
}
|
||||
|
||||
pa_volume_t pa_volume_from_dB(double f) {
|
||||
if (f <= PA_DECIBEL_MININFTY)
|
||||
return PA_VOLUME_MUTED;
|
||||
|
||||
return (pa_volume_t) (pow(10, f/20)*PA_VOLUME_NORM);
|
||||
}
|
||||
|
||||
double pa_volume_to_dB(pa_volume_t v) {
|
||||
if (v == PA_VOLUME_MUTED)
|
||||
return PA_DECIBEL_MININFTY;
|
||||
|
||||
return 20*log10((double) v/PA_VOLUME_NORM);
|
||||
}
|
||||
|
||||
#define USER_DECIBEL_RANGE 30
|
||||
|
||||
double pa_volume_to_user(pa_volume_t v) {
|
||||
double dB = pa_volume_to_dB(v);
|
||||
|
||||
return dB < -USER_DECIBEL_RANGE ? 0 : dB/USER_DECIBEL_RANGE+1;
|
||||
}
|
||||
|
||||
pa_volume_t pa_volume_from_user(double v) {
|
||||
|
||||
if (v <= 0)
|
||||
return PA_VOLUME_MUTED;
|
||||
|
||||
return pa_volume_from_dB((v-1)*USER_DECIBEL_RANGE);
|
||||
}
|
||||
|
||||
void pa_bytes_snprint(char *s, size_t l, unsigned v) {
|
||||
if (v >= ((unsigned) 1024)*1024*1024)
|
||||
snprintf(s, l, "%0.1f GB", ((double) v)/1024/1024/1024);
|
||||
|
|
@ -161,7 +124,7 @@ void pa_bytes_snprint(char *s, size_t l, unsigned v) {
|
|||
snprintf(s, l, "%u B", (unsigned) v);
|
||||
}
|
||||
|
||||
pa_sample_format pa_parse_sample_format(const char *format) {
|
||||
pa_sample_format_t pa_parse_sample_format(const char *format) {
|
||||
|
||||
if (strcasecmp(format, "s16le") == 0)
|
||||
return PA_SAMPLE_S16LE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue