X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=audiod.c;h=9e001c67ee73562f453a69f13e5a644d04e55169;hp=107fb35e641c157bc07667bf0549681799702ea8;hb=adbf9f09c9bf2a680c61b1ef3541c04f1cde97cf;hpb=58ad3169dc1a4999ef3250753f980f168bd2f29e diff --git a/audiod.c b/audiod.c index 107fb35e..9e001c67 100644 --- a/audiod.c +++ b/audiod.c @@ -137,17 +137,7 @@ static void *stat_item_ringbuf; static FILE *logfile; static const struct timeval restart_delay = {0, 300 * 1000}; -static struct audio_format_info afi[] = { - -[AUDIO_FORMAT_MP3] = - { - .write_cmd = "para_play", - }, -[AUDIO_FORMAT_OGG] = - { - .write_cmd = "para_play", - }, -}; +static struct audio_format_info afi[NUM_AUDIO_FORMATS]; static struct audiod_command cmds[] = { { @@ -269,7 +259,7 @@ int get_audio_format_num(char *name) /* * log function. first argument is loglevel. */ -void para_log(int ll, char* fmt,...) +void para_log(int ll, const char* fmt,...) { va_list argp; FILE *outfd; @@ -590,7 +580,7 @@ static void __noreturn clean_exit(int status, const char *msg) exit(status); } -static char *glob_cmd(char *cmd) +__malloc static char *glob_cmd(char *cmd) { char *ret, *replacement; struct timeval tmp, delay, rss; /* real stream start */ @@ -688,12 +678,15 @@ static void start_stream_writer(int slot_num) int ret, fds[3] = {1, -1, -1}; struct slot_info *s = &slot[slot_num]; struct audio_format_info *a = &afi[s->format]; - char *glob = glob_cmd(a->write_cmd); + char *glob = NULL; - PARA_INFO_LOG("starting stream writer: %s\n", glob? glob : a->write_cmd); + if (a->write_cmd) + glob = glob_cmd(a->write_cmd); + if (!glob) + glob = para_strdup("para_play"); + PARA_INFO_LOG("starting stream writer: %s\n", glob); open_filters(slot_num); - - ret = para_exec_cmdline_pid(&s->wpid, glob? glob : a->write_cmd, fds); + ret = para_exec_cmdline_pid(&s->wpid, glob, fds); free(glob); if (ret < 0) { PARA_ERROR_LOG("exec failed (%d)\n", ret); @@ -1084,7 +1077,7 @@ static int setup_default_filters(void) if (ret < 0) goto out; PARA_INFO_LOG("%s -> default filter: %s\n", audio_formats[i], filters[j].name); - ret = add_filter(i, "wav"); + ret = add_filter(i, para_strdup("wav")); if (ret < 0) goto out; PARA_INFO_LOG("%s -> default filter: wav\n", audio_formats[i]); @@ -1427,9 +1420,8 @@ static void audiod_get_socket(void) static int open_stat_pipe(void) { int ret, fd[3] = {-1, 1, 0}; - char *argv[] = {BINDIR "/para_client", "stat", NULL}; pid_t pid; - ret = para_exec(&pid, BINDIR "/para_client", argv, fd); + ret = para_exec_cmdline_pid(&pid, BINDIR "/para_client stat", fd); if (ret >= 0) { ret = fd[1]; PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);