Make sound card support (Alsa) optional

pull/1/head
Andreas Eversberg 2018-01-21 10:43:45 +01:00
parent 0b129d3c7f
commit 4cc33c5b0d
19 changed files with 112 additions and 26 deletions

View File

@ -27,8 +27,6 @@ AC_CANONICAL_HOST
AC_CHECK_LIB([m], [main])
AC_CHECK_LIB([pthread], [main])
PKG_CHECK_MODULES(ALSA, alsa >= 1.0)
# disabled due to problems with api compatibilty with imagemagick
#AC_ARG_ENABLE(graphicsmagick,
# [AS_HELP_STRING(
@ -63,13 +61,17 @@ fi
AM_CONDITIONAL(ENABLE_MAGICK, test x"$somethingmagick" = x"yes")
with_sdr=no
AC_ARG_WITH([alsa], [AS_HELP_STRING([--with-alsa], [compile with Alsa driver @<:@default=check@:>@]) ], [], [with_alsa="check"])
AC_ARG_WITH([uhd], [AS_HELP_STRING([--with-uhd], [compile with UHD driver @<:@default=check@:>@]) ], [], [with_uhd="check"])
AC_ARG_WITH([soapy], [AS_HELP_STRING([--with-soapy], [compile with SoapySDR driver @<:@default=check@:>@]) ], [], [with_soapy="check"])
AS_IF([test "x$with_alsa" != xno], [PKG_CHECK_MODULES(ALSA, alsa >= 1.0, with_alsa=yes, with_alsa=no)])
AS_IF([test "x$with_uhd" != xno], [PKG_CHECK_MODULES(UHD, uhd >= 3.0.0, with_sdr=yes with_uhd=yes, with_uhd=no)])
AS_IF([test "x$with_soapy" != xno], [PKG_CHECK_MODULES(SOAPY, SoapySDR >= 0.6.0, with_sdr=yes with_soapy=yes, with_soapy=no)])
AM_CONDITIONAL(HAVE_ALSA, test "x$with_alsa" == "xyes" )
AM_CONDITIONAL(HAVE_UHD, test "x$with_uhd" == "xyes" )
AM_CONDITIONAL(HAVE_SOAPY, test "x$with_soapy" == "xyes" )
AM_CONDITIONAL(HAVE_SDR, test "x$with_sdr" == "xyes" )
AS_IF([test "x$with_alsa" == "xyes"],[AC_MSG_NOTICE( Compiling with Alsa support )], [AC_MSG_NOTICE( Alsa sound card not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
AS_IF([test "x$with_uhd" == "xyes"],[AC_MSG_NOTICE( Compiling with UHD SDR support )], [AC_MSG_NOTICE( UHD SDR not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
AS_IF([test "x$with_soapy" == "xyes"],[AC_MSG_NOTICE( Compiling with SoapySDR support )], [AC_MSG_NOTICE( SoapySDR not supported. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. )])
AS_IF([test "x$somethingmagick" == "xyes"],[AC_MSG_NOTICE( Compiling with ImageMagick )],[AC_MSG_NOTICE( ImageMagick not supported )])

View File

@ -22,8 +22,12 @@ SUBDIRS = \
libfilter \
libwave \
libfft \
libmncc \
libmncc
if HAVE_ALSA
SUBDIRS += \
libsound
endif
if HAVE_SDR
SUBDIRS += \

View File

@ -38,11 +38,15 @@ amps_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
amps_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
amps_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -30,11 +30,15 @@ anetz_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
anetz_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
anetz_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -27,11 +27,15 @@ bnetz_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
bnetz_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
bnetz_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -29,11 +29,15 @@ cnetz_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
cnetz_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
cnetz_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -24,12 +24,16 @@ jollycom_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libfm/libfm.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
jollycom_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
jollycom_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -24,11 +24,15 @@ jtacs_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
jtacs_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
jtacs_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -8,3 +8,8 @@ libmncc_a_SOURCES = \
mncc_sock.c \
testton.c \
cause.c
if HAVE_ALSA
AM_CPPFLAGS += -DHAVE_ALSA
endif

View File

@ -33,7 +33,9 @@
#include "mncc_console.h"
#include "cause.h"
#include "../libmobile/call.h"
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#endif
static int new_callref = 0; /* toward mobile */
@ -289,11 +291,12 @@ error:
return rc;
}
int console_open_audio(int latspl)
int console_open_audio(int __attribute__((unused)) latspl)
{
if (!console.audiodev[0])
return 0;
#ifdef HAVE_ALSA
/* open sound device for call control */
/* use factor 1.4 of speech level for complete range of sound card */
console.sound = sound_open(console.audiodev, NULL, NULL, 1, 0.0, console.samplerate, latspl, 1.4, 4000.0);
@ -301,6 +304,10 @@ int console_open_audio(int latspl)
PDEBUG(DSENDER, DEBUG_ERROR, "No sound device!\n");
return -EIO;
}
#else
PDEBUG(DSENDER, DEBUG_ERROR, "No sound card support compiled in!\n");
return -ENOTSUP;
#endif
return 0;
}
@ -310,14 +317,20 @@ int console_start_audio(void)
if (!console.audiodev[0])
return 0;
#ifdef HAVE_ALSA
return sound_start(console.sound);
#else
return -EINVAL;
#endif
}
void console_cleanup(void)
{
#ifdef HAVE_ALSA
/* close sound devoice */
if (console.sound)
sound_close(console.sound);
#endif
jitter_destroy(&console.dejitter);
}
@ -428,6 +441,7 @@ void process_console(int c)
if (!console.sound)
return;
#ifdef HAVE_ALSA
/* handle audio, if sound device is used */
sample_t samples[console.latspl + 10], *samples_list[1];
uint8_t *power_list[1];
@ -487,5 +501,6 @@ void process_console(int c)
}
}
}
#endif
}

View File

@ -7,6 +7,10 @@ libmobile_a_SOURCES = \
call.c \
main_mobile.c
if HAVE_ALSA
AM_CPPFLAGS += -DHAVE_ALSA
endif
if HAVE_SDR
AM_CPPFLAGS += -DHAVE_SDR
endif

View File

@ -115,12 +115,18 @@ int sender_create(sender_t *sender, int kanal, double sendefrequenz, double empf
} else
#endif
{
#ifdef HAVE_ALSA
sender->audio_open = sound_open;
sender->audio_start = sound_start;
sender->audio_close = sound_close;
sender->audio_read = sound_read;
sender->audio_write = sound_write;
sender->audio_get_tosend = sound_get_tosend;
#else
PDEBUG(DSENDER, DEBUG_ERROR, "No sound card support compiled in!\n");
rc = -ENOTSUP;
goto error;
#endif
}
}

View File

@ -1,4 +1,6 @@
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#endif
#ifdef HAVE_SDR
#include "../libsdr/sdr.h"
#endif

View File

@ -1,4 +1,6 @@
enum paging_signal;
int sdr_start(void *inst);
void *sdr_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int channels, double paging_frequency, int samplerate, int latspl, double bandwidth, double sample_deviation);
void sdr_close(void *inst);

View File

@ -4,3 +4,5 @@ noinst_LIBRARIES = libsound.a
libsound_a_SOURCES = \
sound_alsa.c
AM_CPPFLAGS += -DHAVE_ALSA

View File

@ -38,11 +38,15 @@ nmt_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
nmt_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
nmt_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -26,11 +26,15 @@ radiocom2000_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
radiocom2000_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
radiocom2000_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -25,11 +25,15 @@ tacs_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
tacs_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
tacs_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \

View File

@ -66,11 +66,15 @@ test_dms_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
test_dms_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
test_dms_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
@ -95,11 +99,15 @@ test_sms_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libmncc/libmncc.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libsample/libsample.a \
$(ALSA_LIBS) \
-lm
if HAVE_ALSA
test_sms_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
test_sms_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \