]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'refs/heads/t/manual'
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 14 Jul 2017 12:50:43 +0000 (14:50 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 14 Jul 2017 12:56:18 +0000 (14:56 +0200)
A couple of patches which merge the contents of the overview.pdf file
into the user manual. After this, the documentation no longer depends
on dia.

Cooking for six weeks.

* refs/heads/t/manual:
  manual: Expand description of para_play.
  manual: Omit level 3 headers from table of contents.
  manual: Combine overview.pdf and the user manual.
  manual: Remove text about permissions of /var/paraslash.
  manual: Correct format of para_client help output.
  manual: Add lopsub installation instructions to quick start.

Doxyfile
NEWS.md
afh.c
audiod.c
error.h
filter_common.c
m4/lls/server_cmd.suite.m4
net.c
osx_write.c [deleted file]
play.c
recv_common.c

index 7781c8e167a9b4b8d77bf0e89f8729e873096e8b..70c71261649c8367f8e512a96ec35806c921a996 100644 (file)
--- a/Doxyfile
+++ b/Doxyfile
@@ -795,10 +795,7 @@ EXCLUDE_SYMLINKS       = NO
 # Note that the wildcards are matched against the file with absolute path, so to
 # exclude all test directories for example use the pattern */test/*
 
-EXCLUDE_PATTERNS       = *.cmdline.* \
-                         gcc-compat.h \
-                         *.command_list.h \
-                         *.completion.h
+EXCLUDE_PATTERNS       = gcc-compat.h
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
 # (namespaces, classes, functions, etc.) that should be excluded from the
diff --git a/NEWS.md b/NEWS.md
index 60b942389ffe1a7d71a61ced088965995548d416..313446f82956fd1f344ee483a45dcef6d9436adb 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,13 @@
 NEWS
 ====
 
+------------------------------------------------
+0.6.1 (to be announced) "hyperbolic correlation"
+------------------------------------------------
+
+- The contents of overview.pdf have been integrated into the user
+  manual.
+
 -------------------------------
 0.6.0 (2017-04-28) "fuzzy flux"
 -------------------------------
diff --git a/afh.c b/afh.c
index 4955b3cfea12e6e7abf93b672d4501cb1e46ca85..9d40caeb8b33fb7442bb1f822af7f6eba0a2c332 100644 (file)
--- a/afh.c
+++ b/afh.c
@@ -20,7 +20,7 @@
 /** Array of error strings. */
 DEFINE_PARA_ERRLIST;
 
-struct lls_parse_result *lpr;
+static struct lls_parse_result *lpr;
 
 #define CMD_PTR (lls_cmd(0, afh_suite))
 #define OPT_RESULT(_name) (lls_opt_result(LSG_AFH_PARA_AFH_OPT_ ## _name, lpr))
index ead29e86b96dae01921ab4167f7231e308e7b76e..74d0ce233b46407c208022229df9a5da26e88f3b 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1001,7 +1001,7 @@ static int init_default_filters(void)
                }
                /* add "dec" to audio format name */
                tmp = make_message("%sdec", audio_formats[i]);
-               for (j = 0; filter_get(j); j++)
+               for (j = 1; filter_get(j); j++)
                        if (!strcmp(tmp, filter_name(j)))
                                break;
                free(tmp);
diff --git a/error.h b/error.h
index ea8f82c4fcfb62cddb299828f9ff730aa7cec7cc..407859ca5a591b42ca8a489ee58aeeb76e5b3c8e 100644 (file)
--- a/error.h
+++ b/error.h
@@ -8,6 +8,7 @@
 
 /** Codes and messages. */
 #define PARA_ERRORS \
+       PARA_ERROR(SUCCESS, "success"), \
        PARA_ERROR(AACDEC_INIT, "failed to init aac decoder"), \
        PARA_ERROR(AAC_DECODE, "aac decode error"), \
        PARA_ERROR(ACL_PERM, "access denied by acl"), \
index 991b3a1e5a96dc47d7cc6594922883856aeac4d9..b406951e8ff145542e9ad579bde5311b7e3be1aa 100644 (file)
  *
  * \param filter_num Between zero and NUM_SUPPORTED_FILTERS, inclusively.
  *
- * \return Pointer to the filter identified by the given filter number.
+ * \return Pointer to the filter identified by the given filter number, or
+ * NULL if the filter number is out of range.
  *
- * It is a fatal error if the given number is out of range. In this case
- * the function aborts.
+ * \sa filter_name().
  */
 const struct filter *filter_get(int filter_num)
 {
-       assert(filter_num >= 1);
-       assert(filter_num <= LSG_NUM_FILTER_CMD_SUBCOMMANDS);
+       if (filter_num < 1 || filter_num > LSG_NUM_FILTER_CMD_SUBCOMMANDS)
+               return NULL;
        return lls_user_data(FILTER_CMD(filter_num));
 }
 
@@ -45,8 +45,18 @@ static inline bool filter_supported(int filter_num)
        return lls_user_data(FILTER_CMD(filter_num));
 }
 
+/**
+ * Return the name of a filter, given its number.
+ *
+ * \param filter_num See \ref filter_get().
+ *
+ * \return A pointer to a string literal, or NULL if filter_num is out of
+ * range. The caller must not attempt to call free(3) on the returned pointer.
+ */
 const char *filter_name(int filter_num)
 {
+       if (filter_num < 1 || filter_num > LSG_NUM_FILTER_CMD_SUBCOMMANDS)
+               return NULL;
        return lls_command_name(FILTER_CMD(filter_num));
 }
 
index 751998adb992523fcdd62394f5a40be18ae05b4e..e2bd162d19b5161a38c9b404607842a0115c4a48 100644 (file)
@@ -259,8 +259,8 @@ aux_info_prefix = Permissions:
                        --listing-mode, this argument may either be a single character or a
                        word, according to the following list.
 
-                       path (p). Sort alphabetically by path or basename (see -p). This is
-                       the default if --sort is not given.
+                       path (p). Sort alphabetically by path or basename, depending on
+                       whether -b is given. This is the default if --sort is not given.
 
                        score (s). Iterate over the entries of the score table, rather than
                        the audio file table. This sort order implies --admissible, since
diff --git a/net.c b/net.c
index 6c23fdd9ce6b248e562e84c23d3e089e4484b178..50243673eaf9f3e22edf7aa0cea0247b5917cdeb 100644 (file)
--- a/net.c
+++ b/net.c
@@ -603,7 +603,7 @@ static inline int estimated_header_overhead(const int af_type)
  */
 int generic_max_transport_msg_size(int sockfd)
 {
-       struct sockaddr_storage ss = {0};
+       struct sockaddr_storage ss = {.ss_family = 0};
        socklen_t sslen = sizeof(ss);
        int af_type = AF_INET;
 
@@ -629,7 +629,7 @@ int generic_max_transport_msg_size(int sockfd)
  */
 char *remote_name(int fd)
 {
-       struct sockaddr_storage ss = {0};
+       struct sockaddr_storage ss = {.ss_family = 0};
        const struct sockaddr *sa;
        socklen_t sslen = sizeof(ss);
        char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
diff --git a/osx_write.c b/osx_write.c
deleted file mode 100644 (file)
index 0517892..0000000
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (C) 2006 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
-
-/** \file osx_write.c paraslash's output plugin for MacOs */
-
-/*
- * based on mosx-mpg123, by Guillaume Outters and Steven A. Kortze
- * <skortze@sourceforge.net>
- */
-
-#include <regex.h>
-#include <sys/types.h>
-#include <lopsub.h>
-
-#include "write_cmd.lsg.h"
-#include "para.h"
-#include "fd.h"
-#include "string.h"
-#include "list.h"
-#include "sched.h"
-#include "buffer_tree.h"
-#include "write.h"
-#include "ipc.h"
-#include "error.h"
-
-#include <CoreServices/CoreServices.h>
-#include <AudioUnit/AudioUnit.h>
-#include <AudioToolbox/AudioToolbox.h>
-
-/** Data specific to the osx writer. */
-struct private_osx_write_data {
-       /** The main CoreAudio handle. */
-       AudioUnit audio_unit;
-       /** True if we wrote some audio data. */
-       bool playing;
-       /** Sample rate of the current audio stream. */
-       unsigned sample_rate;
-       /** Sample format of the current audio stream */
-       unsigned sample_format;
-       /** Number of channels of the current audio stream. */
-       unsigned channels;
-       /**
-        * Serializes access to buffer tree nodes between the writer and
-        * the callback which runs in a different thread.
-        */
-       int mutex;
-       /**
-        * The btr node of the callback.
-        *
-        * Although access to the btr node is serialized between the writer and
-        * the callback via the above mutex, this does not stop other buffer
-        * tree nodes, for example the decoder, to race against the osx
-        * callback.
-        *
-        * However, since all operations on buffer tree nodes are local in the
-        * sense that they only affect one level in the buffer tree (i.e.
-        * parent or child nodes, but not the grandparent or the
-        * grandchildren), we may work around this problem by using another
-        * buffer tree node for the callback.
-        *
-        * The writer grabs the mutex in its post_select method and pushes down
-        * the buffers to the callback node.
-        */
-       struct btr_node *callback_btrn;
-};
-
-/* This function writes the address and the number of bytes to one end of the socket.
- * The post_select() function then fills the buffer and notifies the callback also
- * through the socket.
- */
-static OSStatus osx_callback(void *cb_arg, __a_unused AudioUnitRenderActionFlags *af,
-               __a_unused const AudioTimeStamp *ts, __a_unused  UInt32 bus_number,
-               __a_unused UInt32 num_frames, AudioBufferList *abl)
-{
-       int i;
-       struct writer_node *wn = cb_arg;
-       struct private_osx_write_data *powd;
-       size_t samples_have, samples_want = 0;
-
-       powd = wn->private_data;
-       mutex_lock(powd->mutex);
-       powd = wn->private_data;
-       if (!powd || !wn->btrn)
-               goto out;
-       /*
-        * We fill with zeros if no data was yet written and we do not have
-        * enough to fill all buffers.
-        */
-       if (!powd->playing) {
-               size_t want = 0, have =
-                       btr_get_input_queue_size(powd->callback_btrn);
-               for (i = 0; i < abl->mNumberBuffers; i++)
-                       want += abl->mBuffers[i].mDataByteSize;
-               if (have < want) {
-                       PARA_DEBUG_LOG("deferring playback (have = %zu < %zu = want)\n",
-                               have, want);
-                       for (i = 0; i < abl->mNumberBuffers; i++)
-                               memset(abl->mBuffers[i].mData, 0,
-                                       abl->mBuffers[i].mDataByteSize);
-                       goto out;
-               }
-               powd->playing = true;
-       }
-
-       for (i = 0; i < abl->mNumberBuffers; i++) {
-               /* what we have to fill */
-               void *dest = abl->mBuffers[i].mData;
-               size_t sz = abl->mBuffers[i].mDataByteSize, samples, bytes;
-
-               samples_want = sz / wn->min_iqs;
-               while (samples_want > 0) {
-                       char *buf;
-                       btr_merge(powd->callback_btrn, wn->min_iqs);
-                       samples_have = btr_next_buffer(powd->callback_btrn, &buf) / wn->min_iqs;
-                       //PARA_INFO_LOG("i: %d want %zu samples to addr %p, have: %zu\n", i, samples_want,
-                       //      dest, samples_have);
-                       samples = PARA_MIN(samples_have, samples_want);
-                       if (samples == 0)
-                               break;
-                       bytes = samples * wn->min_iqs;
-                       memcpy(dest, buf, bytes);
-                       btr_consume(powd->callback_btrn, bytes);
-                       samples_want -= samples;
-                       dest += bytes;
-               }
-               if (samples_want == 0)
-                       continue;
-               if (btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF) >= 0)
-                       PARA_INFO_LOG("zero-padding (%zu samples)\n",
-                               samples_want);
-               memset(dest, 0, samples_want * wn->min_iqs);
-               break;
-       }
-out:
-       mutex_unlock(powd->mutex);
-       return noErr;
-}
-
-static int core_audio_init(struct writer_node *wn)
-{
-       struct private_osx_write_data *powd = para_calloc(sizeof(*powd));
-       Component comp;
-       int ret;
-       int32_t val;
-       AURenderCallbackStruct input_callback;
-       ComponentDescription desc = {
-               .componentType = kAudioUnitType_Output,
-               .componentSubType = kAudioUnitSubType_DefaultOutput,
-               .componentManufacturer = kAudioUnitManufacturer_Apple,
-       };
-       AudioStreamBasicDescription format = {
-               .mFormatID = kAudioFormatLinearPCM,
-               .mFramesPerPacket = 1,
-       };
-       struct btr_node *btrn = wn->btrn;
-       struct btr_node_description bnd;
-
-       PARA_INFO_LOG("wn: %p\n", wn);
-       ret = -E_DEFAULT_COMP;
-       comp = FindNextComponent(NULL, &desc);
-       if (!comp)
-               goto e0;
-       ret = -E_OPEN_COMP;
-       if (OpenAComponent(comp, &powd->audio_unit))
-               goto e0;
-       ret = -E_UNIT_INIT;
-       if (AudioUnitInitialize(powd->audio_unit))
-               goto e1;
-       get_btr_sample_rate(btrn, &val);
-       powd->sample_rate = val;
-       get_btr_channels(btrn, &val);
-       powd->channels = val;
-       get_btr_sample_format(btrn, &val);
-       powd->sample_format = val;
-       /*
-        * Choose PCM format. We tell the Output Unit what format we're going
-        * to supply data to it. This is necessary if you're providing data
-        * through an input callback AND you want the DefaultOutputUnit to do
-        * any format conversions necessary from your format to the device's
-        * format.
-        */
-
-       format.mSampleRate = powd->sample_rate;
-       format.mChannelsPerFrame = powd->channels;
-
-       switch (powd->sample_format) {
-       case SF_S8:
-       case SF_U8:
-               wn->min_iqs = powd->channels;
-               format.mBitsPerChannel = 8;
-               format.mBytesPerPacket = powd->channels;
-               format.mFormatFlags |= kLinearPCMFormatFlagIsPacked;
-               break;
-       default:
-               wn->min_iqs = powd->channels * 2;
-               format.mBytesPerPacket = powd->channels * 2;
-               format.mBitsPerChannel = 16;
-               format.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
-       }
-       format.mBytesPerFrame = format.mBytesPerPacket;
-
-       if (powd->sample_format == SF_S16_BE || powd->sample_format == SF_U16_BE)
-               format.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
-
-       input_callback = (AURenderCallbackStruct){osx_callback, wn};
-       ret = -E_STREAM_FORMAT;
-       if (AudioUnitSetProperty(powd->audio_unit, kAudioUnitProperty_StreamFormat,
-                       kAudioUnitScope_Input, 0, &format, sizeof(format)))
-               goto e2;
-       ret = -E_ADD_CALLBACK;
-       if (AudioUnitSetProperty(powd->audio_unit, kAudioUnitProperty_SetRenderCallback,
-                       kAudioUnitScope_Input, 0, &input_callback,
-                       sizeof(input_callback)) < 0)
-               goto e2;
-
-       ret = mutex_new();
-       if (ret < 0)
-               goto e2;
-       powd->mutex = ret;
-       /* set up callback btr node */
-       bnd.name = "cb_node";
-       bnd.parent = btrn;
-       bnd.child = NULL;
-       bnd.handler = NULL;
-       bnd.context = powd;
-       powd->callback_btrn = btr_new_node(&bnd);
-       wn->private_data = powd;
-       return 1;
-e2:
-       AudioUnitUninitialize(powd->audio_unit);
-e1:
-       CloseComponent(powd->audio_unit);
-e0:
-       free(powd);
-       wn->private_data = NULL;
-       return ret;
-}
-
-static void osx_write_close(struct writer_node *wn)
-{
-       struct private_osx_write_data *powd = wn->private_data;
-
-       if (!powd)
-               return;
-       PARA_INFO_LOG("closing writer node %p\n", wn);
-       mutex_destroy(powd->mutex);
-       free(powd);
-       wn->private_data = NULL;
-}
-
-/* must be called with the mutex held */
-static inline bool need_drain_delay(struct private_osx_write_data *powd)
-{
-       if (!powd->playing)
-               return false;
-       return btr_get_input_queue_size(powd->callback_btrn) != 0;
-}
-
-static void osx_write_pre_select(struct sched *s, void *context)
-{
-       struct writer_node *wn = context;
-       struct private_osx_write_data *powd = wn->private_data;
-       int ret;
-       bool drain_delay_nec = false;
-
-       if (!powd) {
-               ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
-               if (ret != 0)
-                       sched_min_delay(s);
-               return;
-       }
-
-       mutex_lock(powd->mutex);
-       ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_INTERNAL);
-       if (ret < 0)
-               drain_delay_nec = need_drain_delay(powd);
-       mutex_unlock(powd->mutex);
-
-       if (drain_delay_nec)
-               return sched_request_timeout_ms(50, s);
-       if (ret != 0)
-               return sched_min_delay(s);
-       sched_request_timeout_ms(50, s);
-}
-
-static int osx_write_post_select(__a_unused struct sched *s, void *context)
-{
-       struct writer_node *wn = context;
-       struct private_osx_write_data *powd = wn->private_data;
-       struct btr_node *btrn = wn->btrn;
-       int ret;
-
-       ret = task_get_notification(wn->task);
-       if (ret < 0)
-               goto fail;
-       if (!powd) {
-               ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF);
-               if (ret == 0)
-                       return 0;
-               if (ret < 0)
-                       goto fail;
-               ret = core_audio_init(wn);
-               if (ret < 0)
-                       goto fail;
-               powd = wn->private_data;
-               ret = -E_UNIT_START;
-               if (AudioOutputUnitStart(powd->audio_unit) != noErr) {
-                       AudioUnitUninitialize(powd->audio_unit);
-                       CloseComponent(powd->audio_unit);
-                       btr_remove_node(&powd->callback_btrn);
-                       goto fail;
-               }
-       }
-       mutex_lock(powd->mutex);
-       ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_INTERNAL);
-       if (ret > 0)
-               btr_pushdown(btrn);
-       if (ret < 0 && need_drain_delay(powd))
-               ret = 0;
-       mutex_unlock(powd->mutex);
-       if (ret >= 0)
-               return 0;
-fail:
-       assert(ret < 0);
-       if (powd && powd->callback_btrn) {
-               AudioOutputUnitStop(powd->audio_unit);
-               AudioUnitUninitialize(powd->audio_unit);
-               CloseComponent(powd->audio_unit);
-               btr_remove_node(&powd->callback_btrn);
-       }
-       btr_remove_node(&wn->btrn);
-       PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
-       return ret;
-}
-
-struct writer lsg_write_cmd_com_osx_user_data = {
-       .close = osx_write_close,
-       .pre_select = osx_write_pre_select,
-       .post_select = osx_write_post_select,
-};
diff --git a/play.c b/play.c
index 10451039726037cf0d0628d8e5d5ddb1acb75b45..56838e822112c422ff3ec78da25d0d7b7dcaf033 100644 (file)
--- a/play.c
+++ b/play.c
@@ -109,8 +109,7 @@ struct play_task {
        char *afhi_txt;
 };
 
-typedef int (*play_cmd_handler_t)(struct play_task *pt,
-               struct lls_parse_result *lpr);
+typedef int (*play_cmd_handler_t)(struct lls_parse_result *lpr);
 struct play_command_info {
        play_cmd_handler_t handler;
 };
@@ -127,7 +126,7 @@ INIT_STDERR_LOGGING(loglevel);
 char *stat_item_values[NUM_STAT_ITEMS] = {NULL};
 
 static struct sched sched = {.max_fileno = 0};
-static struct play_task play_task;
+static struct play_task play_task, *pt = &play_task;
 
 #define AFH_RECV_CMD (lls_cmd(LSG_RECV_CMD_CMD_AFH, recv_cmd_suite))
 #define AFH_RECV ((struct receiver *)lls_user_data(AFH_RECV_CMD))
@@ -228,7 +227,7 @@ fail:
        exit(EXIT_FAILURE);
 }
 
-static char get_playback_state(struct play_task *pt)
+static char get_playback_state(void)
 {
        switch (pt->rq) {
        case CRT_NONE: return pt->playing? 'P' : 'U';
@@ -239,9 +238,9 @@ static char get_playback_state(struct play_task *pt)
        assert(false);
 };
 
-static long unsigned get_play_time(struct play_task *pt)
+static long unsigned get_play_time(void)
 {
-       char state = get_playback_state(pt);
+       char state = get_playback_state();
        long unsigned result;
 
        if (state != 'P' && state != 'U')
@@ -263,7 +262,7 @@ static long unsigned get_play_time(struct play_task *pt)
 }
 
 
-static void wipe_receiver_node(struct play_task *pt)
+static void wipe_receiver_node(void)
 {
        PARA_NOTICE_LOG("cleaning up receiver node\n");
        btr_remove_node(&pt->rn.btrn);
@@ -273,7 +272,7 @@ static void wipe_receiver_node(struct play_task *pt)
 }
 
 /* returns: 0 not eof, 1: eof, < 0: fatal error.  */
-static int get_playback_error(struct play_task *pt)
+static int get_playback_error(void)
 {
        int err;
 
@@ -292,13 +291,13 @@ static int get_playback_error(struct play_task *pt)
        return err;
 }
 
-static int eof_cleanup(struct play_task *pt)
+static int eof_cleanup(void)
 {
        const struct filter *decoder;
        const struct writer *w = writer_get(-1); /* default writer */
        int ret;
 
-       ret = get_playback_error(pt);
+       ret = get_playback_error();
        if (ret == 0)
                return ret;
        PARA_NOTICE_LOG("cleaning up wn/fn nodes\n");
@@ -324,7 +323,7 @@ static int eof_cleanup(struct play_task *pt)
         * paused.
         */
        if (ret < 0)
-               wipe_receiver_node(pt);
+               wipe_receiver_node();
        return ret;
 }
 
@@ -352,7 +351,7 @@ static struct btr_node *new_recv_btrn(struct receiver_node *rn)
                        .handler = AFH_RECV->execute));
 }
 
-static int open_new_file(struct play_task *pt)
+static int open_new_file(void)
 {
        int ret;
        const char *path = get_playlist_file(pt->next_file);
@@ -360,7 +359,7 @@ static int open_new_file(struct play_task *pt)
        char *argv[] = {"play", "-f", tmp, "-b", "0", NULL};
 
        PARA_NOTICE_LOG("next file: %s\n", path);
-       wipe_receiver_node(pt);
+       wipe_receiver_node();
        pt->start_chunk = 0;
        pt->rn.btrn = new_recv_btrn(&pt->rn);
        ret = lls(lls_parse(ARRAY_SIZE(argv) - 1, argv, AFH_RECV_CMD,
@@ -400,11 +399,11 @@ static int open_new_file(struct play_task *pt)
        }
        return 1;
 fail:
-       wipe_receiver_node(pt);
+       wipe_receiver_node();
        return ret;
 }
 
-static int load_file(struct play_task *pt)
+static int load_file(void)
 {
        const char *af;
        char *tmp, buf[20];
@@ -414,7 +413,7 @@ static int load_file(struct play_task *pt)
 
        btr_remove_node(&pt->rn.btrn);
        if (!pt->rn.receiver || pt->next_file != pt->current_file) {
-               ret = open_new_file(pt);
+               ret = open_new_file();
                if (ret < 0)
                        return ret;
        } else {
@@ -468,11 +467,11 @@ static int load_file(struct play_task *pt)
        register_writer_node(&pt->wn, pt->fn.btrn, &sched);
        return 1;
 fail:
-       wipe_receiver_node(pt);
+       wipe_receiver_node();
        return ret;
 }
 
-static int next_valid_file(struct play_task *pt)
+static int next_valid_file(void)
 {
        int i, j = pt->current_file;
        unsigned num_inputs = lls_num_inputs(play_lpr);
@@ -485,20 +484,20 @@ static int next_valid_file(struct play_task *pt)
        return -E_NO_VALID_FILES;
 }
 
-static int load_next_file(struct play_task *pt)
+static int load_next_file(void)
 {
        int ret;
 
 again:
        if (pt->rq == CRT_NONE) {
                pt->start_chunk = 0;
-               ret = next_valid_file(pt);
+               ret = next_valid_file();
                if (ret < 0)
                        return ret;
                pt->next_file = ret;
        } else if (pt->rq == CRT_REPOS)
                pt->next_file = pt->current_file;
-       ret = load_file(pt);
+       ret = load_file();
        if (ret < 0) {
                PARA_ERROR_LOG("%s: marking file as invalid\n",
                        para_strerror(-ret));
@@ -511,7 +510,7 @@ again:
        return ret;
 }
 
-static void kill_stream(struct play_task *pt)
+static void kill_stream(void)
 {
        if (pt->wn.task)
                task_notify(pt->wn.task, E_EOF);
@@ -520,7 +519,7 @@ static void kill_stream(struct play_task *pt)
 #ifdef HAVE_READLINE
 
 /* only called from com_prev(), nec. only if we have readline */
-static int previous_valid_file(struct play_task *pt)
+static int previous_valid_file(void)
 {
        int i, j = pt->current_file;
        unsigned num_inputs = lls_num_inputs(play_lpr);
@@ -710,7 +709,6 @@ I9E_DUMMY_COMPLETER(ls);
 I9E_DUMMY_COMPLETER(info);
 I9E_DUMMY_COMPLETER(play);
 I9E_DUMMY_COMPLETER(pause);
-I9E_DUMMY_COMPLETER(stop);
 I9E_DUMMY_COMPLETER(tasks);
 I9E_DUMMY_COMPLETER(quit);
 I9E_DUMMY_COMPLETER(ff);
@@ -730,7 +728,7 @@ static struct i9e_completer pp_completers[] = {
        {.name = NULL}
 };
 
-static void attach_stdout(struct play_task *pt, const char *name)
+static void attach_stdout(const char *name)
 {
        if (pt->btrn)
                return;
@@ -739,20 +737,19 @@ static void attach_stdout(struct play_task *pt, const char *name)
        i9e_attach_to_stdout(pt->btrn);
 }
 
-static void detach_stdout(struct play_task *pt)
+static void detach_stdout(void)
 {
        btr_remove_node(&pt->btrn);
 }
 
-static int com_quit(struct play_task *pt,
-               __a_unused struct lls_parse_result *lpr)
+static int com_quit(__a_unused struct lls_parse_result *lpr)
 {
        pt->rq = CRT_TERM_RQ;
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(quit);
 
-static int com_help(struct play_task *pt, struct lls_parse_result *lpr)
+static int com_help(struct lls_parse_result *lpr)
 {
        int i, ret;
        char *buf, *errctx;
@@ -805,8 +802,7 @@ static int com_help(struct play_task *pt, struct lls_parse_result *lpr)
 }
 EXPORT_PLAY_CMD_HANDLER(help);
 
-static int com_info(struct play_task *pt,
-               __a_unused struct lls_parse_result *lpr)
+static int com_info(__a_unused struct lls_parse_result *lpr)
 {
        char *buf;
        size_t sz;
@@ -821,7 +817,7 @@ static int com_info(struct play_task *pt,
 }
 EXPORT_PLAY_CMD_HANDLER(info);
 
-static void list_file(struct play_task *pt, int num)
+static void list_file(int num)
 {
        char *buf;
        size_t sz;
@@ -831,8 +827,7 @@ static void list_file(struct play_task *pt, int num)
        btr_add_output(buf, sz, pt->btrn);
 }
 
-static int com_tasks(struct play_task *pt,
-               __a_unused struct lls_parse_result *lpr)
+static int com_tasks(__a_unused struct lls_parse_result *lpr)
 {
        static char state;
        char *buf;
@@ -840,26 +835,25 @@ static int com_tasks(struct play_task *pt,
 
        buf = get_task_list(&sched);
        btr_add_output(buf, strlen(buf), pt->btrn);
-       state = get_playback_state(pt);
+       state = get_playback_state();
        sz = xasprintf(&buf, "state: %c\n", state);
        btr_add_output(buf, sz, pt->btrn);
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(tasks);
 
-static int com_ls(struct play_task *pt,
-       __a_unused struct lls_parse_result *lpr)
+static int com_ls(__a_unused struct lls_parse_result *lpr)
 {
        int i;
        unsigned num_inputs = lls_num_inputs(play_lpr);
 
        for (i = 0; i < num_inputs; i++)
-               list_file(pt, i);
+               list_file(i);
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(ls);
 
-static int com_play(struct play_task *pt, struct lls_parse_result *lpr)
+static int com_play(struct lls_parse_result *lpr)
 {
        int32_t x;
        int ret;
@@ -872,7 +866,7 @@ static int com_play(struct play_task *pt, struct lls_parse_result *lpr)
                free(errctx);
                return ret;
        }
-       state = get_playback_state(pt);
+       state = get_playback_state();
        if (lls_num_inputs(lpr) == 0) {
                if (state == 'P')
                        return 0;
@@ -886,24 +880,23 @@ static int com_play(struct play_task *pt, struct lls_parse_result *lpr)
                return ret;
        if (x < 0 || x >= lls_num_inputs(play_lpr))
                return -ERRNO_TO_PARA_ERROR(EINVAL);
-       kill_stream(pt);
+       kill_stream();
        pt->next_file = x;
        pt->rq = CRT_FILE_CHANGE;
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(play);
 
-static int com_pause(struct play_task *pt,
-               __a_unused struct lls_parse_result *lpr)
+static int com_pause(__a_unused struct lls_parse_result *lpr)
 {
        char state;
        long unsigned seconds, ss;
 
-       state = get_playback_state(pt);
+       state = get_playback_state();
        pt->playing = false;
        if (state != 'P')
                return 0;
-       seconds = get_play_time(pt);
+       seconds = get_play_time();
        pt->playing = false;
        ss = 0;
        if (pt->seconds > 0)
@@ -911,20 +904,19 @@ static int com_pause(struct play_task *pt,
        ss = PARA_MAX(ss, 0UL);
        ss = PARA_MIN(ss, pt->num_chunks);
        pt->start_chunk = ss;
-       kill_stream(pt);
+       kill_stream();
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(pause);
 
-static int com_prev(struct play_task *pt,
-       __a_unused struct lls_parse_result *lpr)
+static int com_prev(__a_unused struct lls_parse_result *lpr)
 {
        int ret;
 
-       ret = previous_valid_file(pt);
+       ret = previous_valid_file();
        if (ret < 0)
                return ret;
-       kill_stream(pt);
+       kill_stream();
        pt->next_file = ret;
        pt->rq = CRT_FILE_CHANGE;
        pt->start_chunk = 0;
@@ -932,15 +924,14 @@ static int com_prev(struct play_task *pt,
 }
 EXPORT_PLAY_CMD_HANDLER(prev);
 
-static int com_next(struct play_task *pt,
-               __a_unused struct lls_parse_result *lpr)
+static int com_next(__a_unused struct lls_parse_result *lpr)
 {
        int ret;
 
-       ret = next_valid_file(pt);
+       ret = next_valid_file();
        if (ret < 0)
                return ret;
-       kill_stream(pt);
+       kill_stream();
        pt->next_file = ret;
        pt->rq = CRT_FILE_CHANGE;
        pt->start_chunk = 0;
@@ -948,23 +939,21 @@ static int com_next(struct play_task *pt,
 }
 EXPORT_PLAY_CMD_HANDLER(next);
 
-static int com_fg(struct play_task *pt,
-               __a_unused struct lls_parse_result *lpr)
+static int com_fg(__a_unused struct lls_parse_result *lpr)
 {
        pt->background = false;
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(fg);
 
-static int com_bg(struct play_task *pt,
-       __a_unused struct lls_parse_result *lpr)
+static int com_bg(__a_unused struct lls_parse_result *lpr)
 {
        pt->background = true;
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(bg);
 
-static int com_jmp(struct play_task *pt, struct lls_parse_result *lpr)
+static int com_jmp(struct lls_parse_result *lpr)
 {
        int32_t percent;
        int ret;
@@ -983,19 +972,19 @@ static int com_jmp(struct play_task *pt, struct lls_parse_result *lpr)
        if (percent < 0 || percent > 100)
                return -ERRNO_TO_PARA_ERROR(EINVAL);
        if (percent == 100)
-               return com_next(pt, NULL);
+               return com_next(NULL);
        if (pt->playing && !pt->fn.btrn)
                return 0;
        pt->start_chunk = percent * pt->num_chunks / 100;
        if (!pt->playing)
                return 0;
        pt->rq = CRT_REPOS;
-       kill_stream(pt);
+       kill_stream();
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(jmp);
 
-static int com_ff(struct play_task *pt, struct lls_parse_result *lpr)
+static int com_ff(struct lls_parse_result *lpr)
 {
        int32_t seconds;
        char *errctx;
@@ -1013,7 +1002,7 @@ static int com_ff(struct play_task *pt, struct lls_parse_result *lpr)
                return ret;
        if (pt->playing && !pt->fn.btrn)
                return 0;
-       seconds += get_play_time(pt);
+       seconds += get_play_time();
        seconds = PARA_MIN(seconds, (typeof(seconds))pt->seconds - 4);
        seconds = PARA_MAX(seconds, 0);
        pt->start_chunk = pt->num_chunks * seconds / pt->seconds;
@@ -1022,12 +1011,12 @@ static int com_ff(struct play_task *pt, struct lls_parse_result *lpr)
        if (!pt->playing)
                return 0;
        pt->rq = CRT_REPOS;
-       kill_stream(pt);
+       kill_stream();
        return 0;
 }
 EXPORT_PLAY_CMD_HANDLER(ff);
 
-static int run_command(char *line, struct play_task *pt)
+static int run_command(char *line)
 {
        int ret, argc;
        char **argv = NULL;
@@ -1036,7 +1025,7 @@ static int run_command(char *line, struct play_task *pt)
        struct lls_parse_result *lpr;
        const struct lls_command *cmd;
 
-       attach_stdout(pt, __FUNCTION__);
+       attach_stdout(__FUNCTION__);
        ret = create_argv(line, " ", &argv);
        if (ret < 0)
                goto out;
@@ -1051,7 +1040,7 @@ static int run_command(char *line, struct play_task *pt)
        if (ret < 0)
                goto out;
        pci = lls_user_data(cmd);
-       ret = pci->handler(pt, lpr);
+       ret = pci->handler(lpr);
        lls_free_parse_result(lpr, cmd);
 out:
        if (errctx)
@@ -1063,12 +1052,11 @@ out:
 
 static int play_i9e_line_handler(char *line)
 {
-       return run_command(line, &play_task);
+       return run_command(line);
 }
 
 static int play_i9e_key_handler(int key)
 {
-       struct play_task *pt = &play_task;
        int idx = get_key_map_idx(key);
        char *seq = get_key_map_seq(key);
        char *cmd = get_key_map_cmd(key);
@@ -1077,7 +1065,7 @@ static int play_i9e_key_handler(int key)
        PARA_NOTICE_LOG("pressed %d: %s key #%d (%s -> %s)\n",
                key, internal? "internal" : "user-defined",
                idx, seq, cmd);
-       run_command(cmd, pt);
+       run_command(cmd);
        free(seq);
        free(cmd);
        pt->next_update = *now;
@@ -1094,7 +1082,7 @@ static struct i9e_client_info ici = {
 
 static void sigint_handler(int sig)
 {
-       play_task.background = true;
+       pt->background = true;
        i9e_signal_dispatch(sig);
 }
 
@@ -1103,7 +1091,7 @@ static void sigint_handler(int sig)
  * stderr. Once the i9e subsystem has been initialized, we switch to the i9e
  * log facility.
  */
-static void session_open(struct play_task *pt)
+static void session_open(void)
 {
        int ret;
        char *history_file;
@@ -1147,7 +1135,7 @@ out:
        exit(EXIT_FAILURE);
 }
 
-static void session_update_time_string(struct play_task *pt, char *str, unsigned len)
+static void session_update_time_string(char *str, unsigned len)
 {
        if (pt->background)
                return;
@@ -1172,30 +1160,30 @@ static void session_update_time_string(struct play_task *pt, char *str, unsigned
  * terminates. Subsequent calls to i9e_get_error() then return negative and we
  * are allowed to call i9e_close() and terminate as well.
  */
-static int session_post_select(__a_unused struct sched *s, struct play_task *pt)
+static int session_post_select(__a_unused struct sched *s)
 {
        int ret;
 
        if (pt->background)
-               detach_stdout(pt);
+               detach_stdout();
        else
-               attach_stdout(pt, __FUNCTION__);
+               attach_stdout(__FUNCTION__);
        ret = i9e_get_error();
        if (ret < 0) {
-               kill_stream(pt);
+               kill_stream();
                i9e_close();
                para_log = stderr_log;
                free(ici.history_file);
                return ret;
        }
-       if (get_playback_state(pt) == 'X')
+       if (get_playback_state() == 'X')
                i9e_signal_dispatch(SIGTERM);
        return 0;
 }
 
 #else /* HAVE_READLINE */
 
-static int session_post_select(struct sched *s, struct play_task *pt)
+static int session_post_select(struct sched *s)
 {
        char c;
 
@@ -1203,38 +1191,36 @@ static int session_post_select(struct sched *s, struct play_task *pt)
                return 0;
        if (read(STDIN_FILENO, &c, 1))
                do_nothing;
-       kill_stream(pt);
+       kill_stream();
        return 1;
 }
 
-static void session_open(__a_unused struct play_task *pt)
+static void session_open(void)
 {
 }
 
-static void session_update_time_string(__a_unused struct play_task *pt,
-               char *str, __a_unused unsigned len)
+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_select(struct sched *s, void *context)
+static void play_pre_select(struct sched *s, __a_unused void *context)
 {
-       struct play_task *pt = context;
        char state;
 
        para_fd_set(STDIN_FILENO, &s->rfds, &s->max_fileno);
-       state = get_playback_state(pt);
+       state = get_playback_state();
        if (state == 'R' || state == 'F' || state == 'X')
                return sched_min_delay(s);
        sched_request_barrier_or_min_delay(&pt->next_update, s);
 }
 
-static unsigned get_time_string(struct play_task *pt, char **result)
+static unsigned get_time_string(char **result)
 {
        int seconds, length;
-       char state = get_playback_state(pt);
+       char state = get_playback_state();
 
        /* do not return anything if things are about to change */
        if (state != 'P' && state != 'U') {
@@ -1244,7 +1230,7 @@ static unsigned get_time_string(struct play_task *pt, char **result)
        length = pt->seconds;
        if (length == 0)
                return xasprintf(result, "0:00 [0:00] (0%%/0:00)");
-       seconds = get_play_time(pt);
+       seconds = get_play_time();
        return xasprintf(result, "#%u: %d:%02d [%d:%02d] (%d%%/%d:%02d) %s",
                pt->current_file,
                seconds / 60,
@@ -1258,24 +1244,23 @@ static unsigned get_time_string(struct play_task *pt, char **result)
        );
 }
 
-static int play_post_select(struct sched *s, void *context)
+static int play_post_select(struct sched *s, __a_unused void *context)
 {
-       struct play_task *pt = context;
        int ret;
 
-       ret = eof_cleanup(pt);
+       ret = eof_cleanup();
        if (ret < 0) {
                pt->rq = CRT_TERM_RQ;
                return 0;
        }
-       ret = session_post_select(s, pt);
+       ret = session_post_select(s);
        if (ret < 0)
                goto out;
        if (!pt->wn.btrn && !pt->fn.btrn) {
-               char state = get_playback_state(pt);
+               char state = get_playback_state();
                if (state == 'P' || state == 'R' || state == 'F') {
                        PARA_NOTICE_LOG("state: %c\n", state);
-                       ret = load_next_file(pt);
+                       ret = load_next_file();
                        if (ret < 0) {
                                PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                                pt->rq = CRT_TERM_RQ;
@@ -1287,10 +1272,10 @@ static int play_post_select(struct sched *s, void *context)
        }
        if (tv_diff(now, &pt->next_update, NULL) >= 0) {
                char *str;
-               unsigned len = get_time_string(pt, &str);
+               unsigned len = get_time_string(&str);
                struct timeval delay = {.tv_sec = 0, .tv_usec = 100 * 1000};
                if (str && len > 0)
-                       session_update_time_string(pt, str, len);
+                       session_update_time_string(str, len);
                free(str);
                tv_add(now, &delay, &pt->next_update);
        }
@@ -1310,7 +1295,6 @@ out:
 int main(int argc, char *argv[])
 {
        int ret;
-       struct play_task *pt = &play_task;
        unsigned num_inputs;
 
        /* needed this early to make help work */
@@ -1319,7 +1303,7 @@ int main(int argc, char *argv[])
        sched.default_timeout.tv_sec = 5;
        parse_config_or_die(argc, argv);
        AFH_RECV->init();
-       session_open(pt);
+       session_open();
        num_inputs = lls_num_inputs(play_lpr);
        init_shuffle_map();
        pt->invalid = para_calloc(sizeof(*pt->invalid) * num_inputs);
index 7bb775fe214af8880bc1244743760b59a2188e46..d48b3476f883bd9ca830aa97bc92dc0112433341 100644 (file)
@@ -37,7 +37,7 @@ void recv_init(void)
 /**
  * Check if the given string is a valid receiver specifier.
  *
- * \param \ra string of the form receiver_name [options...]
+ * \param ra string of the form receiver_name [options...]
  * \param lprp Filled in on success, undefined else.
  *
  * This function checks whether \a ra starts with the name of a receiver,