]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - audiod.c
Make para_recv use the new scheduler.
[paraslash.git] / audiod.c
index 3d01931173f2d09112f7035c4b1af614a35f094e..1d2d69c17de28ee40bbefebc6ca61e0355cdd2da 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -24,6 +24,7 @@
 #include "audiod.cmdline.h"
 #include "list.h"
 #include "close_on_fork.h"
+#include "sched.h"
 #include "recv.h"
 #include "filter.h"
 #include "grab_client.cmdline.h"
@@ -892,6 +893,7 @@ static void check_timeouts(void)
                                audio_formats[s->format], slot_num);
                        if (s->fci)
                                s->fci->error = 42;
+                       kill_stream_writer(slot_num);
                }
        }
 }
@@ -935,6 +937,7 @@ static void close_decoder_if_idle(int slot_num)
                        return;
        }
        if (s->write_fd > 0) {
+               PARA_INFO_LOG("err: %d\n", s->fci->error);
                PARA_INFO_LOG("slot %d: closing write fd %d\n", slot_num,
                        s->write_fd);
                close(s->write_fd);
@@ -1431,7 +1434,7 @@ static int check_perms(uid_t uid)
 static int handle_connect(void)
 {
        int i, argc, ret, clifd = -1;
-       char *p, *buf = para_malloc(MAXLINE), **argv = NULL;
+       char *cmd = NULL, *p, *buf = para_calloc(MAXLINE), **argv = NULL;
        struct sockaddr_un unix_addr;
 
        ret = para_accept(audiod_socket, &unix_addr, sizeof(struct sockaddr_un));
@@ -1446,7 +1449,8 @@ static int handle_connect(void)
        if (ret < 0)
                goto out;
        ret = -E_INVALID_AUDIOD_CMD;
-       p = strchr(buf, '\n');
+       cmd = para_strdup(buf);
+       p = strchr(cmd, '\n');
        if (!p)
                p = "";
        else {
@@ -1455,7 +1459,7 @@ static int handle_connect(void)
        }
        for (i = 0; cmds[i].name; i++) {
                int j;
-               if (strcmp(cmds[i].name, buf))
+               if (strcmp(cmds[i].name, cmd))
                        continue;
                if (cmds[i].handler) {
                        argc = split_args(buf, &argv, "\n");
@@ -1466,12 +1470,13 @@ static int handle_connect(void)
                for (j = 0; p[j]; j++)
                        if (p[j] == '\n')
                                p[j] = ' ';
-               PARA_INFO_LOG("cmd: %s, options: %s\n", buf, p);
+               PARA_INFO_LOG("cmd: %s, options: %s\n", cmd, p);
                ret = cmds[i].line_handler(clifd, p);
                goto out;
        }
        ret = -E_INVALID_AUDIOD_CMD; /* cmd not found */
 out:
+       free(cmd);
        free(buf);
        free(argv);
        if (clifd > 0 && ret < 0 && ret != -E_CLIENT_WRITE) {