use const qualifiers where possible
[paraslash.git] / audiod.c
index 107fb35..9e001c6 100644 (file)
--- 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);