summaryrefslogtreecommitdiff
path: root/mixer.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixer.c')
-rw-r--r--mixer.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/mixer.c b/mixer.c
index 7c11c640..52b6f749 100644
--- a/mixer.c
+++ b/mixer.c
@@ -24,6 +24,7 @@
#include "mixer.lsg.h"
#include "para.h"
+#include "audioc.h"
#include "lsu.h"
#include "fd.h"
#include "string.h"
@@ -202,11 +203,11 @@ static int com_fade(const struct mixer *m)
}
EXPORT_CMD(fade);
-static void run(const char *exe, const char *cmd)
+static void run_server_cmd(const char *cmd)
{
int ret, status, fds[3] = {0, 0, 0};
pid_t pid;
- char *cmdline = make_message("%s %s", exe, cmd);
+ char *cmdline = make_message("para_client %s", cmd);
PARA_INFO_LOG("%s\n", cmdline);
ret = xexec(&pid, cmdline, fds);
@@ -268,14 +269,25 @@ free_buf:
return item? item : para_strdup(NULL);
}
-static void client_cmd(const char *cmd)
+static void run_audiod_cmd(const char *cmd)
{
- run("para_client", cmd);
-}
+ char **argv;
+ int argc, ret;
-static void audioc_cmd(const char *cmd)
-{
- run("para_audioc", cmd);
+ ret = create_argv(cmd, " ", &argv);
+ if (ret < 0) {
+ PARA_EMERG_LOG("create_argv %s: %s\n", cmd,
+ para_strerror(-ret));
+ exit(EXIT_FAILURE);
+ }
+ argc = ret;
+ ret = connect_audiod(OPT_STRING_VAL(PARA_MIXER, SOCKET), argc, argv);
+ free_argv(argv);
+ if (ret < 0) {
+ PARA_EMERG_LOG("connect_audiod %s: %s\n", cmd,
+ para_strerror(-ret));
+ exit(EXIT_FAILURE);
+ }
}
static int set_initial_volume(const struct mixer *m, struct mixer_handle *h)
@@ -340,18 +352,18 @@ static int change_mop(const char *mop, const struct mixer *m,
ret = fade(m, h, 0, 3, false);
if (ret < 0)
goto free_status;
- audioc_cmd("off");
- client_cmd("stop");
+ run_audiod_cmd("off");
+ run_server_cmd("stop");
playing = false;
- audioc_cmd("on");
+ run_audiod_cmd("on");
ret = m->set(h, old_vol);
if (ret < 0)
goto free_status;
} else if (!strcmp(status, "paused"))
- client_cmd("next");
+ run_server_cmd("next");
PARA_NOTICE_LOG("switching to %s\n", mop);
cmd = make_message("select %s", mop);
- client_cmd(cmd);
+ run_server_cmd(cmd);
free(cmd);
}
if (!initial_volume_set) {
@@ -361,7 +373,7 @@ static int change_mop(const char *mop, const struct mixer *m,
goto free_status;
}
if (!playing)
- client_cmd("play");
+ run_server_cmd("play");
ret = 1;
free_status:
free(status);
@@ -425,7 +437,7 @@ static int com_sleep(const struct mixer *m)
ret = change_mop(initial_mood, m, h);
if (ret < 0)
goto close_mixer;
- audioc_cmd("on");
+ run_audiod_cmd("on");
if (ret > 0) /* playing initial mood */
sleep(OPT_UINT32_VAL(SLEEP, INITIAL_DELAY));
ret = change_mop(fo_mood, m, h);
@@ -438,7 +450,7 @@ static int com_sleep(const struct mixer *m)
if (ret < 0)
goto close_mixer;
if (ret == 0) /* no sleep mood */
- client_cmd("stop");
+ run_server_cmd("stop");
time(&t1);
if (wake_time_epoch > t1 + fit)
sleep(wake_time_epoch - t1 - fit);
@@ -467,10 +479,10 @@ static int com_snooze(const struct mixer *m)
ret = fade(m, h, sovol, sotime, true);
if (ret < 0)
goto close_mixer;
- client_cmd("pause");
+ run_server_cmd("pause");
PARA_NOTICE_LOG("%" PRIu32 " seconds snooze time...\n", stime);
sleep(stime);
- client_cmd("play");
+ run_server_cmd("play");
ret = fade(m, h, sivol, sitime, true);
close_mixer:
m->close(h);