diff --git a/config.subr b/config.subr
index e9174a9..b44f476 100644
--- a/config.subr
+++ b/config.subr
@@ -181,8 +181,9 @@ check_portaudio() {
}
check_sndio() {
- LOG=.lib.sndio.config.log
- if "$CC" $CPPFLAGS $CFLAGS "${LIB_SRCDIR}/sndio/config.c" -o /dev/null ${LDFLAGS} -lsndio > $LOG 2>&1; then
+ if pkg-config sndio; then
+ CFLAGS="$CFLAGS $(pkg-config --cflags sndio)"
+ LIBS="$LIBS $(pkg-config --libs sndio)"
HAVE_SNDIO=Yes
else
HAVE_SNDIO=No
diff --git a/lib/configure b/lib/configure
index 416df50..eed0434 100755
--- a/lib/configure
+++ b/lib/configure
@@ -3,10 +3,6 @@ set -e
. ../config.subr
-check_libbsd
-check_portaudio
-check_sndio
-
LIB_SRCDIR="$(dirname $0)"
SOURCES="$(ls *.c | grep -Ev '_type.c$' | tr '\n' ' ')"
@@ -28,6 +24,10 @@ CFLAGS="$CFLAGS -W -Wall -Werror -std=c89 -pedantic"
LIBS=""
+check_libbsd
+check_portaudio
+check_sndio
+
if ! test "x$HAVE_SNDIO" = "xYes"; then
DIRS="$(echo "$DIRS" | grep -v sndio)"
fi
@@ -47,6 +47,9 @@ if test "x$HAVE_PORTAUDIO" = "xYes"; then
fi
type_prog reverb
type_prog signal
+if test "x$HAVE_SNDIO" = "xYes"; then
+ type_prog sndio
+fi
type_prog synth
echo "types:${TYPES}" >> ${CONFIG_MK}
diff --git a/lib/sndio.c b/lib/sndio.c
new file mode 100644
index 0000000..d6ed601
--- /dev/null
+++ b/lib/sndio.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sndio.h>
+#include <stdio.h>
+#include <strings.h>
+#include "../librtbuf/rtbuf.h"
+#include "../librtbuf/lib.h"
+#include "signal.h"
+#include "signal_type.h"
+#include "sndio.h"
+#include "sndio_type.h"
+
+void print_sio_par (struct sio_par *par)
+{
+ printf("#<sio_par bits=%i sig=%i rchan=%i pchan=%i rate=%i>",
+ par->bits, par->sig, par->rchan, par->pchan, par->rate);
+}
diff --git a/lib/sndio.h b/lib/sndio.h
new file mode 100644
index 0000000..0f296fd
--- /dev/null
+++ b/lib/sndio.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_SNDIO_H
+#define RTBUF_SNDIO_H
+
+#include <sndio.h>
+#include "signal.h"
+
+void print_sio_par (struct sio_par *par);
+
+enum {
+ RTBUF_SNDIO_LEFT = 0,
+ RTBUF_SNDIO_RIGHT,
+ RTBUF_SNDIO_CHANNELS
+};
+
+#define RTBUF_SNDIO_SAMPLE_TYPE "short"
+#define RTBUF_SNDIO_SAMPLES \
+ (RTBUF_SNDIO_CHANNELS * RTBUF_SIGNAL_SAMPLES)
+
+typedef short t_rtbuf_sndio_sample;
+typedef t_rtbuf_sndio_sample t_rtbuf_sndio_samples[RTBUF_SNDIO_SAMPLES];
+
+#pragma pack(push,1)
+typedef struct rtbuf_sndio_input_data {
+ t_rtbuf_signal signal[RTBUF_SNDIO_CHANNELS];
+ t_rtbuf_sndio_samples samples;
+} s_rtbuf_sndio_input_data;
+#pragma pack(pop)
+
+int rtbuf_sndio_input (s_rtbuf *rtb);
+int rtbuf_sndio_input_start (s_rtbuf *rtb);
+int rtbuf_sndio_input_stop (s_rtbuf *rtb);
+
+typedef struct rtbuf_sndio_output_reserved {
+ struct sio_hdl *sio_hdl;
+ struct sio_par want;
+ struct sio_par have;
+} s_rtbuf_sndio_output_reserved;
+
+#pragma pack(push,1)
+typedef struct rtbuf_sndio_output_data {
+ t_rtbuf_sndio_samples samples;
+ s_rtbuf_sndio_output_reserved reserved;
+} s_rtbuf_sndio_output_data;
+#pragma pack(pop)
+
+#define RTBUF_SNDIO_OUTPUT_RESERVED_SIZE \
+ sizeof(s_rtbuf_sndio_output_reserved)
+
+int rtbuf_sndio_output (s_rtbuf *rtb);
+int rtbuf_sndio_output_start (s_rtbuf *rtb);
+int rtbuf_sndio_output_stop (s_rtbuf *rtb);
+
+#endif
diff --git a/lib/sndio/config.c b/lib/sndio/config.c
index ac503b3..a7355d4 100644
--- a/lib/sndio/config.c
+++ b/lib/sndio/config.c
@@ -1 +1,6 @@
#include <sndio.h>
+
+int main ()
+{
+ return 0;
+}
diff --git a/lib/sndio/sndio.c b/lib/sndio/sndio.c
deleted file mode 100644
index d6ed601..0000000
--- a/lib/sndio/sndio.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sndio.h>
-#include <stdio.h>
-#include <strings.h>
-#include "../librtbuf/rtbuf.h"
-#include "../librtbuf/lib.h"
-#include "signal.h"
-#include "signal_type.h"
-#include "sndio.h"
-#include "sndio_type.h"
-
-void print_sio_par (struct sio_par *par)
-{
- printf("#<sio_par bits=%i sig=%i rchan=%i pchan=%i rate=%i>",
- par->bits, par->sig, par->rchan, par->pchan, par->rate);
-}
diff --git a/lib/sndio/sndio.h b/lib/sndio/sndio.h
deleted file mode 100644
index 0f296fd..0000000
--- a/lib/sndio/sndio.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_SNDIO_H
-#define RTBUF_SNDIO_H
-
-#include <sndio.h>
-#include "signal.h"
-
-void print_sio_par (struct sio_par *par);
-
-enum {
- RTBUF_SNDIO_LEFT = 0,
- RTBUF_SNDIO_RIGHT,
- RTBUF_SNDIO_CHANNELS
-};
-
-#define RTBUF_SNDIO_SAMPLE_TYPE "short"
-#define RTBUF_SNDIO_SAMPLES \
- (RTBUF_SNDIO_CHANNELS * RTBUF_SIGNAL_SAMPLES)
-
-typedef short t_rtbuf_sndio_sample;
-typedef t_rtbuf_sndio_sample t_rtbuf_sndio_samples[RTBUF_SNDIO_SAMPLES];
-
-#pragma pack(push,1)
-typedef struct rtbuf_sndio_input_data {
- t_rtbuf_signal signal[RTBUF_SNDIO_CHANNELS];
- t_rtbuf_sndio_samples samples;
-} s_rtbuf_sndio_input_data;
-#pragma pack(pop)
-
-int rtbuf_sndio_input (s_rtbuf *rtb);
-int rtbuf_sndio_input_start (s_rtbuf *rtb);
-int rtbuf_sndio_input_stop (s_rtbuf *rtb);
-
-typedef struct rtbuf_sndio_output_reserved {
- struct sio_hdl *sio_hdl;
- struct sio_par want;
- struct sio_par have;
-} s_rtbuf_sndio_output_reserved;
-
-#pragma pack(push,1)
-typedef struct rtbuf_sndio_output_data {
- t_rtbuf_sndio_samples samples;
- s_rtbuf_sndio_output_reserved reserved;
-} s_rtbuf_sndio_output_data;
-#pragma pack(pop)
-
-#define RTBUF_SNDIO_OUTPUT_RESERVED_SIZE \
- sizeof(s_rtbuf_sndio_output_reserved)
-
-int rtbuf_sndio_output (s_rtbuf *rtb);
-int rtbuf_sndio_output_start (s_rtbuf *rtb);
-int rtbuf_sndio_output_stop (s_rtbuf *rtb);
-
-#endif