exit(status);
}
-#if 0
-__malloc static char *glob_cmd(char *cmd)
-{
- char *ret, *replacement;
- struct timeval tmp, delay, rss; /* real stream start */
-
- delay.tv_sec = conf.stream_delay_arg / 1000;
- delay.tv_usec = (conf.stream_delay_arg % 1000) * 1000;
-// PARA_INFO_LOG("delay: %lu:%lu\n", delay.tv_sec, delay.tv_usec);
- if (sa_time_diff_sign < 0)
- tv_add(&server_stream_start, &sa_time_diff, &rss);
- else
- tv_diff(&server_stream_start, &sa_time_diff, &rss);
- tv_add(&rss, &delay, &tmp);
- replacement = make_message("%lu:%lu",
- (long unsigned)tmp.tv_sec,
- (long unsigned)tmp.tv_usec);
- ret = s_a_r(cmd, "STREAM_START", replacement);
- free(replacement);
- if (!ret)
- goto out;
- PARA_INFO_LOG("cmd: %s, repl: %s\n", cmd, ret);
-out:
- return ret;
-}
-#endif
-
/** get the number of filters for the given audio format */
int num_filters(int audio_format_num)
{
}
}
-#if 0
-static int write_audio_data(int slot_num)
-{
- struct slot_info *s = &slot[slot_num];
- struct audio_format_info *a = &afi[s->format];
- struct receiver_node *rn = s->receiver_node;
- int ret;
- char **buf;
- size_t *len;
-
- if (a->num_filters) {
- buf = &s->fc->outbuf;
- len = s->fc->out_loaded;
- } else {
- buf = &rn->buf;
- len = &rn->loaded;
- }
- PARA_DEBUG_LOG("writing %p (%zd bytes)\n", *buf, *len);
- ret = write(s->write_fd, *buf, *len);
- PARA_DEBUG_LOG("wrote %d/%zd\n", ret, *len);
- if (ret < 0) {
- PARA_WARNING_LOG("write error in slot %d (fd %d): %s\n",
- slot_num, s->write_fd, strerror(errno));
- *len = 0;
- close_writer(slot_num);
-// s->fc->error = E_WRITE_AUDIO_DATA;
- } else if (ret != *len) {
- PARA_DEBUG_LOG("partial %s write (%i/%zd) for slot %d\n",
- audio_formats[s->format], ret, *len, slot_num);
- *len -= ret;
- memmove(*buf, *buf + ret, *len);
- } else
- *len = 0;
- if (ret > 0)
- gettimeofday(&s->wtime, NULL);
- return ret;
-}
-#endif
-
-
static void audiod_post_select(struct sched *s, __a_unused struct task *t)
{
int i;
if (rn && rn->loaded)
slot[i].rtime = s->now;
-// if (slot[i].write_fd <= 0 || !slot[i].wcheck
-// || !FD_ISSET(slot[i].write_fd, &s->wfds))
-// continue;
-// ret = write_audio_data(i);
}
}
return ret;
}
-#if 0
-static char *list_filters(void)
-{
- int i, j;
- char *tmp, *msg = make_message("format\tnum\tcmd\n");
-
- FOR_EACH_AUDIO_FORMAT(i) {
- for (j = 0; j < afi[i].num_filters; j++) {
- tmp = make_message("%s\t%i\t%s\n",
- afi[i].name, j, afi[i].filter_cmds[j]);
- msg = para_strcat(msg, tmp);
- free(tmp);
- }
- tmp = make_message("%s\t%i\t%s\n", afi[i].name,
- j, afi[i].write_cmd);
- msg = para_strcat(msg, tmp);
- free(tmp);
- }
- return msg;
-}
-#endif
-
-
static int com_grab(int fd, char *cmdline)
{
struct grab_client *gc;
sprintf(st->task.status, "status task");
}
-
-
-#if 0
-/* TODO: move everything before the select call to pre_select() */
-static void __noreturn audiod_mainloop(void)
-{
- fd_set rfds, wfds;
- int ret, max_fileno, sbo = 0;
- char status_buf[STRINGSIZE] = "";
- struct timeval tv;
-
-
-
-repeat:
- FD_ZERO(&wfds);
- FD_ZERO(&rfds);
- max_fileno = -1;
- /* always check signal pipe and the local socket */
- para_fd_set(signal_pipe, &rfds, &max_fileno);
- para_fd_set(audiod_socket, &rfds, &max_fileno);
-
- if (audiod_status != AUDIOD_ON)
- kill_all_decoders();
- else if (playing)
- start_current_receiver();
-
- set_stream_fds(&wfds, &max_fileno);
- /* status pipe */
- if (stat_pipe >= 0 && audiod_status == AUDIOD_OFF)
- close_stat_pipe();
- if (stat_pipe < 0 && audiod_status != AUDIOD_OFF) {
- stat_pipe = open_stat_pipe();
- sbo = 0;
- status_buf[0] = '\0';
- }
- if (stat_pipe >= 0 && audiod_status != AUDIOD_OFF)
- para_fd_set(stat_pipe, &rfds, &max_fileno);
- /* local socket */
- tv.tv_sec = 0;
- tv.tv_usec = 200 * 1000;
- audiod_pre_select(&rfds, &wfds, &tv, &max_fileno);
- ret = para_select(max_fileno + 1, &rfds, &wfds, &tv);
- if (ret < 0)
- goto repeat;
- if (audiod_status != AUDIOD_OFF)
- audiod_status_dump();
- audiod_post_select(ret, &rfds, &wfds);
- /* read status pipe */
- if (stat_pipe >=0 && FD_ISSET(stat_pipe, &rfds)) {
- ret = read(stat_pipe, status_buf + sbo, STRINGSIZE - 1 - sbo);
- if (ret <= 0) {
- close_stat_pipe();
- /* avoid busy loop if server is down */
- while (sleep(1) > 0)
- ; /* try again*/
- } else {
- status_buf[ret + sbo] = '\0';
- sbo = for_each_line(status_buf, ret + sbo,
- &check_stat_line);
- }
- }
- slot_io(&wfds);
- if (FD_ISSET(audiod_socket, &rfds)) {
- ret = handle_connect();
- if (ret < 0) {
- PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
- }
- }
- /* signals */
- if (FD_ISSET(signal_pipe, &rfds)) {
- int sig_nr = para_next_signal();
- if (sig_nr > 0)
- handle_signal(sig_nr);
- }
- goto repeat;
-}
-#endif
-
static void set_initial_status(void)
{
audiod_status = AUDIOD_ON;
PARA_EMERG_LOG("init stream io error: %s\n", PARA_STRERROR(-i));
exit(EXIT_FAILURE);
}
-// return 0;
server_uptime(UPTIME_SET);
set_initial_status();
FOR_EACH_SLOT(i)