summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Noll <maan@tuebingen.mpg.de>2026-09-18 23:14:12 +0200
committerAndre Noll <maan@tuebingen.mpg.de>2026-09-18 23:14:12 +0200
commit7d7576c87246d696ce75f74e5120d80be78a070f (patch)
treea242dd3f3e2b03db6a076d6eba03ec043bf2d3dc
parent2c40e901e4d8f98d91711f846e899a6d4e05bd9d (diff)
parent976154771d159645b573958137013da2319e130d (diff)
Merge topic branch t/mixer into pupu
Improvements to para_mixer. --------------------------- Link para_mixer with audioc_common.o to avoid one fork+exec per audiod subcommand. * t/mixer: mixer: Link with audioc_common.o mixer: Rename client_cmd() -> run_server_cmd(). mixer: Rename audioc_cmd() -> run_audiod_cmd().
-rw-r--r--Makefile.real3
-rw-r--r--m4/lls/mixer.suite.m41
-rw-r--r--mixer.c48
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.
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);