sad

simple audio daemon
git clone git://git.2f30.org/sad.git
Log | Files | Refs | LICENSE

commit 178e378914c62891f84633233020ec13a9ae069f
parent c39de543ffcc6e021957fc967f30133c0f1ef852
Author: sin <sin@2f30.org>
Date:   Fri Jan  2 14:50:39 +0000

Factor our pcm conversion functions to a separate file

Diffstat:
Makefile | 1+
output.c | 20--------------------
pcm.c | 26++++++++++++++++++++++++++
sad.h | 4++++
4 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile @@ -16,6 +16,7 @@ OBJ =\ mp3.o\ notify.o\ output.o\ + pcm.o\ playlist.o\ sad.o\ sndio.o\ diff --git a/output.c b/output.c @@ -151,26 +151,6 @@ closeoutputs(void) return r; } -static void -s16monotostereo(short *in, short *out, size_t nsamples) -{ - size_t i; - - for (i = 0; i < nsamples; i++) { - out[i * 2] = in[i]; - out[i * 2 + 1] = in[i]; - } -} - -static void -s16stereotomono(short *in, short *out, size_t nsamples) -{ - size_t i; - - for (i = 0; i < nsamples; i++) - out[i] = (in[i * 2] + in[i * 2 + 1]) / 2; -} - static int playoutput(Format *fmt, Outputdesc *desc, void *buf, size_t nbytes) { diff --git a/pcm.c b/pcm.c @@ -0,0 +1,26 @@ +#include <sys/select.h> + +#include <limits.h> +#include <stdio.h> + +#include "sad.h" + +void +s16monotostereo(short *in, short *out, size_t nsamples) +{ + size_t i; + + for (i = 0; i < nsamples; i++) { + out[i * 2] = in[i]; + out[i * 2 + 1] = in[i]; + } +} + +void +s16stereotomono(short *in, short *out, size_t nsamples) +{ + size_t i; + + for (i = 0; i < nsamples; i++) + out[i] = (in[i * 2] / 2) + (in[i * 2 + 1] / 2); +} diff --git a/sad.h b/sad.h @@ -147,3 +147,7 @@ int addsubscriber(int, int); int addsubscribername(int, const char *); int notify(int); void removesubscriber(int); + +/* pcm.c */ +void s16monotostereo(short *, short *, size_t); +void s16stereotomono(short *, short *, size_t);