fn->private_data = NULL;
}
-static int aacdec_post_select(__a_unused struct sched *s, struct task *t)
+static int aacdec_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct btr_node *btrn = fn->btrn;
struct private_aacdec_data *padd = fn->private_data;
int i, ret;
freep(&rn->private_data);
}
-static void afh_recv_pre_select(struct sched *s, struct task *t)
+static void afh_recv_pre_select(struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
struct private_afh_recv_data *pard = rn->private_data;
struct afh_info *afhi = &pard->afhi;
struct afh_recv_args_info *conf = rn->conf;
struct timeval chunk_time;
- int state = generic_recv_pre_select(s, t);
+ int state = generic_recv_pre_select(s, rn);
if (state <= 0)
return;
sched_request_barrier_or_min_delay(&chunk_time, s);
}
-static int afh_recv_post_select(__a_unused struct sched *s, struct task *t)
+static int afh_recv_post_select(__a_unused struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
struct afh_recv_args_info *conf = rn->conf;
struct private_afh_recv_data *pard = rn->private_data;
struct btr_node *btrn = rn->btrn;
return ret;
}
-static void signal_pre_select(struct sched *s, struct task *t)
+static void signal_pre_select(struct sched *s, void *context)
{
- struct signal_task *st = task_context(t);
+ struct signal_task *st = context;
para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
-static int afs_signal_post_select(struct sched *s, __a_unused struct task *t)
+static int afs_signal_post_select(struct sched *s, __a_unused void *context)
{
int signum, ret;
struct timeval connect_time;
};
-static void command_pre_select(struct sched *s, struct task *t)
+static void command_pre_select(struct sched *s, void *context)
{
- struct command_task *ct = task_context(t);
+ struct command_task *ct = context;
struct afs_client *client;
para_fd_set(server_socket, &s->rfds, &s->max_fileno);
/** Shutdown connection if query has not arrived until this many seconds. */
#define AFS_CLIENT_TIMEOUT 3
-static int command_post_select(struct sched *s, struct task *t)
+static int command_post_select(struct sched *s, void *context)
{
- struct command_task *ct = task_context(t);
+ struct command_task *ct = context;
struct sockaddr_un unix_addr;
struct afs_client *client, *tmp;
int fd, ret;
- ret = task_get_notification(t);
+ ret = task_get_notification(ct->task);
if (ret < 0)
return ret;
ret = execute_server_command(&s->rfds);
return -E_ALSA;
}
-static void alsa_write_pre_select(struct sched *s, struct task *t)
+static void alsa_write_pre_select(struct sched *s, void *context)
{
struct pollfd pfd;
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_alsa_write_data *pad = wn->private_data;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
free(pad);
}
-static int alsa_write_post_select(__a_unused struct sched *s,
- struct task *t)
+static int alsa_write_post_select(__a_unused struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_alsa_write_data *pad = wn->private_data;
struct btr_node *btrn = wn->btrn;
char *data;
snd_pcm_sframes_t frames;
int ret;
- ret = task_get_notification(t);
+ ret = task_get_notification(wn->task);
if (ret < 0)
goto err;
again:
pad->amp, pad->amp / 64.0 + 1.0);
}
-static int amp_post_select(__a_unused struct sched *s, struct task *t)
+static int amp_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct private_amp_data *pad = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret, factor = 64 + pad->amp;
wn->private_data = NULL;
}
-static void aow_pre_select(struct sched *s, struct task *t)
+static void aow_pre_select(struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_aow_data *pawd = wn->private_data;
int ret;
return -E_AO_PTHREAD;
}
-static int aow_post_select(__a_unused struct sched *s,
- struct task *t)
+static int aow_post_select(__a_unused struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_aow_data *pawd = wn->private_data;
int ret;
{.name = NULL}
};
-static void audioc_pre_select(struct sched *s, struct task *t)
+static void audioc_pre_select(struct sched *s, void *context)
{
- struct audioc_task *at = task_context(t);
+ struct audioc_task *at = context;
int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
if (ret < 0)
para_fd_set(at->fd, &s->rfds, &s->max_fileno);
}
-static int audioc_post_select(struct sched *s, struct task *t)
+static int audioc_post_select(struct sched *s, void *context)
{
char *buf = NULL;
- struct audioc_task *at = task_context(t);
+ struct audioc_task *at = context;
int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
if (ret < 0)
*/
struct sched sched = {.max_fileno = 0};
-/**
- * The task for obtaining para_server's status (para_client stat).
- *
- * \sa struct task, struct sched.
- */
+/* The task for obtaining para_server's status (para_client stat). */
struct status_task {
/** The associated task structure of audiod. */
struct task *task;
exit(EXIT_FAILURE);
}
-static void signal_pre_select(struct sched *s, struct task *t)
+static void signal_pre_select(struct sched *s, void *context)
{
- struct signal_task *st = task_context(t);
+ struct signal_task *st = context;
para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
-static int signal_post_select(struct sched *s, __a_unused struct task *t)
+static int signal_post_select(struct sched *s, __a_unused void *context)
{
int signum;
-
signum = para_next_signal(&s->rfds);
switch (signum) {
case SIGINT:
return 0;
}
-static void command_pre_select(struct sched *s, struct task *t)
+static void command_pre_select(struct sched *s, void *context)
{
- struct command_task *ct = task_context(t);
+ struct command_task *ct = context;
para_fd_set(ct->fd, &s->rfds, &s->max_fileno);
}
-static int command_post_select(struct sched *s, struct task *t)
+static int command_post_select(struct sched *s, void *context)
{
int ret;
- struct command_task *ct = task_context(t);
+ struct command_task *ct = context;
static struct timeval last_status_dump;
struct timeval tmp, delay;
bool force = true;
btr_log_tree(sl->receiver_node->btrn, LL_NOTICE);
}
-static void status_pre_select(struct sched *s, struct task *t)
+static void status_pre_select(struct sched *s, void *context)
{
- struct status_task *st = task_context(t);
+ struct status_task *st = context;
int i, ret, cafn = stat_task->current_audio_format_num;
if (must_start_decoder())
}
/* restart the client task if necessary */
-static int status_post_select(struct sched *s, struct task *t)
+static int status_post_select(struct sched *s, void *context)
{
- struct status_task *st = task_context(t);
+ struct status_task *st = context;
if (audiod_status == AUDIOD_OFF) {
if (!st->ct)
size_t result_size;
};
-static void exec_pre_select(struct sched *s, struct task *t)
+static void exec_pre_select(struct sched *s, void *context)
{
- struct exec_task *et = task_context(t);
+ struct exec_task *et = context;
int ret = btr_node_status(et->btrn, 0, BTR_NT_LEAF);
if (ret != 0)
sched_min_delay(s);
}
-static int exec_post_select(__a_unused struct sched *s, struct task *t)
+static int exec_post_select(__a_unused struct sched *s, void *context)
{
- struct exec_task *et = task_context(t);
+ struct exec_task *et = context;
struct btr_node *btrn = et->btrn;
char *buf;
size_t sz;
struct task *task;
};
-static int supervisor_post_select(struct sched *s, struct task *t)
+static int supervisor_post_select(struct sched *s, void *context)
{
- struct supervisor_task *svt = task_context(t);
+ struct supervisor_task *svt = context;
int ret = task_status(ct->task);
if (ret < 0)
free(ct);
}
-/**
+/*
* The preselect hook for server commands.
*
- * \param s Pointer to the scheduler.
- * \param t Pointer to the task struct for this command.
- *
* The task pointer must contain a pointer to the initialized client data
* structure as it is returned by client_open().
*
* This function checks the state of the connection and adds the file descriptor
- * of the connection to the read or write fd set of \a s accordingly.
- *
- * \sa register_task() client_open(), struct sched, struct task.
+ * of the connection to the read or write fd set of s accordingly.
*/
-static void client_pre_select(struct sched *s, struct task *t)
+static void client_pre_select(struct sched *s, void *context)
{
int ret;
- struct client_task *ct = task_context(t);
+ struct client_task *ct = context;
if (ct->scc.fd < 0)
return;
return send_sb(ct, 0, command, len, SBD_COMMAND, false);
}
-/**
+/*
* The post select hook for client commands.
*
- * \param s Pointer to the scheduler.
- * \param t Pointer to the task struct for this command.
- *
* Depending on the current state of the connection and the status of the read
- * and write fd sets of \a s, this function performs the necessary steps to
- * authenticate the connection, to send the command given by \a t->private_data
+ * and write fd sets of s, this function performs the necessary steps to
+ * authenticate the connection, to send the command given by t->private_data
* and to receive para_server's output, if any.
- *
- * \sa struct sched, struct task.
*/
-static int client_post_select(struct sched *s, struct task *t)
+static int client_post_select(struct sched *s, void *context)
{
- struct client_task *ct = task_context(t);
+ struct client_task *ct = context;
int ret = 0;
size_t n;
char buf[CLIENT_BUFSIZE];
- ret = task_get_notification(t);
+ ret = task_get_notification(ct->task);
if (ret < 0)
goto out;
if (ct->scc.fd < 0)
free(fn->private_data);
}
-static int compress_post_select(__a_unused struct sched *s, struct task *t)
+static int compress_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct private_compress_data *pcd = fn->private_data;
struct btr_node *btrn = fn->btrn;
bool inplace = btr_inplace_ok(btrn);
return tmp;
}
-static void dccp_recv_pre_select(struct sched *s, struct task *t)
+static void dccp_recv_pre_select(struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
- if (generic_recv_pre_select(s, t) <= 0)
+ if (generic_recv_pre_select(s, rn) <= 0)
return;
para_fd_set(rn->fd, &s->rfds, &s->max_fileno);
}
-static int dccp_recv_post_select(struct sched *s, struct task *t)
+static int dccp_recv_post_select(struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
struct btr_node *btrn = rn->btrn;
struct iovec iov[2];
int ret, iovcnt;
size_t num_bytes;
- ret = task_get_notification(t);
+ ret = task_get_notification(rn->task);
if (ret < 0)
goto out;
ret = btr_node_status(btrn, 0, BTR_NT_ROOT);
fn->private_data = NULL;
}
-static int fecdec_post_select(__a_unused struct sched *s, struct task *t)
+static int fecdec_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct btr_node *btrn = fn->btrn;
int ret;
struct fec_header h;
return ret;
}
-static void file_write_pre_select(struct sched *s, struct task *t)
+static void file_write_pre_select(struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_file_write_data *pfwd = wn->private_data;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
free(pfwd);
}
-static int file_write_post_select(__a_unused struct sched *s,
- struct task *t)
+static int file_write_post_select(__a_unused struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_file_write_data *pfwd = wn->private_data;
struct btr_node *btrn = wn->btrn;
int ret;
char *buf;
size_t bytes;
- ret = task_get_notification(t);
+ ret = task_get_notification(wn->task);
if (ret < 0)
goto out;
ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF);
* this function is to set file descriptors to be watched by the
* subsequent select call to the two fd sets.
*/
- void (*pre_select)(struct sched *s, struct task *t);
+ 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.
*/
- int (*post_select)(struct sched *s, struct task *t);
+ int (*post_select)(struct sched *s, void *context);
/**
* Answer a buffer tree query.
*
void filter_init(void);
int check_filter_arg(char *filter_arg, void **conf);
void print_filter_helps(unsigned flags);
-void generic_filter_pre_select(struct sched *s, struct task *t);
+void generic_filter_pre_select(struct sched *s, void *context);
int decoder_execute(const char *cmd, unsigned sample_rate, unsigned channels,
char **result);
* Set select timeout of the scheduler.
*
* \param s The scheduler.
- * \param t The task struct of this filter.
+ * \param context Pointer to the filter node (task context).
*
* 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.
*/
-void generic_filter_pre_select(struct sched *s, struct task *t)
+void generic_filter_pre_select(struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
if (btr_node_status(fn->btrn, fn->min_iqs, BTR_NT_INTERNAL) != 0)
sched_min_delay(s);
return btr_get_output_queue_size(btrn) > FLACDEC_MAX_OUTPUT_SIZE;
}
-static void flacdec_pre_select(struct sched *s, struct task *t)
+static void flacdec_pre_select(struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct private_flacdec_data *pfd = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
return sched_min_delay(s);
}
-static int flacdec_post_select(__a_unused struct sched *s, struct task *t)
+static int flacdec_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct private_flacdec_data *pfd = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
return -E_GC_WRITE;
}
-static void gc_pre_select(struct sched *s, struct task *t)
+static void gc_pre_select(struct sched *s, void *context)
{
- struct grab_client *gc = task_context(t);
+ struct grab_client *gc = context;
int ret = btr_node_status(gc->btrn, 0, BTR_NT_LEAF);
if (ret == 0)
* We need this forward declaration as post_select() needs
* activate_grab_client and vice versa.
*/
-static int gc_post_select(struct sched *s, struct task *t);
+static int gc_post_select(struct sched *s, void *context);
/**
* Move a grab client to the active list and start it.
return 0;
}
-static int gc_post_select(__a_unused struct sched *s, struct task *t)
+static int gc_post_select(__a_unused struct sched *s, void *context)
{
- struct grab_client *gc = task_context(t);
+ struct grab_client *gc = context;
struct btr_node *btrn = gc->btrn;
int ret;
size_t sz;
return ret;
}
-static void http_recv_pre_select(struct sched *s, struct task *t)
+static void http_recv_pre_select(struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
struct private_http_recv_data *phd = rn->private_data;
- if (generic_recv_pre_select(s, t) <= 0)
+ if (generic_recv_pre_select(s, rn) <= 0)
return;
if (phd->status == HTTP_CONNECTED)
para_fd_set(rn->fd, &s->wfds, &s->max_fileno);
* area with data read from the socket. In any case, update the state of the
* connection if necessary.
*/
-static int http_recv_post_select(struct sched *s, struct task *t)
+static int http_recv_post_select(struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
struct private_http_recv_data *phd = rn->private_data;
struct btr_node *btrn = rn->btrn;
int ret, iovcnt;
struct iovec iov[2];
size_t num_bytes;
- ret = task_get_notification(t);
+ ret = task_get_notification(rn->task);
if (ret < 0)
goto out;
ret = btr_node_status(btrn, 0, BTR_NT_ROOT);
free(line);
}
-static int i9e_post_select(__a_unused struct sched *s, __a_unused struct task *t)
+static int i9e_post_select(__a_unused struct sched *s, __a_unused void *context)
{
int ret;
struct i9e_client_info *ici = i9ep->ici;
return ret;
}
-static void i9e_pre_select(struct sched *s, __a_unused struct task *t)
+static void i9e_pre_select(struct sched *s, __a_unused void *context)
{
int ret;
#define MP3DEC_MAX_FRAME 8192
-static int mp3dec_post_select(__a_unused struct sched *s, struct task *t)
+static int mp3dec_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
int i, ret;
struct private_mp3dec_data *pmd = fn->private_data;
struct btr_node *btrn = fn->btrn;
#define OGGDEC_MAX_OUTPUT_SIZE (96 * 1024)
#define OGGDEC_OUTPUT_CHUNK_SIZE (32 * 1024)
-static void ogg_pre_select(struct sched *s, struct task *t)
+static void ogg_pre_select(struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct private_oggdec_data *pod = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
sched_min_delay(s);
}
-static int ogg_post_select(__a_unused struct sched *s, struct task *t)
+static int ogg_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct private_oggdec_data *pod = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret, have;
#define OPUSDEC_MAX_OUTPUT_SIZE (1024 * 1024)
-static int opusdec_post_select(__a_unused struct sched *s, struct task *t)
+static int opusdec_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct opusdec_context *ctx = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
return ret;
}
-static void opusdec_pre_select(struct sched *s, struct task *t)
+static void opusdec_pre_select(struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct opusdec_context *ctx = fn->private_data;
int ret = btr_node_status(fn->btrn, fn->min_iqs, BTR_NT_INTERNAL);
}
}
-static void oss_pre_select(struct sched *s, struct task *t)
+static void oss_pre_select(struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_oss_write_data *powd = wn->private_data;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
return ret;
}
-static int oss_post_select(__a_unused struct sched *s,
- struct task *t)
+static int oss_post_select(__a_unused struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_oss_write_data *powd = wn->private_data;
struct btr_node *btrn = wn->btrn;
size_t frames, bytes;
int ret;
char *data;
- ret = task_get_notification(t);
+ ret = task_get_notification(wn->task);
if (ret < 0)
goto out;
ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF);
return btr_get_input_queue_size(powd->callback_btrn) != 0;
}
-static void osx_write_pre_select(struct sched *s, struct task *t)
+static void osx_write_pre_select(struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ struct writer_node *wn = context;
struct private_osx_write_data *powd = wn->private_data;
int ret;
bool drain_delay_nec = false;
sched_request_timeout_ms(50, s);
}
-static int osx_write_post_select(__a_unused struct sched *s, struct task *t)
+static int osx_write_post_select(__a_unused struct sched *s, void *context)
{
- struct writer_node *wn = task_context(t);
+ 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(t);
+ ret = task_get_notification(wn->task);
if (ret < 0)
goto fail;
if (!powd) {
* 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 task *t)
+static int session_post_select(__a_unused struct sched *s, struct play_task *pt)
{
- struct play_task *pt = task_context(t);
int ret;
if (pt->background)
#else /* HAVE_READLINE */
-static int session_post_select(struct sched *s, struct task *t)
+static int session_post_select(struct sched *s, struct play_task *pt)
{
- struct play_task *pt = task_context(t);
char c;
if (!FD_ISSET(STDIN_FILENO, &s->rfds))
}
#endif /* HAVE_READLINE */
-static void play_pre_select(struct sched *s, struct task *t)
+static void play_pre_select(struct sched *s, void *context)
{
- struct play_task *pt = task_context(t);
+ struct play_task *pt = context;
char state;
para_fd_set(STDIN_FILENO, &s->rfds, &s->max_fileno);
);
}
-static int play_post_select(struct sched *s, struct task *t)
+static int play_post_select(struct sched *s, void *context)
{
- struct play_task *pt = task_context(t);
+ struct play_task *pt = context;
int ret;
ret = eof_cleanup(pt);
pt->rq = CRT_TERM_RQ;
return 0;
}
- ret = session_post_select(s, t);
+ ret = session_post_select(s, pt);
if (ret < 0)
goto out;
if (!pt->wn.btrn && !pt->fn.btrn) {
struct timeval barrier;
};
-static void prebuffer_pre_select(struct sched *s, struct task *t)
+static void prebuffer_pre_select(struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct btr_node *btrn = fn->btrn;
size_t iqs = btr_get_input_queue_size(btrn);
struct private_prebuffer_data *ppd = fn->private_data;
free(fn->private_data);
}
-static int prebuffer_post_select(__a_unused struct sched *s, struct task *t)
+static int prebuffer_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct btr_node *btrn = fn->btrn;
size_t iqs = btr_get_input_queue_size(btrn);
struct private_prebuffer_data *ppd = fn->private_data;
*
* \sa select(2), time.c struct task, struct sched.
*/
- void (*pre_select)(struct sched *s, struct task *t);
+ void (*pre_select)(struct sched *s, void *context);
/**
* Evaluate the result from select().
*
*
* \sa select(2), struct receiver.
*/
- int (*post_select)(struct sched *s, struct task *t);
+ int (*post_select)(struct sched *s, void *context);
/** The two help texts of this receiver. */
struct ggo_help help;
void recv_init(void);
void *check_receiver_arg(char *ra, int *receiver_num);
void print_receiver_helps(unsigned flags);
-int generic_recv_pre_select(struct sched *s, struct task *t);
+int generic_recv_pre_select(struct sched *s, struct receiver_node *rn);
/** \cond receiver */
extern void http_recv_init(struct receiver *r);
* Simple pre-select hook, used by all receivers.
*
* \param s Scheduler info.
- * \param t Determines the receiver node.
+ * \param rn The receiver node.
*
* 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
* \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().
*/
-int generic_recv_pre_select(struct sched *s, struct task *t)
+int generic_recv_pre_select(struct sched *s, struct receiver_node *rn)
{
- struct receiver_node *rn = task_context(t);
int ret = btr_node_status(rn->btrn, 0, BTR_NT_ROOT);
if (ret < 0)
btr_log_tree(btr_parent(btr_parent(btrn)), LL_INFO);
}
-static void resample_pre_select(struct sched *s, struct task *t)
+static void resample_pre_select(struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct resample_context *ctx = fn->private_data;
int ret = btr_node_status(fn->btrn, fn->min_iqs, BTR_NT_INTERNAL);
return data.input_frames_used;
}
-static int resample_post_select(__a_unused struct sched *s, struct task *t)
+static int resample_post_select(__a_unused struct sched *s, void *context)
{
int ret;
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct resample_context *ctx = fn->private_data;
struct resample_filter_args_info *conf = fn->conf;
struct btr_node *btrn = fn->btrn;
if (t->notification != 0)
sched_min_delay(s);
if (t->info.pre_select)
- t->info.pre_select(s, t);
+ t->info.pre_select(s, t->info.context);
}
}
int ret;
#ifndef SCHED_DEBUG
- ret = t->info.post_select(s, t);
+ ret = t->info.post_select(s, t->info.context);
#else
struct timeval t1, t2, diff;
unsigned long pst;
clock_get_realtime(&t1);
- ret = t->info.post_select(s, t);
+ ret = t->info.post_select(s, t->info.context);
clock_get_realtime(&t2);
tv_diff(&t1, &t2, &diff);
pst = tv2ms(&diff);
* \return Zero if no more tasks are left in the task list, negative if the
* select function returned an error.
*
- * \sa \ref task, \ref now.
+ * \sa \ref now.
*/
int schedule(struct sched *s)
{
return t;
}
-/**
- * Obtain the context pointer of a task.
- *
- * \param t Return this task's context pointer.
- *
- * \return A pointer to the memory location specified previously as \a
- * task_info->context when the task was registered with \ref task_register().
- */
-void *task_context(struct task *t)
-{
- return t->info.context;
-}
-
/**
* Get the list of all registered tasks.
*
* Its purpose is to add file descriptors to the fd sets of the
* scheduler and to decrease the select timeout if necessary.
*/
- void (*pre_select)(struct sched *s, struct task *t);
+ void (*pre_select)(struct sched *s, void *context);
/**
* The mandatory post select method.
*
* select call. If this function returns a negative value, the
* scheduler unregisters the task.
*/
- int (*post_select)(struct sched *s, struct task *t);
+ int (*post_select)(struct sched *s, void *context);
/**
- * This pointer is saved when the task is register(ed). It may be
- * queried from ->pre_select() and ->post_select() via \ref
- * task_context(). Usually this is a pointer to the struct owned by the
- * caller which contains the task pointer as one member.
+ * This pointer is saved when the task is registered. It is passed to
+ * ->pre_select() and ->post_select(). Usually this is a pointer to the
+ * struct owned by the caller which contains the task pointer.
*/
void *context;
};
extern struct timeval *now;
struct task *task_register(struct task_info *info, struct sched *s);
-void *task_context(struct task *t);
int schedule(struct sched *s);
void sched_shutdown(struct sched *s);
char *get_task_list(struct sched *s);
exit(EXIT_FAILURE);
}
-static void signal_pre_select(struct sched *s, struct task *t)
+static void signal_pre_select(struct sched *s, void *context)
{
- struct signal_task *st = task_context(t);
+ struct signal_task *st = context;
para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
kill(mmd->afs_pid, SIGHUP);
}
-static int signal_post_select(struct sched *s, __a_unused struct task *t)
+static int signal_post_select(struct sched *s, __a_unused void *context)
{
int signum = para_next_signal(&s->rfds);
}, &sched);
}
-static void command_pre_select(struct sched *s, struct task *t)
+static void command_pre_select(struct sched *s, void *context)
{
- struct server_command_task *sct = task_context(t);
+ struct server_command_task *sct = context;
para_fd_set(sct->listen_fd, &s->rfds, &s->max_fileno);
}
-static int command_post_select(struct sched *s, struct task *t)
+static int command_post_select(struct sched *s, void *context)
{
- struct server_command_task *sct = task_context(t);
+ struct server_command_task *sct = context;
int new_fd, ret, i;
char *peer_name;
return ret;
}
-static int speexdec_post_select(__a_unused struct sched *s, struct task *t)
+static int speexdec_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct private_spxdec_data *psd = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret, ns;
#include "buffer_tree.h"
#include "string.h"
-/**
- * The pre_select function of the stdin task.
- *
- * \param s The scheduler this task was registered to.
- * \param t The task structure of the stdin task.
- *
- * This function is always successful. If there is space left in the
- * buffer of the stdin task, it adds \p STDIN_FILENO to the read fd set
- * of \a s.
+/*
+ * If there is space left in the buffer of the stdin task add STDIN_FILENO to
+ * the read fd set of s.
*/
-static void stdin_pre_select(struct sched *s, struct task *t)
+static void stdin_pre_select(struct sched *s, void *context)
{
- struct stdin_task *sit = task_context(t);
+ struct stdin_task *sit = context;
int ret;
ret = btr_node_status(sit->btrn, 0, BTR_NT_ROOT);
sched_request_timeout_ms(100, s);
}
-/**
- * The post select function of the stdin task.
- *
- * \param s The scheduler this task was registered to.
- * \param t The task structure of the stdin task.
- *
- * This function checks if \p STDIN_FILENO was included by in the read fd set
- * of \a s during the previous pre_select call. If yes, and \p STDIN_FILENO
- * appears to be readable, data is read from stdin and fed into the buffer
- * tree.
+/*
+ * This function checks if STDIN_FILENO was included by in the read fd set of s
+ * during the previous pre_select call. If so, and if STDIN_FILENO is readable,
+ * data is read from stdin and fed into the buffer tree.
*/
-static int stdin_post_select(struct sched *s, struct task *t)
+static int stdin_post_select(struct sched *s, void *context)
{
- struct stdin_task *sit = task_context(t);
+ struct stdin_task *sit = context;
ssize_t ret;
size_t sz, n;
char *buf = NULL;
#include "stdout.h"
#include "buffer_tree.h"
-/**
- * The pre_select function of the stdout task.
- *
- * \param s The scheduler this task was registered to.
- * \param t The task structure of the stdout task.
- *
- * This function is always successful. If there is input data available, it
- * adds \p STDOUT_FILENO to the write fd set of \a s.
- */
-static void stdout_pre_select(struct sched *s, struct task *t)
+/* Add STDOUT_FILENO to the write fd set if there is input data available. */
+static void stdout_pre_select(struct sched *s, void *context)
{
- struct stdout_task *sot = task_context(t);
+ struct stdout_task *sot = context;
int ret;
ret = btr_node_status(sot->btrn, 0, BTR_NT_LEAF);
sched_min_delay(s);
}
-/**
- * The post select function of the stdout task.
- *
- * \param s The scheduler this task was registered to.
- * \param t The task structure of the stdout task.
- *
- * This function writes input data from the buffer tree to stdout if \p
+/*
+ * This function writes input data from the buffer tree to stdout if
* STDOUT_FILENO is writable.
*/
-static int stdout_post_select(struct sched *s, struct task *t)
+static int stdout_post_select(struct sched *s, void *context)
{
- struct stdout_task *sot = task_context(t);
+ struct stdout_task *sot = context;
struct btr_node *btrn = sot->btrn;
int ret;
char *buf;
tv_add(now, &to, &ctx->timeout);
}
-static void sync_pre_select(struct sched *s, struct task *t)
+static void sync_pre_select(struct sched *s, void *context)
{
int ret;
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct sync_filter_context *ctx = fn->private_data;
struct sync_filter_config *sfc = fn->conf;
return NULL;
}
-static int sync_post_select(__a_unused struct sched *s, struct task *t)
+static int sync_post_select(__a_unused struct sched *s, void *context)
{
int ret;
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct sync_filter_context *ctx = fn->private_data;
struct sync_filter_config *sfc = fn->conf;
struct sync_buddy *buddy, *tmp;
#include "net.h"
#include "fd.h"
-static void udp_recv_pre_select(struct sched *s, struct task *t)
+static void udp_recv_pre_select(struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
- if (generic_recv_pre_select(s, t) <= 0)
+ if (generic_recv_pre_select(s, rn) <= 0)
return;
para_fd_set(rn->fd, &s->rfds, &s->max_fileno);
}
return -E_RECV_EOF;
}
-static int udp_recv_post_select(__a_unused struct sched *s, struct task *t)
+static int udp_recv_post_select(__a_unused struct sched *s, void *context)
{
- struct receiver_node *rn = task_context(t);
+ struct receiver_node *rn = context;
struct btr_node *btrn = rn->btrn;
size_t num_bytes;
struct iovec iov[2];
int ret, readv_ret, iovcnt;
- ret = task_get_notification(t);
+ ret = task_get_notification(rn->task);
if (ret < 0)
goto out;
ret = btr_node_status(btrn, 0, BTR_NT_ROOT);
mmd->offset = tv2ms(&offset);
}
-/**
+/*
* Compute the timeout for the main select-loop of the scheduler.
*
- * \param s Pointer to the server scheduler.
- * \param t Pointer to the vss task structure.
- *
* Before the timeout is computed, the current vss status flags are evaluated
* and acted upon by calling appropriate functions from the lower layers.
* Possible actions include
* - shutdown of all senders (stop/pause command),
* - reposition the stream (ff/jmp command).
*/
-static void vss_pre_select(struct sched *s, struct task *t)
+static void vss_pre_select(struct sched *s, void *context)
{
int i;
- struct vss_task *vsst = task_context(t);
+ struct vss_task *vsst = context;
if (!vsst->map || vss_next() || vss_paused() || vss_repos()) {
struct fec_client *fc, *tmp;
}
}
-static int vss_post_select(struct sched *s, struct task *t)
+static int vss_post_select(struct sched *s, void *context)
{
int ret, i;
- struct vss_task *vsst = task_context(t);
+ struct vss_task *vsst = context;
if (mmd->sender_cmd_data.cmd_num >= 0) {
int num = mmd->sender_cmd_data.cmd_num,
*bof = 1;
}
-static void wav_pre_select(struct sched *s, struct task *t)
+static void wav_pre_select(struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
size_t iqs = btr_get_input_queue_size(fn->btrn);
if (iqs == 0)
sched_min_delay(s);
}
-static int wav_post_select(__a_unused struct sched *s, struct task *t)
+static int wav_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
struct btr_node *btrn = fn->btrn;
size_t iqs = btr_get_input_queue_size(btrn);
int ret;
#define WMA_OUTPUT_BUFFER_SIZE (128 * 1024)
-static int wmadec_post_select(__a_unused struct sched *s, struct task *t)
+static int wmadec_post_select(__a_unused struct sched *s, void *context)
{
- struct filter_node *fn = task_context(t);
+ struct filter_node *fn = context;
int ret, converted, out_size;
struct private_wmadec_data *pwd = fn->private_data;
struct btr_node *btrn = fn->btrn;
struct check_wav_context *cwc;
};
-static void write_pre_select(struct sched *s, struct task *t)
+static void write_pre_select(struct sched *s, void *context)
{
- struct write_task *wt = task_context(t);
+ struct write_task *wt = context;
check_wav_pre_select(s, wt->cwc);
}
-static int write_post_select(__a_unused struct sched *s, struct task *t)
+static int write_post_select(__a_unused struct sched *s, void *context)
{
- struct write_task *wt = task_context(t);
+ struct write_task *wt = context;
return check_wav_post_select(wt->cwc);
}
* This is called from scheduler. It may use the sched pointer to add
* any file descriptors or to decrease the select timeout.
*/
- void (*pre_select)(struct sched *s, struct task *t);
+ void (*pre_select)(struct sched *s, void *context);
/**
* Write audio data.
*
* Called from the post_select function of the writer node's task.
*/
- int (*post_select)(struct sched *s, struct task *t);
+ int (*post_select)(struct sched *s, void *context);
/**
* Close one instance of the writer.
*