CPPFLAGS += -Werror-implicit-function-declaration
CPPFLAGS += -Wmissing-format-attribute
CPPFLAGS += -Wunused-macros
+CPPFLAGS += -Wshadow
BINARIES = para_server para_client para_gui para_audiod para_audioc para_recv para_filter para_write $(extra_binaries)
- the new paraslash scheduler, short and sweet.
- Support for m4a files via the new aac filter/ and audio
- format handler. (requires libfaad)
+ format handler (requires libfaad).
+ - each writer has its own command line parser, just like
+ para_recv and para_filter.
- new writer: osxplay (thanks to Gerd Becker)
+ - para_client and para_audioc use the error subsystem
- writers are integrated in para_audiod
- para_client is integrated in para_audiod
- - each writer of para_write has its own command line parser,
- just like para_recv and para_filter.
- random/playlist selector: improved info strings
- new audiod commands: tasks, kill
- - para_client/para_audioc use the error subsystem
+ - update to libortp-0.10.0
+ - para_fade: wake time defaults to 8 hours from now
------------------------------------------
PARA_DEBUG_LOG("offset #%d: %zu\n", i, chunk_table[i]);
}
return 1;
-
}
long unsigned aac_set_chunk_tv(mp4AudioSpecificConfig *mp4ASC)
static struct status_task status_task_struct;
struct status_task *stat_task = &status_task_struct;
+static struct timeval initial_delay_barrier;
/**
* the task for handling audiod commands
struct task task;
};
+/**
+ * task for signal handling
+ */
struct signal_task {
+ /** the signal pipe */
int fd;
+ /** the number of the most recent signal */
int signum;
+ /** the associated task structure */
struct task task;
};
{
struct slot_info *s = &slot[slot_num];
struct audio_format_info *a;
- const struct timeval restart_delay = {0, 200 * 1000};
if (s->format < 0 || !s->receiver_node)
return;
a = &afi[s->format];
PARA_NOTICE_LOG("closing %s receiver in slot %d (eof = %d)\n",
audio_formats[s->format] , slot_num, s->receiver_node->eof);
-// if (!s->receiver_node->eof)
-// unregister_task(&s->receiver_node->task);
a->receiver->close(s->receiver_node);
free(s->receiver_node);
s->receiver_node = NULL;
- /* set restart barrier */
- tv_add(now, &restart_delay, &afi[s->format].restart_barrier);
}
static void kill_all_decoders(void)
return -E_NO_MORE_SLOTS;
}
-static int decoder_running(int format)
-{
- int i, ret = 0;
- struct slot_info *s;
-
- FOR_EACH_SLOT(i) {
- s = &slot[i];
- if (s->format == format && s->receiver_node)
- ret |= 1;
- if (s->format == format && s->wng)
- ret |= 2;
- }
- return ret;
-}
-
static void close_stat_pipe(void)
{
int i;
static void rn_event_handler(struct task *t)
{
struct receiver_node *rn = t->private_data;
+ const struct timeval restart_delay = {0, 10 * 1000};
+ int i;
PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
unregister_task(t);
rn->eof = 1;
+ /* set restart barrier */
+ FOR_EACH_SLOT(i) {
+ if (slot[i].receiver_node != rn)
+ continue;
+ tv_add(now, &restart_delay, &afi[slot[i].format].restart_barrier);
+ }
}
static void open_receiver(int format)
register_task(&rn->task);
}
+static int receiver_running(int format)
+{
+ int i;
+
+ FOR_EACH_SLOT(i) {
+ struct slot_info *s = &slot[i];
+ if (s->format == format && s->receiver_node
+ && !s->receiver_node->eof)
+ return 1;
+ }
+ return 0;
+}
+
static int open_current_receiver(struct sched *s)
{
int i;
i = get_audio_format_num(stat_task->af_status);
if (i < 0)
return 0;
- if (decoder_running(i))
+ if (receiver_running(i))
return 0;
if (tv_diff(now, &afi[i].restart_barrier, &diff) < 0) {
s->timeout = diff;
break;
case SI_STREAM_START:
if (sscanf(line + ilen + 1, "%lu.%lu", &sec, &usec) == 2) {
+ struct timeval a_start, delay;
+ delay.tv_sec = conf.stream_delay_arg / 1000;
+ delay.tv_usec = (conf.stream_delay_arg % 1000) * 1000;
stat_task->server_stream_start.tv_sec = sec;
stat_task->server_stream_start.tv_usec = usec;
+ if (stat_task->sa_time_diff_sign < 0)
+ tv_add(&stat_task->server_stream_start,
+ &stat_task->sa_time_diff, &a_start);
+ else
+ tv_diff(&stat_task->server_stream_start,
+ &stat_task->sa_time_diff, &a_start);
+ tv_add(&a_start, &delay, &initial_delay_barrier);
}
break;
case SI_CURRENT_TIME:
FOR_EACH_SLOT(i) {
struct slot_info *sl = &slot[i];
struct audio_format_info *a;
+ struct timeval diff;
if (sl->format < 0)
continue;
s->timeout = min_delay;
continue;
}
- if (sl->fc && *sl->fc->out_loaded && !sl->wng) {
+ if (!sl->fc || !*sl->fc->out_loaded || sl->wng)
+ continue;
+ if (tv_diff(now, &initial_delay_barrier, &diff) > 0) {
+ PARA_INFO_LOG("barrier: %lu:%lu, now: %lu, %lu\n",
+ initial_delay_barrier.tv_sec,
+ initial_delay_barrier.tv_usec,
+ now->tv_sec, now->tv_usec);
open_writers(i);
s->timeout = min_delay;
+ continue;
+ }
+ PARA_INFO_LOG("inital delay: %lu ms left\n", tv2ms(&diff));
+ if (tv_diff(&s->timeout, &diff, NULL) > 0) {
+ s->timeout = diff;
}
}
}
PARA_INFO_LOG("initializing %s receiver\n", receivers[i].name);
receivers[i].init(&receivers[i]);
}
- for (i = 0; i < conf.receiver_given; i++) {
+ for (i = conf.receiver_given - 1; i >= 0; i--) {
char *arg = conf.receiver_arg[i];
- char *recv = strchr(arg, ':');
+ char *recv_arg = strchr(arg, ':');
+ PARA_INFO_LOG("arg: %s\n", arg);
ret = -E_MISSING_COLON;
- if (!recv)
+ if (!recv_arg)
goto out;
- *recv = '\0';
- recv++;
+ *recv_arg = '\0';
+ recv_arg++;
ret = get_audio_format_num(arg);
if (ret < 0)
goto out;
- afi[ret].receiver_conf = check_receiver_arg(recv, &receiver_num);
+ afi[ret].receiver_conf = check_receiver_arg(recv_arg, &receiver_num);
if (!afi[ret].receiver_conf) {
ret = -E_RECV_SYNTAX;
goto out;
return fd;
}
-void signal_event_handler(struct task *t)
+static void signal_event_handler(struct task *t)
{
struct signal_task *st = t->private_data;
handle_signal(st->signum);
}
-void signal_pre_select(struct sched *s, struct task *t)
+static void signal_pre_select(struct sched *s, struct task *t)
{
struct signal_task *st = t->private_data;
t->ret = 1;
para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
-void signal_post_select(struct sched *s, struct task *t)
+static void signal_post_select(struct sched *s, struct task *t)
{
struct signal_task *st = t->private_data;
t->ret = 1;
st->signum = para_next_signal();
}
-void signal_setup_default(struct signal_task *st)
+static void signal_setup_default(struct signal_task *st)
{
st->task.pre_select = signal_pre_select;
st->task.post_select = signal_post_select;
t->ret = 1;
if (!st->pcd || !st->pcd->loaded
- || st->pcd->status != CL_RECEIVING_SERVER_OUTPUT)
+ || st->pcd->status != CL_RECEIVING)
return;
st->pcd->loaded = for_each_line(st->pcd->buf, st->pcd->loaded,
&check_stat_line);
__malloc static char *decoder_flags(void)
{
int i;
- char decoder_flags[MAX_STREAM_SLOTS + 1];
+ char flags[MAX_STREAM_SLOTS + 1];
FOR_EACH_SLOT(i) {
struct slot_info *s = &slot[i];
flag += 1;
if (s->wng)
flag += 2;
- decoder_flags[i] = flag;
+ flags[i] = flag;
}
- decoder_flags[MAX_STREAM_SLOTS] = '\0';
+ flags[MAX_STREAM_SLOTS] = '\0';
return make_message("%s:%s\n", status_item_list[SI_DECODER_FLAGS],
- decoder_flags);
+ flags);
}
static int dump_commands(int fd)
p->eof = 1;
return;
}
- if (p->status == CL_SENDING_STDIN) {
+ if (p->status == CL_SENDING) {
stdin_set_defaults(&sit);
sit.buf = para_malloc(sit.bufsize),
register_task(&sit.task);
/** \file client.h common client functions and exported symbols from client_common.c */
#include <openssl/rc4.h>
+
+/**
+ * the different states of a connection from the view of the client
+ */
enum {
+ /** tcp connection is established */
CL_CONNECTED,
+ /** server sends the welcome message */
CL_RECEIVED_WELCOME,
+ /** client sends the authentification request */
CL_SENT_AUTH,
+ /** server sends a challenge */
CL_RECEIVED_CHALLENGE,
+ /** clientd solves the challenge and sends the result */
CL_SENT_CH_RESPONSE,
+ /** server accepts this authentication */
CL_RECEIVED_PROCEED,
+ /** client sends the command */
CL_SENT_COMMAND,
- CL_SENDING_STDIN,
- CL_RECEIVING_SERVER_OUTPUT
+ /** server expects data */
+ CL_SENDING,
+ /** client expects data */
+ CL_RECEIVING,
};
#define CLIENT_BUFSIZE 8192
+/**
+ * data specific to a client task
+ */
struct private_client_data {
+ /** the state of the connection */
int status;
+ /** the file descriptor */
int fd;
+ /** the configuration (including the command) */
struct client_args_info conf;
+ /** the config file for client options */
char *config_file;
+ /** the RSA private key */
char *key_file;
+ /** paraslash user name */
char *user;
+ /** session key for receiving data */
RC4_KEY rc4_recv_key;
+ /** session key for sending data */
RC4_KEY rc4_send_key;
+ /** the client task structure */
struct task task;
+ /** non-zero if task is unregistered */
int eof;
+ /** the buffer used for handshake and receiving */
char buf[CLIENT_BUFSIZE];
+ /** number of bytes loaded in \p buf */
size_t loaded;
+ /** non-zero if the pre_select hook added \p fd to the read fd set */
int check_r;
+ /** non-zero if the pre_select hook added \p fd to the write fd set */
int check_w;
+ /** the decrypted challenge */
long unsigned challenge_nr;
- /* only used if stdin gets sent to para_server */
+ /** pointer to the data to be sent to para_server */
char *inbuf;
+ /** number of bytes loaded in \p inbuf */
size_t *in_loaded;
+ /** non-zero if input task encountered an eof or an errro condition */
int *in_eof;
};
{
if (pcd)
return;
- if (pcd->fd >= 0)
+ if (pcd->fd >= 0) {
+ disable_crypt(pcd->fd);
close(pcd->fd);
+ }
free(pcd->user);
free(pcd->config_file);
free(pcd->key_file);
&pcd->conf, 0, 0, 0);
ret = 1;
*pcd_ptr = pcd;
- PARA_INFO_LOG(
- "current loglevel: %d\n"
- "using config_file: %s\n"
- "using key_file: %s\n"
- "connecting to %s:%d\n" ,
- pcd->conf.loglevel_arg,
- pcd->config_file,
- pcd->key_file,
- pcd->conf.hostname_arg, pcd->conf.server_port_arg
- );
+ PARA_INFO_LOG("loglevel: %d\n", pcd->conf.loglevel_arg);
+ PARA_INFO_LOG("config_file: %s\n", pcd->config_file);
+ PARA_INFO_LOG("key_file: %s\n", pcd->key_file);
+ PARA_NOTICE_LOG("connecting %s:%d\n", pcd->conf.hostname_arg,
+ pcd->conf.server_port_arg);
out:
free(home);
if (ret < 0)
pcd->check_w = 1;
return;
- case CL_RECEIVING_SERVER_OUTPUT:
+ case CL_RECEIVING:
if (pcd->loaded < CLIENT_BUFSIZE - 1) {
para_fd_set(pcd->fd, &s->rfds, &s->max_fileno);
pcd->check_r = 1;
}
return;
- case CL_SENDING_STDIN:
+ case CL_SENDING:
if (*pcd->in_loaded) {
PARA_INFO_LOG("loaded: %zd\n", *pcd->in_loaded);
para_fd_set(pcd->fd, &s->wfds, &s->max_fileno);
return;
t->ret = -E_HANDSHAKE_COMPLETE;
if (strstr(pcd->buf, AWAITING_DATA_MSG))
- pcd->status = CL_SENDING_STDIN;
+ pcd->status = CL_SENDING;
else
- pcd->status = CL_RECEIVING_SERVER_OUTPUT;
+ pcd->status = CL_RECEIVING;
return;
- case CL_SENDING_STDIN: /* FIXME: might block */
+ case CL_SENDING: /* FIXME: might block */
PARA_INFO_LOG("loaded: %zd\n", *pcd->in_loaded);
t->ret = send_bin_buffer(pcd->fd, pcd->inbuf, *pcd->in_loaded);
if (t->ret <= 0) {
}
*pcd->in_loaded = 0; /* FIXME: short writes */
return;
- case CL_RECEIVING_SERVER_OUTPUT:
+ case CL_RECEIVING:
t->ret = client_recv_buffer(pcd);
return;
}
struct hostent *he;
struct sockaddr_in their_addr;
- /* get the host info */
- PARA_NOTICE_LOG("getting host info of %s\n",
- pcd->conf.hostname_arg);
ret = get_host_info(pcd->conf.hostname_arg, &he);
if (ret < 0)
goto out;
pcd->fd = ret;
/* init their_addr */
init_sockaddr(&their_addr, pcd->conf.server_port_arg, he);
- /* connect */
- PARA_NOTICE_LOG("connecting to %s\n", pcd->conf.hostname_arg);
ret = para_connect(pcd->fd, &their_addr);
if (ret < 0)
goto out;
pcd->status = CL_CONNECTED;
+ ret = mark_fd_nonblock(pcd->fd);
+ if (ret < 0)
+ goto out;
pcd->task.pre_select = client_pre_select;
pcd->task.post_select = client_post_select;
pcd->task.private_data = pcd;
static char **get_all_atts(int *num_atts)
{
int fd = client_cmd("laa");
- FILE *pipe;
+ FILE *f;
char **ret = NULL, *buf;
if (fd < 0)
return NULL;
- pipe = fdopen(fd, "r");
- if (!pipe) {
+ f = fdopen(fd, "r");
+ if (!f) {
close(fd);
return NULL;
}
*num_atts = 0;
buf = para_malloc(MAXLINE * sizeof(char));
- while (fgets(buf, MAXLINE - 1, pipe) && *buf) {
+ while (fgets(buf, MAXLINE - 1, f) && *buf) {
size_t n = strlen(buf);
buf[n - 1] = '\0';
if (choice_len < n - 1)
static int dccp_write(int fd, const char *buf, size_t len)
{
- size_t send, written = 0;
+ size_t size, written = 0;
int ret;
again:
- send = PARA_MIN(1024, len - written);
- ret = write(fd, buf + written, send);
+ size = PARA_MIN(1024, len - written);
+ ret = write(fd, buf + written, size);
if (ret < 0)
goto err_out;
written += ret;
time_t t1, wake_time_epoch;
unsigned int delay;
struct tm *tm;
- int hour = args_info.wake_hour_arg;
int min = args_info.wake_min_arg;
char *fa_stream = args_info.fa_stream_arg;
char *wake_stream = args_info.wake_stream_arg;
char *cmd, *sleep_stream = args_info.sleep_stream_given?
args_info.sleep_stream_arg : NULL;
+ /* calculate wake time */
+ time(&t1);
+ if (args_info.wake_hour_given) {
+ int hour = args_info.wake_hour_arg;
+ tm = localtime(&t1);
+ if (tm->tm_hour > hour || (tm->tm_hour == hour && tm->tm_min> min)) {
+ t1 += 86400; /* wake time is tomorrow */
+ tm = localtime(&t1);
+ }
+ tm->tm_hour = hour;
+ tm->tm_min = min;
+ tm->tm_sec = 0;
+ } else {
+ t1 += 8 * 60 * 60;
+ PARA_INFO_LOG("default wake time: %lu\n", t1);
+ tm = localtime(&t1);
+ }
+ wake_time_epoch = mktime(tm);
+ PARA_INFO_LOG("waketime: %s", asctime(tm));
if (sf) {
PARA_INFO_LOG("initial volume: %d\n", iv);
set_vol(iv);
client_cmd("stop");
if (!wf)
return;
- /* calculate wake time */
- time(&t1);
- tm = localtime(&t1);
- if (tm->tm_hour > hour || (tm->tm_hour == hour && tm->tm_min> min)) {
- /* wake time is tomorrow */
- t1 += 86400;
- tm = localtime(&t1);
- t1 -= 86400;
- }
- tm->tm_hour = hour;
- tm->tm_min = min;
- tm->tm_sec = 0;
- wake_time_epoch = mktime(tm);
- PARA_INFO_LOG("waketime: %s", asctime(tm));
- while (wake_time_epoch > t1 + wf) {
+ for (;;) {
+ time(&t1);
+ if (wake_time_epoch <= t1 + wf)
+ break;
delay = wake_time_epoch - t1 - wf;
PARA_INFO_LOG("sleeping %u seconds (%u:%02u)\n",
delay, delay / 3600,
(delay % 3600) / 60);
sleep(delay);
- time(&t1);
}
cmd = make_message("csp %s\n", wake_stream);
client_cmd(cmd);
section "general options"
-option "mode" o "{sleep|fade|snooze}" string default="sleep" optional
-option "config_file" c "(default='~/.paraslash/fade.conf')" string typestr="filename" optional
-option "mixer_device" m "mixer device file" string typestr="device" default="/dev/mixer" optional
+#########################
+
+option "mode" o
+#~~~~~~~~~~~~~~
+
+"{sleep|fade|snooze}"
+ string default="sleep"
+ optional
+
+option "config_file" c
+#~~~~~~~~~~~~~~~~~~~~~
+ "(default='~/.paraslash/fade.conf')"
+ string typestr="filename"
+ optional
+
+option "mixer_device" m
+#~~~~~~~~~~~~~~~~~~~~~~
+ "mixer device file"
+ string typestr="device"
+ default="/dev/mixer"
+ optional
section "sleep options (only relevant in sleep mode)"
-option "sleep_ivol" - "set initial volume before doing anything else" int typestr="volume" default="60" optional
-option "fa_stream" - "fall asleep stream. Change to this stream right after setting the volume" string typestr="streamname" default="fa" optional
-option "fa_fade" - "fall asleep fading time, no fading if set to 0" int typestr="seconds" default="1800" optional
-option "fa_vol" - "volume to fade to" int typestr="volume" default="20" optional
-option "sleep_stream" - "change to this stream after fading, stop playing if unset" string typestr="streamname" default="sleep" optional
-option "wake_hour" H "(0-23)" int default="8" optional
-option "wake_min" M "(0-59)" int default="0" optional
-option "wake_stream" - "changed to on waketime" string typestr="streamname" default="wake" optional
-option "wake_fade" - "no fading in if set to 0" int typestr="seconds" default="1200" optional
-option "wake_vol" - "vol to fade to at waketime" int typestr="volume" default="80" optional
+#####################################################
+
+option "sleep_ivol" -
+#~~~~~~~~~~~~~~~~~~~~
+ "set initial volume before doing anything else"
+ int typestr="volume"
+ default="60"
+ optional
+
+option "fa_stream" -
+#~~~~~~~~~~~~~~~~~~~
+ "fall asleep stream. Change to this stream
+right after setting the volume"
+
+ string typestr="streamname"
+ default="fa"
+ optional
+
+option "fa_fade" -
+#~~~~~~~~~~~~~~~~~
+ "fall asleep fading time, no fading if set
+to 0"
+ int typestr="seconds"
+ default="1800"
+ optional
+
+option "fa_vol" -
+#~~~~~~~~~~~~~~~~
+ "volume to fade to"
+ int typestr="volume"
+ default="20"
+ optional
+
+option "sleep_stream" -
+#~~~~~~~~~~~~~~~~~~~~~~
+ "change to this stream after fading, stop
+playing if unset"
+ string typestr="streamname"
+ default="sleep"
+ optional
+
+option "wake_hour" H
+#~~~~~~~~~~~~~~~~~~~
+ "(0-23)"
+ int typestr="hour"
+ default="8"
+ optional
+
+option "wake_min" M
+#~~~~~~~~~~~~~~~~~~
+"(0-59)"
+ int typestr="seconds"
+ default="0"
+ optional
+
+option "wake_stream" -
+#~~~~~~~~~~~~~~~~~~~~~
+ "change to this stream on waketime"
+ string typestr="streamname"
+ default="wake"
+ optional
+
+option "wake_fade" -
+#~~~~~~~~~~~~~~~~~~~
+ "no fading in if set to 0"
+ int typestr="seconds"
+ default="1200"
+ optional
+
+option "wake_vol" -
+#~~~~~~~~~~~~~~~~~~
+ "vol to fade to at waketime"
+ int typestr="volume"
+ default="80"
+ optional
section "snooze options"
-option "snooze_out_fade" - "fade out time" int typestr="seconds" default="30" optional
-option "snooze_out_vol" - "vol to fade to before snooze" int typestr="volume" default="20" optional
-option "snooze_time" - "delay" int typestr="seconds" default="600" optional
-option "snooze_in_fade" - "fade in time" int typestr="seconds" default="180" optional
-option "snooze_in_vol" - "vol to fade to after snooze" int typestr="volume" default="80" optional
+########################
+
+option "snooze_out_fade" -
+#~~~~~~~~~~~~~~~~~~~~~~~~~
+ "fade out time"
+ int typestr="seconds"
+ default="30"
+ optional
+
+option "snooze_out_vol" -
+#~~~~~~~~~~~~~~~~~~~~~~~~
+ "vol to fade to before snooze"
+ int typestr="volume"
+ default="20"
+ optional
+
+option "snooze_time" -
+#~~~~~~~~~~~~~~~~~~~~~
+ "delay"
+ int typestr="seconds"
+ default="600"
+ optional
+
+option "snooze_in_fade" -
+#~~~~~~~~~~~~~~~~~~~~~~~~
+ "fade in time"
+ int typestr="seconds"
+ default="180"
+ optional
+
+option "snooze_in_vol" -
+#~~~~~~~~~~~~~~~~~~~~~~~
+ "vol to fade to after snooze"
+ int typestr="volume"
+ default="80"
+ optional
section "fade options"
-option "fade_vol" f "volume to fade to" int typestr="volume" default="50" optional
-option "fade_time" t "time to fade in" int typestr="seconds" default="5" optional
+######################
+
+option "fade_vol" f
+#~~~~~~~~~~~~~~~~~~
+ "volume to fade to"
+ int typestr="volume"
+ default="50"
+ optional
+
+option "fade_time" t
+#~~~~~~~~~~~~~~~~~~~
+ "time to fade in"
+ int typestr="seconds"
+ default="5"
+ optional
* \sa select(2) select_tut(2)
*/
int para_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout)
+ struct timeval *timeout_tv)
{
int ret, err;
do {
- ret = select(n, readfds, writefds, NULL, timeout);
+ ret = select(n, readfds, writefds, NULL, timeout_tv);
err = errno;
} while (ret < 0 && err == EINTR);
if (ret < 0)
int file_exists(const char *);
int para_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout);
+ struct timeval *timeout_tv);
int mark_fd_nonblock(int fd);
void para_fd_set(int fd, fd_set *fds, int *max_fileno);
__must_check int para_fread(void *dest, size_t nbytes, size_t nmemb, FILE *stream);
list_for_each_entry(fn, &fc->filters, node) {
if (*loaded && fn->loaded < fn->bufsize) {
size_t old_fn_loaded = fn->loaded;
- PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n",
- fc, *loaded, fn->filter->name);
+// PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n",
+// fc, *loaded, fn->filter->name);
t->ret = fn->filter->convert(ib, *loaded, fn);
if (t->ret < 0)
goto err_out;
*loaded -= t->ret;
conv += t->ret;
if (*loaded && t->ret) {
- PARA_DEBUG_LOG("moving %zd bytes in input "
- "buffer for %s filter\n",
- *loaded, fn->filter->name);
+// PARA_DEBUG_LOG("moving %zd bytes in input "
+// "buffer for %s filter\n",
+// *loaded, fn->filter->name);
memmove(ib, ib + t->ret, *loaded);
}
}
loaded = &fn->loaded;
}
conv_total += conv;
- PARA_DEBUG_LOG("eof (in/out/fc): %d/%d/%d out_loaded: %zd, "
- "conv: %d, conv_total: %d\n", *fc->input_eof,
- fc->output_eof? *fc->output_eof : -42,
- fc->eof, *fc->out_loaded, conv, conv_total);
+// PARA_DEBUG_LOG("eof (in/out/fc): %d/%d/%d out_loaded: %zd, "
+// "conv: %d, conv_total: %d\n", *fc->input_eof,
+// fc->output_eof? *fc->output_eof : -42,
+// fc->eof, *fc->out_loaded, conv, conv_total);
if (conv)
goto again;
t->ret = 1;
static int check_gc_args(struct grab_client *gc)
{
int i;
- struct grab_client_args_info *conf = gc->conf;
+ struct grab_client_args_info *c = gc->conf;
char **mv = grab_client_cmdline_parser_mode_values;
- PARA_INFO_LOG("filter_num: %d\n", gc->conf->filter_num_arg);
+ PARA_INFO_LOG("filter_num: %d\n", c->filter_num_arg);
for (i = 0; mv[i]; i++)
- if (!strcmp(conf->mode_arg, mv[i]))
+ if (!strcmp(c->mode_arg, mv[i]))
break;
if (!mv[i])
return -E_GC_SYNTAX;
gc->mode = i;
gc->audio_format_num = -1;
- if (conf->audio_format_given) {
- gc->audio_format_num = get_audio_format_num(conf->audio_format_arg);
+ if (c->audio_format_given) {
+ gc->audio_format_num = get_audio_format_num(c->audio_format_arg);
if (gc->audio_format_num < 0)
return gc->audio_format_num;
}
- if (conf->slot_arg > MAX_STREAM_SLOTS)
+ if (c->slot_arg > MAX_STREAM_SLOTS)
return -E_BAD_GC_SLOT;
- if (conf->filter_num_arg <= 0)
+ if (c->filter_num_arg <= 0)
return -E_BAD_GC_FILTER_NUM;
- if (conf->audio_format_given) {
- if (num_filters(gc->audio_format_num) < conf->filter_num_arg)
+ if (c->audio_format_given) {
+ if (num_filters(gc->audio_format_num) < c->filter_num_arg)
return -E_BAD_GC_FILTER_NUM;
} else
- if (conf->filter_num_arg > max_num_filters())
+ if (c->filter_num_arg > max_num_filters())
return -E_BAD_GC_FILTER_NUM;
return 1;
* \sa filter_chain_info::filters, inactive_grab_client_list,
* activate_grab_client
*/
-void activate_inactive_grab_clients(int slot, int audio_format_num,
+void activate_inactive_grab_clients(int slot_num, int audio_format_num,
struct list_head *filter_list)
{
struct grab_client *gc, *tmp;
list_for_each_entry_safe(gc, tmp, &inactive_grab_client_list, node) {
// PARA_INFO_LOG("checking inactive grab client %p\n", gc);
- if (gc->conf->slot_arg >= 0 && gc->conf->slot_arg != slot)
+ if (gc->conf->slot_arg >= 0 && gc->conf->slot_arg != slot_num)
continue;
if (gc->audio_format_num >= 0 && gc->audio_format_num !=
audio_format_num)
/* command pipe only for COMMAND_MODE */
if (command_pipe >= 0 && mode == COMMAND_MODE)
para_fd_set(command_pipe, &rfds, &max_fileno);
- if (curses_active)
- para_fd_set(STDIN_FILENO, &rfds, &max_fileno);
ret = para_select(max_fileno + 1, &rfds, NULL, &tv);
-// PARA_DEBUG_LOG("select returned %d\n", ret);
if (ret <= 0)
goto check_return; /* skip fd checks */
/* signals */
{
struct rb_entry *rbe = NULL;
unsigned lines;
- int i, first_rbe, scroll;
+ int i, first_rbe, num_scroll;
/* the entry that is going to vanish */
rbe = ringbuffer_get(bot_win_rb, scroll_position);
if (!rbe)
goto err_out;
- scroll = NUM_LINES(rbe->len);
+ num_scroll = NUM_LINES(rbe->len);
first_rbe = first_visible_rbe(&lines);
if (first_rbe < 0 || (first_rbe == ringbuffer_filled(bot_win_rb) - 1))
goto err_out;
scroll_position++;
- wscrl(bot.win, -scroll);
+ wscrl(bot.win, -num_scroll);
i = draw_top_rbe(&lines);
if (i < 0)
goto err_out;
- while (i > 0 && lines < scroll) {
+ while (i > 0 && lines < num_scroll) {
int rbe_lines;
rbe = ringbuffer_get(bot_win_rb, --i);
if (!rbe)
option "auto_decode" a "auto-decode audio stream" flag on
option "config_file" c "(default='~/.paraslash/gui.conf')" string typestr="filename" optional
option "loglevel" l "set loglevel (0-6)" int typestr="level" default="4" optional
-option "timeout" t "set timeout" int typestr="milliseconds" default="300" optional
+option "timeout" t "set timeout" int typestr="milliseconds" default="30" optional
option "stat_cmd" s "command to read server and audiod status data from" string typestr="command" default="para_audioc -t 100 stat" optional
section "mapping keys to commands"
#include "para.h"
+#include "fd.h"
extern const char *status_item_list[NUM_STAT_ITEMS];
{
int fds[3] = {0, 1, 0};
pid_t pid;
- return para_exec_cmdline_pid(&pid, cmd, fds) > 0?
- fds[1] : -1;
+ int ret = para_exec_cmdline_pid(&pid, cmd, fds);
+ if (ret < 0)
+ return ret;
+ ret = mark_fd_nonblock(fds[1]);
+ if (ret > 0)
+ return fds[1];
+ close(fds[1]);
+ return ret;
}
int read_audiod_pipe(int fd, void (*line_handler)(char *) )
continue;
if (hc->status == HTTP_READY_TO_STREAM) {
int hlen;
- char *buf = afs_get_header(&hlen);
- if (buf && hlen > 0 && current_chunk) {
+ char *hbuf = afs_get_header(&hlen);
+ if (hbuf && hlen > 0 && current_chunk) {
/* need to send header */
PARA_INFO_LOG("queueing header: %d\n", hlen);
- if (queue_packet(hc, buf, hlen) < 0)
+ if (queue_packet(hc, hbuf, hlen) < 0)
continue;
} else
PARA_INFO_LOG("%s", "no need to queue header\n");
tv_divide(fcount, &total_time, &af->chunk_tv);
rewind(mp3.file);
PARA_DEBUG_LOG("chunk_time: %lums\n", tv2ms(&af->chunk_tv));
- tv_scale(30, &af->chunk_tv, &af->eof_tv);
+ tv_scale(3, &af->chunk_tv, &af->eof_tv);
PARA_DEBUG_LOG("eof timeout: %lu\n", tv2ms(&af->eof_tv));
return 1;
}
#include "string.h"
#include "error.h"
+
+/** \cond holds information about one encrypted connection */
struct crypt_data {
crypt_function *recv;
crypt_function *send;
void *private_data;
};
-
-static struct crypt_data *crypt_data_array;
static unsigned cda_size = 0;
+static struct crypt_data *crypt_data_array;
+/** \endcond */
-void enable_crypt(int fd, crypt_function *recv, crypt_function *send,
+
+/**
+ * activate encryption for one file descriptor
+ *
+ * \param fd the file descriptor
+ * \param recv_f the function used for decrypting received data
+ * \param send_f the function used for encrypting before sending
+ * \param private_data user data supplied by the caller
+ */
+void enable_crypt(int fd, crypt_function *recv_f, crypt_function *send_f,
void *private_data)
{
if (fd + 1 > cda_size) {
crypt_data_array = para_realloc(crypt_data_array,
(fd + 1) * sizeof(struct crypt_data));
- memset(crypt_data_array + cda_size * sizeof(struct crypt_data), 0,
+ memset(crypt_data_array + cda_size, 0,
(fd + 1 - cda_size) * sizeof(struct crypt_data));
cda_size = fd + 1;
}
- crypt_data_array[fd].recv = recv;
- crypt_data_array[fd].send = send;
+ crypt_data_array[fd].recv = recv_f;
+ crypt_data_array[fd].send = send_f;
crypt_data_array[fd].private_data = private_data;
PARA_INFO_LOG("rc4 encryption activated for fd %d\n", fd);
}
+/**
+ * deactivate encryption for a given fd
+ *
+ * \param fd the file descriptor
+ *
+ * This must be called if and only if \p fd was activated via enable_crypt().
+ */
void disable_crypt(int fd)
{
if (cda_size < fd + 1)
goto out;
ret = 1;
out:
- if (ret < 0)
- PARA_NOTICE_LOG("did not receive pattern '%s'\n", pattern);
+ if (ret < 0) {
+ PARA_NOTICE_LOG("n = %d, did not receive pattern '%s'\n", n, pattern);
+ if (n > 0)
+ PARA_NOTICE_LOG("recvd: %s\n", buf);
+ }
free(buf);
return ret;
}
ssize_t send_cred_buffer(int, char*);
int recv_pattern(int fd, const char *pattern, size_t bufsize);
int init_tcp_socket(int port);
-void enable_crypt(int fd, crypt_function *recv, crypt_function *send,
+void enable_crypt(int fd, crypt_function *recv_f, crypt_function *send_f,
void *private_data);
void disable_crypt(int fd);
static int header_len, oggbuf_len, vi_channels;
static char *header, *oggbuf;
static ssize_t *chunk_table, max_chunk_len;
-struct audio_format_handler *af;
+static struct audio_format_handler *af;
static long vi_sampling_rate, vi_bitrate, vi_bitrate_nominal,
num_chunks;
continue;
}
if (j < 0)
- tv_scale(i + 2, &af->chunk_tv, &af->eof_tv);
+ tv_scale(i, &af->chunk_tv, &af->eof_tv);
for (j = lp; j < i; j++)
chunk_table[j] = chunk_table[i];
lp = i;
oggbuf_len = 0;
}
-static int ogg_save_header(FILE *file, int header_len)
+static int ogg_save_header(FILE *file, int len)
{
int ret;
- header = para_malloc(header_len);
+ header = para_malloc(len);
rewind(file);
- ret = read(fileno(file), header, header_len);
- if (ret != header_len)
+ ret = read(fileno(file), header, len);
+ if (ret != len)
return -E_OGG_READ;
return 1;
}
#define CHUNK_SIZE 128 * 1024
-extern int msg_to_buf(mblk_t *, char *, int);
-
/**
* data specific to the ortp receiver
*
uint32_t chunk_ts;
};
+
+static int msg_to_buf(mblk_t *mp, char *buffer, int len)
+{
+ int rlen = len;
+ mblk_t *m, *mprev;
+ int mlen;
+
+ m = mp->b_cont;
+ mprev = mp;
+ while (m != NULL) {
+ mlen = (int) (m->b_wptr - m->b_rptr);
+ if (mlen <= rlen) {
+ mblk_t *consumed = m;
+ memcpy (buffer, m->b_rptr, mlen);
+ /* go to next mblk_t */
+ mprev->b_cont = m->b_cont;
+ m = m->b_cont;
+ consumed->b_cont = NULL;
+ freeb (consumed);
+ buffer += mlen;
+ rlen -= mlen;
+ } else { /*if mlen>rlen */
+ memcpy (buffer, m->b_rptr, rlen);
+ m->b_rptr += rlen;
+ return len;
+ }
+ }
+ return len - rlen;
+}
+
+
static void ortp_recv_pre_select(struct sched *s, struct task *t)
{
struct receiver_node *rn = t->private_data;
tv_add(&chunk_tv, &pord->next_chunk, &tmp);
pord->next_chunk = tmp;
pord->timestamp += pord->chunk_ts;
- PARA_DEBUG_LOG("next chunk (ts = %d) due at %lu:%lu\n",
- pord->timestamp, pord->next_chunk.tv_sec,
- pord->next_chunk.tv_usec);
+// PARA_DEBUG_LOG("next chunk (ts = %d) due at %lu:%lu\n",
+// pord->timestamp, pord->next_chunk.tv_sec,
+// pord->next_chunk.tv_usec);
}
static void ortp_recv_post_select(__a_unused struct sched *s, struct task *t)
static int ortp_recv_open(struct receiver_node *rn)
{
struct private_ortp_recv_data *pord;
- struct ortp_recv_args_info *conf = rn->conf;
+ struct ortp_recv_args_info *c = rn->conf;
rn->buf = para_calloc(CHUNK_SIZE);
rn->private_data = para_calloc(sizeof(struct private_ortp_recv_data));
pord = rn->private_data;
pord->session = rtp_session_new(RTP_SESSION_RECVONLY);
- PARA_NOTICE_LOG("receiving from %s:%d\n", conf->host_arg, conf->port_arg);
- rtp_session_set_local_addr(pord->session, conf->host_arg, conf->port_arg);
+ PARA_NOTICE_LOG("receiving from %s:%d\n", c->host_arg, c->port_arg);
+ rtp_session_set_local_addr(pord->session, c->host_arg, c->port_arg);
rtp_session_set_payload_type(pord->session, PAYLOAD_AUDIO_CONTINUOUS);
- if (conf->jitter_compensation_arg) {
+ if (c->jitter_compensation_arg) {
rtp_session_enable_adaptive_jitter_compensation(pord->session, TRUE);
rtp_session_set_jitter_compensation(pord->session,
- conf->jitter_compensation_arg);
+ c->jitter_compensation_arg);
}
return 1;
}
#if DEBUG > COMPILE_TIME_LOGLEVEL
#define PARA_DEBUG_LOG(f,...) para_log(DEBUG, "%s: " f, __FUNCTION__, __VA_ARGS__)
#else
-#define PARA_DEBUG_LOG(...)
+#define PARA_DEBUG_LOG(...) do {;} while (0)
#endif
#if INFO > COMPILE_TIME_LOGLEVEL
#define PARA_INFO_LOG(f,...) para_log(INFO, "%s: " f, __FUNCTION__, __VA_ARGS__)
#else
-#define PARA_INFO_LOG(...)
+#define PARA_INFO_LOG(...) do {;} while (0)
#endif
#if NOTICE > COMPILE_TIME_LOGLEVEL
#define PARA_NOTICE_LOG(f,...) para_log(NOTICE, "%s: " f, __FUNCTION__, __VA_ARGS__)
#else
-#define PARA_NOTICE_LOG(...)
+#define PARA_NOTICE_LOG(...) do {;} while (0)
#endif
#if WARNING > COMPILE_TIME_LOGLEVEL
#define PARA_WARNING_LOG(f,...) para_log(WARNING, "%s: " f, __FUNCTION__, __VA_ARGS__)
#else
-#define PARA_WARNING_LOG(...)
+#define PARA_WARNING_LOG(...) do {;} while (0)
#endif
#if ERROR > COMPILE_TIME_LOGLEVEL
#define PARA_ERROR_LOG(f,...) para_log(ERROR, "%s: " f, __FUNCTION__, __VA_ARGS__)
#else
-#define PARA_ERROR_LOG(...)
+#define PARA_ERROR_LOG(...) do {;} while (0)
#endif
#if CRIT > COMPILE_TIME_LOGLEVEL
#define PARA_CRIT_LOG(f,...) para_log(CRIT, "%s: " f, __FUNCTION__, __VA_ARGS__)
#else
-#define PARA_CRIT_LOG(...)
+#define PARA_CRIT_LOG(...) do {;} while (0)
#endif
#if EMERG > COMPILE_TIME_LOGLEVEL
void d2tv(double, struct timeval*);
void tv_add(const struct timeval*, const struct timeval *, struct timeval *);
void tv_scale(const unsigned long, const struct timeval *, struct timeval *);
-void tv_divide(const unsigned long div, const struct timeval *tv,
+void tv_divide(const unsigned long divisor, const struct timeval *tv,
struct timeval *result);
int tv_convex_combination(const long a, const struct timeval *tv1,
const long b, const struct timeval *tv2,
*/
static int command_handler(void)
{
- FILE *pipe;
+ FILE *f;
unsigned count = 0;
char text[MAXLINE]="";
char buf[MAXLINE]="";
if (text[0] == '!') {
if (text[1] == '\0')
return 1;
- pipe = popen(text + 1, "r");
+ f = popen(text + 1, "r");
} else {
sprintf(buf, BINDIR "/para_client %s 2>&1", text);
- pipe = popen(buf, "r");
+ f = popen(buf, "r");
}
- if (!pipe)
+ if (!f)
return 0;
fill_output_rect();
- while(fgets(text, MAXLINE - 1, pipe)) {
+ while(fgets(text, MAXLINE - 1, f)) {
int len;
tab2space(text);
update_all();
hit_key("Hit any key to return");
out: fill_output_rect();
- pclose(pipe);
+ pclose(f);
return 1;
}
SDL_RWops *rwop;
int fds[3] = {0, 1, 0};
pid_t pid;
- FILE *pipe;
+ FILE *f;
if (para_exec_cmdline_pid(&pid, args_info.pic_cmd_arg, fds) < 0)
return NULL;
- pipe = fdopen(fds[1], "r");
- if (!pipe)
+ f = fdopen(fds[1], "r");
+ if (!f)
return NULL;
- if (!(rwop = SDL_RWFromFP(pipe, 0)))
+ if (!(rwop = SDL_RWFromFP(f, 0)))
return NULL;
return IMG_LoadJPG_RW(rwop);
}
* Read stat line from pipe if pipe is ready, call update_status to
* display information.
*/
-static int draw_status(int pipe)
+static int draw_status(int fd)
{
fd_set rfds;
int ret;
tv.tv_sec = 0;
tv.tv_usec = 3000000;
FD_ZERO(&rfds);
- FD_SET(pipe, &rfds);
- ret = para_select(pipe + 1, &rfds, NULL, &tv);
+ FD_SET(fd, &rfds);
+ ret = para_select(fd + 1, &rfds, NULL, &tv);
if (ret <= 0)
return 0;
- if (read_audiod_pipe(pipe, update_status) > 0)
+ if (read_audiod_pipe(fd, update_status) > 0)
return 1;
free(stat_items[SI_STATUS_BAR].content);
stat_items[SI_STATUS_BAR].content =
*/
int main(int argc, char *argv[])
{
- int i, ret, pipe;
+ int i, ret, fd;
SDLKey sym;
sdl_gui_cmdline_parser(argc, argv, &args_info);
height = args_info.height_arg;
// printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg);
init_stat_items();
- pipe = para_open_audiod_pipe(args_info.stat_cmd_arg);
+ fd = para_open_audiod_pipe(args_info.stat_cmd_arg);
init_SDL();
for (i = 0; fonts[i].name[0]; i++) {
char buf[MAXLINE];
update_input();
}
for (;;) {
- ret = draw_status(pipe);
+ ret = draw_status(fd);
if (ret < 0) {
- close(pipe);
- pipe = -1;
+ close(fd);
+ fd = -1;
}
if (SDL_QuitRequested())
clean_exit(0);
|| sym == SDLK_COMPOSE
)
continue;
- if (pipe < 0) {
-// printf("closing pipe\n");
- kill(0, SIGINT);
- close(pipe);
-// printf("pipe closed\n");
+ if (fd < 0) {
+ kill(0, SIGINT);
+ close(fd);
}
fill_input_rect();
update_input();
print_help();
update_pic();
SDL_UpdateRect(screen, 0, 0, 0, 0);
- pipe = para_open_audiod_pipe(args_info.stat_cmd_arg);
+ fd = para_open_audiod_pipe(args_info.stat_cmd_arg);
break;
}
}
if (pid <= 0) {
if (pid < 0)
pid = -E_WAITPID;
- return 0;
+ return pid;
}
if (WIFEXITED(status))
PARA_DEBUG_LOG("child %i exited. Exit status: %i\n", pid,
#define MAX_STAT_CLIENTS 50
/**
- * The structure associated with a connected client that sent the 'stat' command
-*
+ * describes a status client of para_audiod
+ *
+ * There's one such structure per audiod client that sent the 'stat' command.
*
* A status client is identified by its file descriptor. para_audiod
* keeps a list of connected status clients.
*/
struct stat_client {
-/**
- *
- *
- * the stat client's file descriptor
- */
-int fd;
-long unsigned item_mask;
-/**
- *
- * its entry in the list of stat clients
-*/
-struct list_head node;
+ /** the stat client's file descriptor */
+ int fd;
+ /** bitmask of those status items the client is interested in */
+ long unsigned item_mask;
+ /** its entry in the list of stat clients */
+ struct list_head node;
};
static struct list_head client_list;
/**
* compute fraction of given struct timeval
*
- * \param div the integer value to divide by
+ * \param divider the integer value to divide by
* \param tv the timevalue to divide
* \param result holds (1 / mult) * tv upon return
*/
-void tv_divide(const unsigned long div, const struct timeval *tv,
+void tv_divide(const unsigned long divisor, const struct timeval *tv,
struct timeval *result)
{
- long unsigned q = tv->tv_usec / div;
- result->tv_sec = tv->tv_sec / div;
- result->tv_usec = (tv->tv_sec - result->tv_sec * div) * 1000 * 1000 / div;
+ long unsigned q = tv->tv_usec / divisor;
+ result->tv_sec = tv->tv_sec / divisor;
+ result->tv_usec = (tv->tv_sec - result->tv_sec * divisor)
+ * 1000 * 1000 / divisor;
if (result->tv_usec + q >= 1000 * 1000) {
result->tv_sec++;
result->tv_usec = 1000 * 1000 - result->tv_usec - q;
SPAN.preprocessor { color: #CC00CC }
SPAN.stringliteral { color: #e0e020 }
SPAN.charliteral { color: #0000ff }
-.mdTable {
- border: 1px solid #868686;
- background-color: #112244;
-}
-.mdRow {
- padding: 8px 10px;
-}
.mdescLeft {
padding: 0px 8px 4px 8px;
font-size: 80%;
border: none;
border-top: 1px solid yellow;
}
+/* Style for detailed member documentation */
+.memtemplate {
+ font-size: 80%;
+ color: #a0a0a0;
+ font-weight: normal;
+}
+.memnav {
+/* background-color: #181eff; */
+ border: 1px solid #845047;
+ text-align: center;
+ margin: 2px;
+ margin-right: 15px;
+ padding: 2px;
+}
+.memitem {
+ padding: 4px;
+ background-color: #000000;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ffff00;
+ -moz-border-radius: 8px 8px 8px 8px;
+}
+.memname {
+ white-space: nowrap;
+ font-weight: bold;
+}
+.memdoc{
+ padding-left: 10px;
+}
+.memproto {
+ background-color: #000055;
+ width: 100%;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ffff00;
+ font-weight: bold;
+ -moz-border-radius: 8px 8px 8px 8px;
+}
+.paramkey {
+ text-align: right;
+}
+.paramtype {
+ white-space: nowrap;
+}
+.paramname {
+ color: #00ff00;
+ font-style: italic;
+}
+/* End Styling for detailed member documentation */
+
+
+/* gitweb */
+div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background
+-color:#000000; }
+div.page_nav { padding:8px; }
+div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
+div.page_footer { height:17px; padding:4px 8px; background-color: #000000; }
+div.page_footer_text { float:left; color:#888888; font-style:italic; }
+div.page_body { padding:8px; }
+div.title, a.title {
+ padding:6px 8px;
+ font-weight:bold;
+}
+div.log_body { padding:8px 8px 8px 150px; }
+span.age { position:relative; float:left; width:142px; font-style:italic; }
+div.log_link {
+ padding:0px 8px;
+ font-size:10px; font-family:sans-serif; font-style:normal;
+ position:relative; float:left; width:136px;
+}
+table { padding:8px 4px; }
+th { padding:2px 5px; font-size:12px; text-align:left; }
+td { padding:2px 5px; font-size:12px; vertical-align:top; }
+td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
+div.pre { font-family:monospace; font-size:12px; white-space:pre; }
+div.diff_info { font-family:monospace; color:#8888ff; font-style:italic; }
+div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
+div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
+a.linenr { color:#999999; text-decoration:none }
+a.rss_logo {
+ float:right; padding:3px 0px; width:35px; line-height:10px;
+ border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
+ color:#ffffff; background-color:#ff6600;
+ font-weight:bold; font-family:sans-serif; font-size:10px;
+ text-align:center; text-decoration:none;
+}
+a.rss_logo:hover { background-color:#ee5500; }
+span.tag {
+ padding:0px 4px; font-size:10px; font-weight:normal;
*/
static void check_wav_pre_select(__a_unused struct sched *s, struct task *t)
{
- struct check_wav_task *cwt = t->private_data;
+ struct check_wav_task *wt = t->private_data;
unsigned char *a;
- if (*cwt->loaded < WAV_HEADER_LEN) {
- t->ret = *cwt->eof? -E_PREMATURE_END : 1;
+ if (*wt->loaded < WAV_HEADER_LEN) {
+ t->ret = *wt->eof? -E_PREMATURE_END : 1;
return;
}
- cwt->channels = 2;
- cwt->samplerate = 44100;
- a = (unsigned char*)cwt->buf;
+ wt->channels = 2;
+ wt->samplerate = 44100;
+ a = (unsigned char*)wt->buf;
t->ret = -E_NO_WAV_HEADER;
if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F')
return;
- cwt->channels = (unsigned) a[22];
- cwt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- *cwt->loaded -= WAV_HEADER_LEN;
- memmove(cwt->buf, cwt->buf + WAV_HEADER_LEN, *cwt->loaded);
+ wt->channels = (unsigned) a[22];
+ wt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
+ *wt->loaded -= WAV_HEADER_LEN;
+ memmove(wt->buf, wt->buf + WAV_HEADER_LEN, *wt->loaded);
t->ret = -E_WAV_HEADER_SUCCESS;
- PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->samplerate);
+ PARA_INFO_LOG("channels: %d, sample rate: %d\n", wt->channels, wt->samplerate);
}
static void initial_delay_pre_select(struct sched *s, struct task *t)
{
- struct initial_delay_task *idt = t->private_data;
+ struct initial_delay_task *dt = t->private_data;
struct timeval diff;
t->ret = -E_NO_DELAY;
- if (!idt->start_time.tv_sec && !idt->start_time.tv_usec)
+ if (!dt->start_time.tv_sec && !dt->start_time.tv_usec)
return;
t->ret = -E_DELAY_TIMEOUT;
- if (tv_diff(now, &idt->start_time, &diff) > 0)
+ if (tv_diff(now, &dt->start_time, &diff) > 0)
return;
t->ret = 1;
if (tv_diff(&s->timeout , &diff, NULL) > 0)
static struct writer_node_group *check_args(void)
{
int i, ret = -E_WRITE_SYNTAX;
- struct writer_node_group *wng = NULL;
+ struct writer_node_group *g = NULL;
if (conf.list_writers_given) {
char *msg = NULL;
free(msg);
exit(EXIT_SUCCESS);
}
-// if (conf.prebuffer_arg < 0 || conf.prebuffer_arg > 100)
-// goto out;
if (conf.start_time_given) {
long unsigned sec, usec;
if (sscanf(conf.start_time_arg, "%lu:%lu",
idt.start_time.tv_usec = usec;
}
if (!conf.writer_given) {
- wng = setup_default_wng();
+ g = setup_default_wng();
ret = 1;
goto out;
}
- wng = wng_new(conf.writer_given);
+ g = wng_new(conf.writer_given);
ret = -E_WRITE_SYNTAX;
for (i = 0; i < conf.writer_given; i++) {
int writer_num;
- wng->writer_nodes[i].conf = check_writer_arg(
+ g->writer_nodes[i].conf = check_writer_arg(
conf.writer_arg[i], &writer_num);
- if (!wng->writer_nodes[i].conf)
+ if (!g->writer_nodes[i].conf)
goto out;
- wng->writer_nodes[i].writer = &writers[writer_num];
+ g->writer_nodes[i].writer = &writers[writer_num];
}
ret = 1;
out:
if (ret > 0)
- return wng;
- free(wng);
+ return g;
+ free(g);
return NULL;
}