]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Let para_play depend on libreadline.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 5 Oct 2022 18:22:17 +0000 (20:22 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 19 Apr 2024 18:41:22 +0000 (20:41 +0200)
While para_client and para_audioc are suitable for non-interactive
use, e.g. in scripts, para_play can only be used interactively,
and its non-readline version is barely usable.

Rather than building a crippled version, teach the build and test
systems to skip para_play if the readline library is not installed.

configure.ac
play.c
t/t0005-man.sh
web/manual.md

index 92560e00ec50b7fa7ae4fcfd7d8966bdca2c63bf..bd8fbd53ba433a1981c3caf8e2cf809f23015400 100644 (file)
@@ -61,7 +61,7 @@ REQUIRE_EXECUTABLE([bison])
 REQUIRE_EXECUTABLE([flex])
 REQUIRE_EXECUTABLE([m4])
 
-executables="recv filter audioc write afh play"
+executables="recv filter audioc write afh"
 ########################################################################### osl
 STASH_FLAGS
 LIB_ARG_WITH([osl], [-losl])
@@ -739,78 +739,84 @@ afh_objs="$afh_errlist_objs"
 
 AC_SUBST(afh_objs, add_dot_o($afh_objs))
 ########################################################################## play
-play_errlist_objs="
-       play
-       fd
-       sched
-       buffer_tree
-       time
-       string
-       net
-       afh_recv
-       afh_common
-       wma_afh
-       wma_common
-       mp3_afh
-       recv_common
-       udp_recv
-       http_recv
-       dccp_recv
-       filter_common
-       fec
-       bitstream
-       imdct
-       wav_filter
-       compress_filter
-       amp_filter
-       prebuffer_filter
-       fecdec_filter
-       wmadec_filter
-       write_common
-       file_write
-       version
-       sync_filter
-       lsu
-"
-NEED_OGG_OBJECTS && play_errlist_objs="$play_errlist_objs ogg_afh_common"
-NEED_VORBIS_OBJECTS && {
-       play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
-}
-NEED_SPEEX_OBJECTS && {
-       play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
-}
-NEED_OPUS_OBJECTS &&
-       play_errlist_objs="$play_errlist_objs
-               opusdec_filter
-               opus_afh
-               opus_common
-       "
-NEED_FLAC_OBJECTS && {
-       play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
-}
-if test $HAVE_FAAD = yes; then
-       play_errlist_objs="$play_errlist_objs aac_afh aacdec_filter mp4"
-fi
-if test $HAVE_MAD = yes; then
-       play_errlist_objs="$play_errlist_objs mp3dec_filter"
-fi
-if test $HAVE_OSS = yes; then
-       play_errlist_objs="$play_errlist_objs oss_write"
-fi
-if test $HAVE_ALSA = yes; then
-       play_errlist_objs="$play_errlist_objs alsa_write"
-fi
-NEED_AO_OBJECTS && {
-       play_errlist_objs="$play_errlist_objs ao_write"
-}
 if test $HAVE_READLINE = yes; then
-       play_errlist_objs="$play_errlist_objs interactive"
-fi
-if test $HAVE_SAMPLERATE = yes; then
-       play_errlist_objs="$play_errlist_objs resample_filter check_wav"
-fi
+       build_play=yes
+       executables="$executables play"
+       play_errlist_objs="
+               play
+               fd
+               sched
+               buffer_tree
+               time
+               string
+               net
+               afh_recv
+               afh_common
+               wma_afh
+               wma_common
+               mp3_afh
+               recv_common
+               udp_recv
+               http_recv
+               dccp_recv
+               filter_common
+               fec
+               bitstream
+               imdct
+               wav_filter
+               compress_filter
+               amp_filter
+               prebuffer_filter
+               fecdec_filter
+               wmadec_filter
+               write_common
+               file_write
+               version
+               sync_filter
+               lsu
+       "
+       NEED_OGG_OBJECTS && play_errlist_objs="$play_errlist_objs ogg_afh_common"
+       NEED_VORBIS_OBJECTS && {
+               play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
+       }
+       NEED_SPEEX_OBJECTS && {
+               play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
+       }
+       NEED_OPUS_OBJECTS &&
+               play_errlist_objs="$play_errlist_objs
+                       opusdec_filter
+                       opus_afh
+                       opus_common
+               "
+       NEED_FLAC_OBJECTS && {
+               play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
+       }
+       if test $HAVE_FAAD = yes; then
+               play_errlist_objs="$play_errlist_objs aac_afh aacdec_filter mp4"
+       fi
+       if test $HAVE_MAD = yes; then
+               play_errlist_objs="$play_errlist_objs mp3dec_filter"
+       fi
+       if test $HAVE_OSS = yes; then
+               play_errlist_objs="$play_errlist_objs oss_write"
+       fi
+       if test $HAVE_ALSA = yes; then
+               play_errlist_objs="$play_errlist_objs alsa_write"
+       fi
+       NEED_AO_OBJECTS && {
+               play_errlist_objs="$play_errlist_objs ao_write"
+       }
+       if test $HAVE_READLINE = yes; then
+               play_errlist_objs="$play_errlist_objs interactive"
+       fi
+       if test $HAVE_SAMPLERATE = yes; then
+               play_errlist_objs="$play_errlist_objs resample_filter check_wav"
+       fi
 
-play_objs="$play_errlist_objs"
+       play_objs="$play_errlist_objs"
+else
+       build_play=no
+fi
 AC_SUBST(play_objs, add_dot_o($play_objs))
 ######################################################################### write
 write_errlist_objs="
@@ -875,6 +881,7 @@ audio format handlers: $audio_format_handlers
 
 exe: $executables
 para_server: $build_server
+para_play: $build_play
 para_gui: $build_gui
 para_mixer: $build_mixer
 para_client: $build_client
diff --git a/play.c b/play.c
index bd183b6b8dd48906e08cf142d7ff8c1e05aad48a..e6510b03b15843b0ebd01c6d022a6200a7a71fb7 100644 (file)
--- a/play.c
+++ b/play.c
@@ -24,6 +24,7 @@
 #include "recv.h"
 #include "write.h"
 #include "fd.h"
+#include "interactive.h"
 
 /** Array of error strings. */
 DEFINE_PARA_ERRLIST;
@@ -470,8 +471,6 @@ static void kill_stream(void)
                task_notify(pt->wn.task, E_EOF);
 }
 
-#ifdef HAVE_READLINE
-
 /* only called from com_prev(), nec. only if we have readline */
 static int previous_valid_file(void)
 {
@@ -488,8 +487,6 @@ static int previous_valid_file(void)
        return -E_NO_VALID_FILES;
 }
 
-#include "interactive.h"
-
 /*
  * Define the default (internal) key mappings and helper functions to get the
  * key sequence or the command from a key id, which is what we obtain from
@@ -1131,31 +1128,6 @@ static int session_post_monitor(__a_unused struct sched *s)
        return 0;
 }
 
-#else /* HAVE_READLINE */
-
-static int session_post_monitor(struct sched *s)
-{
-       char c;
-
-       if (!sched_read_ok(STDIN_FILENO, s))
-               return 0;
-       if (read(STDIN_FILENO, &c, 1))
-               do_nothing;
-       kill_stream();
-       return 1;
-}
-
-static void session_open(void)
-{
-}
-
-static void session_update_time_string(char *str, __a_unused unsigned len)
-{
-       printf("\r%s     ", str);
-       fflush(stdout);
-}
-#endif /* HAVE_READLINE */
-
 static void play_pre_monitor(struct sched *s, __a_unused void *context)
 {
        char state;
index ee1949c05a04d4fd4b81f2b9c847a403a753e2f5..307be1240a559dd5b8a1773a0b1dc1c2447e1a4f 100755 (executable)
@@ -58,7 +58,12 @@ else
                "grep_man '$regex' server"
 fi
 
-# para_play is always built
-regex='LIST OF COMMANDS.\{100,\}'
-test_expect_success 'para_play: play commands' "grep_man '$regex' play"
+test_require_objects 'play'
+missing_objects="$result"
+if [[ -n "$missing_objects" ]]; then
+       test_skip 'para_play' "missing object(s): $missing_objects"
+else
+       regex='LIST OF COMMANDS.\{100,\}'
+       test_expect_success 'para_play: play commands' "grep_man '$regex' play"
+fi
 test_done
index b5329ea07f3d8a2f9553f384c9129c4ad1a262e3..a2942d71ac6d1f63aab3ec8a08ee2cc7c516fe1f 100644 (file)
@@ -385,9 +385,10 @@ the ao writer (ESD, PulseAudio,...).  Debian package: `libao-dev`.
 para_gui. Debian package: `libncurses-dev`.
 
 - [GNU
-Readline](http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html). If
-this library (`libreadline-dev`) is installed, para_client, para_audioc
-and para_play support interactive sessions.
+Readline](http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html). Only if
+this library (`libreadline-dev`) is installed, para_play is built, Without it,
+para_client(1) and para_audioc(1) still work, but lack support for interactive
+sessions.
 
 Installation
 ------------