From 16cb57ff4f7e49b5c141915cc451d5ba09c2d420 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 27 Jan 2023 11:12:24 +0100 Subject: [PATCH] :art: Add in, out and samplerate to config --- scripts/embed.bash | 11 +++++++++++ src/soundinfo.c | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/scripts/embed.bash b/scripts/embed.bash index bf56e91b..0701c385 100644 --- a/scripts/embed.bash +++ b/scripts/embed.bash @@ -119,3 +119,14 @@ echo "}" >> embed/embed_foot cat embed/embed_head embed/embed_body embed/embed_foot > embed/embed.c rm embed/embed_head embed/embed_body embed/embed_foot +audio=$(jq -rc '.audio' <<< "$json") +in=$(jq -rc '.in' <<< "$audio") +out=$(jq -rc '.out' <<< "$audio") +samplerate=$(jq -rc '.samplerate' <<< "$audio") +# check is truthy +{ +[ "$in" != "null" ] && echo "CFLAGS += -DGWION_DEFAULT_NIN=$in" +[ "$out" != "null" ] && echo "CFLAGS += -DGWION_DEFAULT_NOUT=$out" +[ "$samplerate" != "null" ] && echo "CFLAGS += -DGWION_DEFAULT_SAMPLERATE=$samplerate" +} >> embed/embed.mk + diff --git a/src/soundinfo.c b/src/soundinfo.c index 6fc0472a..cea3bb21 100644 --- a/src/soundinfo.c +++ b/src/soundinfo.c @@ -1,10 +1,23 @@ #include #include +#ifndef GWION_DEFAULT_NIN +#define GWION_DEFAULT_NIN 2 +#endif + +#ifndef GWION_DEFAULT_NOUT +#define GWION_DEFAULT_NOUT 2 +#endif + +#ifndef GWION_DEFAULT_SAMPLERATE +#define GWION_DEFAULT_SAMPLERATE 48000 +#endif + struct SoundInfo_ *new_soundinfo(MemPool p) { struct SoundInfo_ *si = mp_calloc(p, SoundInfo); - si->in = si->out = 2; - si->sr = 48000; + si->in = GWION_DEFAULT_NIN; + si->out = GWION_DEFAULT_NOUT; + si->sr = GWION_DEFAULT_SAMPLERATE; return si; } -- 2.43.0