From 799a29ac430a70a24dc71e415c2a819cfe08dbd3 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 5 Oct 2022 20:22:17 +0200 Subject: [PATCH] Let para_play depend on libreadline. 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 | 149 ++++++++++++++++++++++++++----------------------- play.c | 30 +--------- t/t0005-man.sh | 11 +++- web/manual.md | 8 +-- 4 files changed, 91 insertions(+), 107 deletions(-) diff --git a/configure.ac b/configure.ac index b9ac3d0d..b9d6f5fb 100644 --- a/configure.ac +++ b/configure.ac @@ -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 4adedcc0..93035532 100644 --- 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; diff --git a/t/t0005-man.sh b/t/t0005-man.sh index ee1949c0..307be124 100755 --- a/t/t0005-man.sh +++ b/t/t0005-man.sh @@ -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 diff --git a/web/manual.md b/web/manual.md index 0db1e22c..3c49d6fb 100644 --- a/web/manual.md +++ b/web/manual.md @@ -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 ------------ -- 2.39.5