From e7016f9f02379cc5b95d6e8d7e123a5a0e5e2d34 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 21 Jan 2018 10:43:45 +0100 Subject: [PATCH] Make sound card support (Alsa) optional --- libmncc/Makefile.am | 5 +++++ libmncc/mncc_console.c | 17 ++++++++++++++++- libmobile/Makefile.am | 4 ++++ libmobile/sender.c | 6 ++++++ libmobile/sender.h | 2 ++ libsdr/sdr.h | 2 ++ libsound/Makefile.am | 2 ++ 7 files changed, 37 insertions(+), 1 deletion(-) diff --git a/libmncc/Makefile.am b/libmncc/Makefile.am index 7881872..491a3ef 100644 --- a/libmncc/Makefile.am +++ b/libmncc/Makefile.am @@ -8,3 +8,8 @@ libmncc_a_SOURCES = \ mncc_sock.c \ testton.c \ cause.c + +if HAVE_ALSA +AM_CPPFLAGS += -DHAVE_ALSA +endif + diff --git a/libmncc/mncc_console.c b/libmncc/mncc_console.c index 72ce21c..912f339 100644 --- a/libmncc/mncc_console.c +++ b/libmncc/mncc_console.c @@ -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 } diff --git a/libmobile/Makefile.am b/libmobile/Makefile.am index 045d548..f75cfe5 100644 --- a/libmobile/Makefile.am +++ b/libmobile/Makefile.am @@ -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 diff --git a/libmobile/sender.c b/libmobile/sender.c index 728fa46..b309c4d 100644 --- a/libmobile/sender.c +++ b/libmobile/sender.c @@ -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 } } diff --git a/libmobile/sender.h b/libmobile/sender.h index 1bcb1c0..6591f35 100644 --- a/libmobile/sender.h +++ b/libmobile/sender.h @@ -1,4 +1,6 @@ +#ifdef HAVE_ALSA #include "../libsound/sound.h" +#endif #ifdef HAVE_SDR #include "../libsdr/sdr.h" #endif diff --git a/libsdr/sdr.h b/libsdr/sdr.h index 360f424..8d31475 100644 --- a/libsdr/sdr.h +++ b/libsdr/sdr.h @@ -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); diff --git a/libsound/Makefile.am b/libsound/Makefile.am index ffa876f..afbbb0a 100644 --- a/libsound/Makefile.am +++ b/libsound/Makefile.am @@ -4,3 +4,5 @@ noinst_LIBRARIES = libsound.a libsound_a_SOURCES = \ sound_alsa.c + +AM_CPPFLAGS += -DHAVE_ALSA