diff --git a/README b/README index 5d58e9b..ad6fb79 100644 --- a/README +++ b/README @@ -1,10 +1,10 @@ minimodem - software audio Bell-type or RTTY FSK modem -Copyright (C) 2011 Kamal Mostafa +Copyright (C) 2011-2012 Kamal Mostafa Minimodem is a command-line program which generates (or decodes) audio modem tones at any specified baud rate, emulating an old Bell-type or radio-teletype FSK modem. The tones can be played to (or recorded from) -the PulseAudio system or to an audio file. +the system audio (PulseAudio or ALSA) or to an audio file. Minimodem can be used to transfer data between nearby computers using an audio cable (or just via sound waves), or between remote computers using diff --git a/configure b/configure index 46758f7..ddcb68f 100755 --- a/configure +++ b/configure @@ -3299,13 +3299,12 @@ if test "${with_alsa+set}" = set; then : withval=$with_alsa; fi -if test "x$with_alsa" != "xyes"; then : +if test "x$with_alsa" == "xno"; then : # then use_alsa=0 else # else use_alsa=1 - with_pulseaudio=no # For now, ALSA precludes pulseaudio deps_packages+=" alsa" fi diff --git a/configure.ac b/configure.ac index b64f4e8..f557805 100644 --- a/configure.ac +++ b/configure.ac @@ -36,12 +36,11 @@ deps_packages+=" fftw3f" # ALSA AC_ARG_WITH([alsa], AS_HELP_STRING([--without-alsa], [build without ALSA support])) -AS_IF([test "x$with_alsa" != "xyes"], +AS_IF([test "x$with_alsa" == "xno"], # 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]) diff --git a/src/minimodem.1.in b/src/minimodem.1.in index c13ef67..3716cad 100644 --- a/src/minimodem.1.in +++ b/src/minimodem.1.in @@ -30,7 +30,7 @@ minimodem \- software audio Bell-type or RTTY FSK modem is a command-line program which generates (or decodes) audio modem tones at any specified baud rate, emulating an old Bell-type or radio-teletype FSK modem. The tones can be played to (or recorded from) -the PulseAudio system or to an audio file. +the system audio (PulseAudio or ALSA) or to an audio file. .PP .B minimodem can be used to transfer data between nearby computers using an audio @@ -71,6 +71,10 @@ encode or decode an audio file (extension sets audio format) .B \-q, \-\-quiet Do not report CARRIER / NOCARRIER or signal analysis metrics. .TP +.B \-A, \-\-alsa +Use ALSA as the audio output system instead of the default +PulseAudio (depending on build configuration options). +.TP .B \-V, \-\-version print program version .SH {baudmode} diff --git a/src/minimodem.c b/src/minimodem.c index 8bfa442..d2072b1 100644 --- a/src/minimodem.c +++ b/src/minimodem.c @@ -255,6 +255,7 @@ usage() " -T, --txstopbits {m.n}\n" " -q, --quiet\n" " -V, --version\n" + " -A, --alsa\n" " {baudmode}\n" " 1200 : Bell202 1200 bps --ascii\n" " 300 : Bell103 300 bps --ascii\n" @@ -283,6 +284,20 @@ main( int argc, char*argv[] ) float carrier_autodetect_threshold = 0.0; float bfsk_confidence_threshold = 0.6; + simpleaudio * (*simpleaudio_open_system_audio)() = NULL; + + /* configure the default system audio mechanism */ +#if USE_PULSEAUDIO + simpleaudio_open_system_audio = simpleaudio_open_stream_pulseaudio; +#elif USE_ALSA + simpleaudio_open_system_audio = simpleaudio_open_stream_alsa; +#else +# define _MINIMODEM_NO_SYSTEM_AUDIO +# if !USE_SNDFILE +# error At least one of {USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE} must be enabled! +# endif +#endif + program_name = strrchr(argv[0], '/'); if ( program_name ) program_name++; @@ -311,9 +326,10 @@ main( int argc, char*argv[] ) { "space", 1, 0, 'S' }, { "txstopbits", 1, 0, 'T' }, { "quiet", 0, 0, 'q' }, + { "alsa", 0, 0, 'A' }, { 0 } }; - c = getopt_long(argc, argv, "Vtrc:a85f:b:M:S:T:q", + c = getopt_long(argc, argv, "Vtrc:a85f:b:M:S:T:qA", long_options, &option_index); if ( c == -1 ) break; @@ -365,6 +381,14 @@ main( int argc, char*argv[] ) case 'q': quiet_mode = 1; break; + case 'A': +#if USE_ALSA + simpleaudio_open_system_audio = simpleaudio_open_stream_alsa; +#else + fprintf(stderr, "E: This build of minimodem was configured without alsa support.\n"); + exit(1); +#endif + break; default: usage(); } @@ -372,26 +396,13 @@ main( int argc, char*argv[] ) if ( TX_mode == -1 ) TX_mode = 0; -#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 { -#ifndef simpleaudio_open_system_audio +#ifdef _MINIMODEM_NO_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 @@ -507,11 +518,9 @@ main( int argc, char*argv[] ) return 1; } -#ifdef simpleaudio_open_system_audio if ( ! sa_out ) sa_out = simpleaudio_open_system_audio(SA_STREAM_PLAYBACK, program_name, "output audio"); -#endif if ( ! sa_out ) return 1; @@ -537,11 +546,10 @@ main( int argc, char*argv[] ) if ( ! sa ) return 1; } -#ifdef simpleaudio_open_system_audio + if ( ! sa ) sa = simpleaudio_open_system_audio(SA_STREAM_RECORD, program_name, "input audio"); -#endif if ( !sa ) return 1;