sad

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

commit 711d9919fab35544496048743167abfdd85af821
parent b86364909a9bf32c03b18f8699c493bee125c474
Author: sin <sin@2f30.org>
Date:   Wed, 31 Dec 2014 18:06:05 +0000

Simplify config.def.h

Diffstat:
Mconfig.def.h | 14++++----------
Moutput.c | 25+++++++++++++++++++++++++
Msad.c | 1+
Msad.h | 1+
4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,6 +1,6 @@ #define RESAMPLEQUALITY SOXR_QQ -Outputdesc outputdescs[] = { +Outputcfg outputcfgs[] = { { .name = "sndio", .fmt = { @@ -9,9 +9,7 @@ Outputdesc outputdescs[] = { .channels = 2 }, .enabled = 0, - .active = 0, - .output = &sndiooutput, - .resampler = NULL + .output = &sndiooutput }, { .name = "alsa", @@ -21,9 +19,7 @@ Outputdesc outputdescs[] = { .channels = 2 }, .enabled = 0, - .active = 0, - .output = &alsaoutput, - .resampler = NULL + .output = &alsaoutput }, { .name = "fifo", @@ -33,8 +29,6 @@ Outputdesc outputdescs[] = { .channels = 2 }, .enabled = 0, - .active = 0, - .output = &fifooutput, - .resampler = NULL + .output = &fifooutput }, }; diff --git a/output.c b/output.c @@ -19,8 +19,33 @@ typedef struct { soxr_t resampler; } Outputdesc; +typedef struct { + char *name; + Format fmt; + int enabled; + Output *output; +} Outputcfg; + #include "config.h" +static Outputdesc outputdescs[LEN(outputcfgs)]; + +int +initoutputs(void) +{ + int i; + + for (i = 0; i < LEN(outputcfgs); i++) { + outputdescs[i].name = outputcfgs[i].name; + outputdescs[i].fmt = outputcfgs[i].fmt; + outputdescs[i].enabled = outputcfgs[i].enabled; + outputdescs[i].output = outputcfgs[i].output; + outputdescs[i].active = 0; + outputdescs[i].resampler = NULL; + } + return 0; +} + static int initresampler(Format *fmt, Outputdesc *desc) { diff --git a/sad.c b/sad.c @@ -122,6 +122,7 @@ main(int argc, char *argv[]) fdmax = listenfd; initdecoders(); + initoutputs(); openoutputs(); initnotifier(); diff --git a/sad.h b/sad.h @@ -130,6 +130,7 @@ int initdecoders(void); Decoder *matchdecoder(const char *); /* output.c */ +int initoutputs(void); int initresamplers(Format *); int openoutputs(void); int closeoutputs(void);