diff options
| -rw-r--r-- | Makefile.real | 3 | ||||
| -rw-r--r-- | m4/lls/mixer.suite.m4 | 1 | ||||
| -rw-r--r-- | mixer.c | 48 |
3 files changed, 33 insertions, 19 deletions
diff --git a/Makefile.real b/Makefile.real index d5196ff5..afa789c2 100644 --- a/Makefile.real +++ b/Makefile.real @@ -147,7 +147,8 @@ ifneq ($(CRYPTOLIB),) endif ifneq ($(HAVE_OSS)-$(HAVE_ALSA),no-no) executables += mixer - mixer_objs := $(addsuffix .o, mixer exec string fd time lsu version) + mixer_objs := $(addsuffix .o, mixer exec string fd time lsu version \ + audioc_common net) ifeq ($(HAVE_OSS),yes) mixer_objs += oss_mix.o endif diff --git a/m4/lls/mixer.suite.m4 b/m4/lls/mixer.suite.m4 index b51fab4c..1e01d873 100644 --- a/m4/lls/mixer.suite.m4 +++ b/m4/lls/mixer.suite.m4 @@ -18,6 +18,7 @@ caption = List of subcommands m4_include(version.m4) m4_include(config-file.m4) m4_include(loglevel.m4) + m4_include(socket.m4) m4_include(per-command-options-section.m4) [help] These options apply to several subcommands. @@ -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); |
