From 95d7a87ce1122ecff3e1b8d607980e07a4e9111d Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Wed, 8 Aug 2012 14:26:39 -0700 Subject: [PATCH] minimodem: configure --with-alsa for ALSA instead of Pulseaudio --- config.h.in | 3 +++ configure | 26 ++++++++++++++++++++++++++ configure.ac | 14 ++++++++++++++ src/Makefile.am | 1 + src/Makefile.in | 5 ++++- src/minimodem.c | 29 ++++++++++++++++++++--------- 6 files changed, 68 insertions(+), 10 deletions(-) diff --git a/config.h.in b/config.h.in index a062b23..03b5201 100644 --- a/config.h.in +++ b/config.h.in @@ -21,6 +21,9 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Define to 1 to enable ALSA support */ +#undef USE_ALSA + /* Define to 1 to enable pulseaudio support */ #undef USE_PULSEAUDIO diff --git a/configure b/configure index d779dd2..46758f7 100755 --- a/configure +++ b/configure @@ -656,6 +656,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking enable_dependency_tracking +with_alsa with_pulseaudio with_sndfile ' @@ -1294,6 +1295,7 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --without-alsa build without ALSA support --without-pulseaudio build without pulseaudio support --without-sndfile build without sndfile support @@ -3290,6 +3292,28 @@ fi # fftw3f deps_packages+=" fftw3f" +# ALSA + +# Check whether --with-alsa was given. +if test "${with_alsa+set}" = set; then : + withval=$with_alsa; +fi + +if test "x$with_alsa" != "xyes"; then : + # then + use_alsa=0 +else + # else + use_alsa=1 + with_pulseaudio=no # For now, ALSA precludes pulseaudio + deps_packages+=" alsa" +fi + +cat >>confdefs.h <<_ACEOF +#define USE_ALSA $use_alsa +_ACEOF + + # pulseaudio # Check whether --with-pulseaudio was given. @@ -5026,11 +5050,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: minimodem 0.8.2 configuration summary: --with-pulseaudio $with_pulseaudio ($use_pulseaudio) + --with-alsa $with_alsa ($use_alsa) --with-sndfile $with_sndfile ($use_sndfile) deps_packages: $deps_packages " >&5 $as_echo "minimodem 0.8.2 configuration summary: --with-pulseaudio $with_pulseaudio ($use_pulseaudio) + --with-alsa $with_alsa ($use_alsa) --with-sndfile $with_sndfile ($use_sndfile) deps_packages: $deps_packages " >&6; } diff --git a/configure.ac b/configure.ac index 30a2052..b64f4e8 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,19 @@ AC_PROG_CC # fftw3f deps_packages+=" fftw3f" +# ALSA +AC_ARG_WITH([alsa], + AS_HELP_STRING([--without-alsa], [build without ALSA support])) +AS_IF([test "x$with_alsa" != "xyes"], + # then + use_alsa=0, + # else + use_alsa=1 + with_pulseaudio=no # For now, ALSA precludes pulseaudio + deps_packages+=" alsa") +AC_DEFINE_UNQUOTED(USE_ALSA, $use_alsa, + [Define to 1 to enable ALSA support]) + # pulseaudio AC_ARG_WITH([pulseaudio], AS_HELP_STRING([--without-pulseaudio], [build without pulseaudio support])) @@ -83,6 +96,7 @@ AC_OUTPUT AC_MSG_RESULT([PKG_NAME PKG_VERSION configuration summary: --with-pulseaudio $with_pulseaudio ($use_pulseaudio) + --with-alsa $with_alsa ($use_alsa) --with-sndfile $with_sndfile ($use_sndfile) deps_packages: $deps_packages ]) diff --git a/src/Makefile.am b/src/Makefile.am index 71d704d..86a1d81 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,6 +36,7 @@ SIMPLEAUDIO_SRC = \ simpleaudio.c \ simple-tone-generator.c \ simpleaudio-pulse.c \ + simpleaudio-alsa.c \ simpleaudio-sndfile.c FSK_SRC = fsk.h fsk.c diff --git a/src/Makefile.in b/src/Makefile.in index 143567a..80a1bef 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -68,7 +68,8 @@ PROGRAMS = $(bin_PROGRAMS) am__objects_1 = baudot.$(OBJEXT) am__objects_2 = fsk.$(OBJEXT) am__objects_3 = simpleaudio.$(OBJEXT) simple-tone-generator.$(OBJEXT) \ - simpleaudio-pulse.$(OBJEXT) simpleaudio-sndfile.$(OBJEXT) + simpleaudio-pulse.$(OBJEXT) simpleaudio-alsa.$(OBJEXT) \ + simpleaudio-sndfile.$(OBJEXT) am_minimodem_OBJECTS = minimodem.$(OBJEXT) $(am__objects_1) \ $(am__objects_2) $(am__objects_3) minimodem_OBJECTS = $(am_minimodem_OBJECTS) @@ -218,6 +219,7 @@ SIMPLEAUDIO_SRC = \ simpleaudio.c \ simple-tone-generator.c \ simpleaudio-pulse.c \ + simpleaudio-alsa.c \ simpleaudio-sndfile.c FSK_SRC = fsk.h fsk.c @@ -311,6 +313,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsk.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimodem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple-tone-generator.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simpleaudio-alsa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simpleaudio-pulse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simpleaudio-sndfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simpleaudio.Po@am__quote@ diff --git a/src/minimodem.c b/src/minimodem.c index 9a7964b..8bfa442 100644 --- a/src/minimodem.c +++ b/src/minimodem.c @@ -372,17 +372,27 @@ main( int argc, char*argv[] ) if ( TX_mode == -1 ) TX_mode = 0; -#if !(USE_PULSEAUDIO || USE_SNDFILE) -#error At least one of {USE_PULSEAUDIO,USE_SNDFILE} must be enabled +#if !(USE_PULSEAUDIO || USE_ALSA || USE_SNDFILE) +#error At least one of {USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE} must be enabled! #endif + +#if (USE_PULSEAUDIO && USE_ALSA) +#error For now, only one of {USE_PULSEAUDIO,USE_ALSA} can be enabled (FIXME)! +#endif +#if USE_PULSEAUDIO +#define simpleaudio_open_system_audio simpleaudio_open_stream_pulseaudio +#elif USE_ALSA +#define simpleaudio_open_system_audio simpleaudio_open_stream_alsa +#endif + if ( filename ) { #if !USE_SNDFILE fprintf(stderr, "E: This build of minimodem was configured without sndfile,\nE: so the --file flag is not supported.\n"); exit(1); #endif } else { -#if !USE_PULSEAUDIO - fprintf(stderr, "E: this build of minimodem was configured without pulseaudio,\nE: so only the --file mode is supported.\n"); +#ifndef simpleaudio_open_system_audio + fprintf(stderr, "E: this build of minimodem was configured without system audio support,\nE: so only the --file mode is supported.\n"); exit(1); #endif } @@ -496,9 +506,10 @@ main( int argc, char*argv[] ) if ( ! sa_out ) return 1; } -#if USE_PULSEAUDIO + +#ifdef simpleaudio_open_system_audio if ( ! sa_out ) - sa_out = simpleaudio_open_stream_pulseaudio(SA_STREAM_PLAYBACK, + sa_out = simpleaudio_open_system_audio(SA_STREAM_PLAYBACK, program_name, "output audio"); #endif if ( ! sa_out ) @@ -526,10 +537,10 @@ main( int argc, char*argv[] ) if ( ! sa ) return 1; } -#if USE_PULSEAUDIO +#ifdef simpleaudio_open_system_audio if ( ! sa ) - sa = simpleaudio_open_stream_pulseaudio(SA_STREAM_RECORD, - program_name, "input audio"); + sa = simpleaudio_open_system_audio(SA_STREAM_RECORD, + program_name, "input audio"); #endif if ( !sa ) return 1;