]> git.tue.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>
Sun, 26 May 2024 16:24:22 +0000 (18:24 +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 b9ac3d0d47a4dc2adcfd8b6c28468aab35c50601..b9d6f5fb1bd105310031b83001e4c07fcd420024 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 4adedcc0475a6a810513989499ab31b752d2a945..93035532f9f19190ba7680724e7d5aa7bcd481cb 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
@@ -1130,31 +1127,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 0db1e22c26fdee83b3df4aaf60bad0537e40a0f1..3c49d6fb8601b03b0e9b5908f34307faaae61e38 100644 (file)
@@ -384,10 +384,10 @@ the ao writer (ESD, PulseAudio,...).  Debian package: `libao-dev`.
 - [curses](ftp://ftp.gnu.org/pub/gnu/ncurses). Needed for
 para_gui. Debian package: `libncurses-dev`.
 
-- [GNU
-Readline](https://www.gnu.org/software/readline/). If
-this library (`libreadline-dev`) is installed, para_client, para_audioc
-and para_play support interactive sessions.
+- [GNU Readline](https://www.gnu.org/software/readline/). 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
 ------------