sad

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

commit a0ac7e311c5533c7cfa3fea010674dad41debd17
parent a780d71d012c31e573f2efb68d3fd0bd1529f58e
Author: Spenser Truex <truex@equwal.com>
Date:   Thu, 21 Jan 2021 06:11:15 -0800

Use #define macros to simplify configuration

The idea is to remove any need for duplicating user effort in
configuring. So if you want to enable a different sound card, for
example, you only change SOUNDSYS and not three hardcoded booleans.

Diffstat:
Mconfig.def.h | 39+++++++++++++++++++++++++++++++++------
Msad.h | 5+++++
2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,16 +1,43 @@ #define RESAMPLEQUALITY SOXR_QQ +#define BITRATE 48000 +#define BITDEPTH 16 +#define CHANNELS 2 +#define SOUNDSYS ALSA + + +/* + Only need to edit below this line if you have multiple sound backends. +*/ + +#if SOUNDSYS == SNDIO +#define SNDIOON 1 +#else +#define SNDIOON 0 +#endif +#if SOUNDSYS == ALSA +#define ALSAON 1 +#else +#define ALSAON 0 +#endif +#if SOUNDSYS == FIFO +#define FIFOON 1 +#else +#define FIFOON 0 +#endif + Outputcfg outputcfgs[] = { {.name = "sndio", - .fmt = {.bits = 16, .rate = 48000, .channels = 2}, - .enabled = 0, + .fmt = {.bits = BITDEPTH, .rate = BITRATE, .channels = CHANNELS}, + .enabled = SNDIOON, .output = &sndiooutput}, {.name = "alsa", - .fmt = {.bits = 16, .rate = 48000, .channels = 2}, - .enabled = 1, + .fmt = {.bits = BITDEPTH, .rate = BITRATE, .channels = CHANNELS}, + .enabled = ALSAON, .output = &alsaoutput}, {.name = "fifo", - .fmt = {.bits = 16, .rate = 48000, .channels = 2}, - .enabled = 0, + .fmt = {.bits = BITDEPTH, .rate = BITRATE, .channels = CHANNELS}, + .enabled = FIFOON, .output = &fifooutput}, }; + diff --git a/sad.h b/sad.h @@ -6,6 +6,10 @@ #define PROTOCOLVERSION "0.0" #define DEFAULTVOL 100 +//Magic number flags to enable with. +#define SNDIO 0 +#define ALSA 1 +#define FIFO 2 typedef struct { char *name; void (*fn)(int, char *); @@ -136,3 +140,4 @@ void s16monotostereo(short *, short *, size_t); void s16stereotomono(short *, short *, size_t); void s16tofloat(short *, float *, size_t); void floattos16(float *, short *, size_t); +