};
/**
- * The structure associated with a paraslash filter.
+ * Describes a method to convert audio data.
*
- * Paraslash filters are "modules" which transform an audio stream. struct
- * filter contains methods which are implemented by each filter.
+ * Paraslash filters are "modules" which transform the data of an audio stream.
+ * This structure contains the methods which have to be implemented by each
+ * filter.
*
- * Note: As several instances of the same filter may be running at the same
- * time, all these filter functions must be reentrant; no static non-constant
- * variables may be used.
+ * As several instances of the same filter may be running at the same time, all
+ * filter methods must be reentrant and no static non-constant variables must
+ * be used.
*
- * \sa \ref filter_node.
+ * \sa \ref filter_node, struct \ref receiver, struct \ref writer, struct \ref
+ * sched.
*/
struct filter {
/**
* This should free whatever ->setup() has allocated.
*/
void (*teardown)(const struct lls_parse_result *lpr, void *conf);
- /**
- * Set scheduler timeout and add file descriptors to fd sets.
- *
- * This function controls the timeout value for the next call to
- * select(2). It may decrease the current timeout but shall never
- * increase it. The second purpose of this function is to add file
- * descriptors to the two fd sets of the sched structure. The
- * descriptors in these sets will be watched by the subsequent
- * select(2) call.
- */
+ /** Force a zero timeout if data is available in the buffer tree. */
void (*pre_select)(struct sched *s, void *context);
- /**
- * Convert (filter) the given data.
- *
- * Pointer to the converting function of the filter. On errors, the
- * post_select function is supposed to return a negative error code.
- */
+ /** Convert (filter) input data into output data. */
int (*post_select)(struct sched *s, void *context);
/**
* Answer a buffer tree query.
}
/**
- * Set select timeout of the scheduler.
+ * Request a minimal timeout if not idle.
*
- * \param s The scheduler.
- * \param context Pointer to the filter node (task context).
+ * \param s The scheduler instance.
+ * \param context Pointer to the filter node.
*
- * This looks at the status of the btr node of the filter. If data is available
- * in the input queue of the filter, or if an error occurred, a minimal timeout
- * for the next select call is requested from the scheduler. Otherwise the
- * scheduler timeout is left unchanged.
+ * If the buffer tree node of the given filter node has data available (or is
+ * in error state) a minimal I/O timeout is requested from the scheduler.
+ * Otherwise the function does nothing.
*/
void generic_filter_pre_select(struct sched *s, void *context)
{
};
/**
- * Describes one supported paraslash receiver.
+ * Describes a possible data source for audio streams.
*
- * \sa \ref http_recv.c, \ref udp_recv.c.
+ * A paraslash receiver is a modular piece of software which is capable of
+ * receiving an audio data stream from a data source. Received audio data is
+ * fed to consumers through the buffer tree mechanism.
+ *
+ * This structure contains the methods which have to be implemented by each
+ * receiver.
+ *
+ * \sa \ref http_recv.c, \ref udp_recv.c, \ref dccp_recv.c, \ref afh_recv.c,
+ * struct \ref receiver_node, struct \ref filter, struct \ref writer, struct
+ * \ref sched.
*/
struct receiver {
/**
* This should allocate the output buffer of the given receiver node
* and prepare it for retrieving the audio stream according to the
* configuration stored in rn->lpr.
- *
- * \sa struct \ref receiver_node.
*/
int (*open)(struct receiver_node *rn);
/**
* \sa \ref receiver_node.
*/
void (*close)(struct receiver_node *rn);
- /**
- * Add file descriptors to fd_sets and compute timeout for select(2).
- *
- * If this is not NULL, the function is called in each iteration of the
- * scheduler's select loop. The receiver may define it to add file
- * descriptors to the file descriptor sets given by s. Those will be
- * monitored in the subsequent call to select(2). The function may also
- * lower the timeout value of s to make select(2) return earlier if no
- * file descriptors are ready for I/O.
- *
- * \sa select(2), \ref time.c, struct \ref sched.
- */
+ /** Ask the scheduler to monitor receive fds. */
void (*pre_select)(struct sched *s, void *context);
- /**
- * Evaluate the result from select(2).
- *
- * This is called after the call to select(2). It should check all file
- * descriptors which were added to any of the fd sets in the previous
- * call to ->pre_select() and perform (non-blocking) I/O operations on
- * those fds which are ready for I/O, for example in order to establish
- * a connection or to receive a part of the audio stream.
- *
- * \sa select(2), struct \ref receiver.
- */
+ /** Receive data and make it available to consumers. */
int (*post_select)(struct sched *s, void *context);
/**
* Answer a buffer tree query.
}
/**
- * Simple pre-select hook, used by all receivers.
+ * Request a minimal timeout in case of buffer tree errors.
*
- * \param s Scheduler info.
- * \param rn The receiver node.
+ * \param s The scheduler instance.
+ * \param rn The buffer tree node is derived from this.
*
- * This requests a minimal delay from the scheduler if the status of the buffer
- * tree node indicates an error/eof condition. No file descriptors are added to
- * the fd sets of \a s.
+ * If the buffer tree node of the given receiver node is in error or EOF state,
+ * a minimal I/O timeout is requested from the scheduler. Otherwise, the
+ * function does nothing. No file descriptors are asked to be monitored.
*
- * \return The status of the btr node of the receiver node, i.e. the return
- * value of the underlying call to \ref btr_node_status().
+ * \return The status of of the receiver node's buffer tree node. That is, the
+ * return value of the underlying call to \ref btr_node_status().
*/
int generic_recv_pre_select(struct sched *s, struct receiver_node *rn)
{
* function which is called from the scheduler main loop before it calls
* select(). Similarly, each task must define a post_select function which is
* called after the select call.
+ *
+ * \sa select(2), poll(2).
*/
struct sched {
/** Initial value (in milliseconds) before any pre_select call. */
/** Used for log messages and by \ref get_task_list(). */
const char *name;
/**
- * The optional pre select method.
+ * Configure watch fds and impose an upper bound on the I/O timeout.
+ *
+ * If this is not NULL, the function is called at each iteration of the
+ * scheduler's main loop. Its purpose is to tell the scheduler that
+ * certain file descriptors should be monitored for readiness for I/O.
+ * The function may also lower the scheduler's timeout value (but shall
+ * never increase it) to impose an upper bound on the waiting time in
+ * case no file descriptors happen to be ready.
*
- * Its purpose is to add file descriptors to the fd sets of the
- * scheduler and to decrease the select timeout if necessary.
+ * \sa \ref time.c.
*/
void (*pre_select)(struct sched *s, void *context);
/**
- * The mandatory post select method.
+ * Perform I/O on file descriptors which are ready for I/O.
+ *
+ * This mandatory hook is called after the system call which monitors
+ * file descriptors returns. The function should perform non-blocking
+ * I/O on those file descriptors which are reported as being ready.
*
- * Its purpose is to evaluate and act upon the results of the previous
- * select call. If this function returns a negative value, the
- * scheduler unregisters the task.
+ * If this function returns a negative value, the scheduler unregisters
+ * the task.
*/
int (*post_select)(struct sched *s, void *context);
/**
size_t min_iqs;
};
-/** Describes one supported writer. */
+/**
+ * Describes a data sink for audio streams.
+ *
+ * A paraslash writer obtains data via the buffer tree mechanism from its
+ * parent node. It consumes data without producing output on its own.
+ *
+ * This structure contains the methods which have to be implemented by each
+ * writer.
+ *
+ * \sa struct \ref writer_node, struct \ref receiver, struct \ref filter,
+ * struct \ref sched.
+ */
struct writer {
- /**
- * Prepare the fd sets for select.
- *
- * This is called from scheduler. It may use the sched pointer to add
- * any file descriptors or to decrease the select timeout.
- */
+ /** Ask the scheduler to check whether data can be written. */
void (*pre_select)(struct sched *s, void *context);
- /**
- * Write audio data.
- *
- * Called from the post_select function of the writer node's task.
- */
+ /** Write audio data. */
int (*post_select)(struct sched *s, void *context);
/**
* Close one instance of the writer.