X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mixer.c;fp=mixer.c;h=48095d03ff7f0c0b9326223fd86222e2c48fe647;hb=149460f7ea29ce43cb3fe5795cf7395c57e13cba;hp=013f35fe3e37c60db0404bfe0e80eeee95cfc5a0;hpb=be5daec66f163725489f42d512659a8af5c3fd59;p=paraslash.git diff --git a/mixer.c b/mixer.c index 013f35fe..48095d03 100644 --- a/mixer.c +++ b/mixer.c @@ -187,11 +187,11 @@ static int com_fade(const struct mixer *m) } EXPORT_CMD(fade); -static void client_cmd(const char *cmd) +static void run(const char *exe, const char *cmd) { int ret, status, fds[3] = {0, 0, 0}; pid_t pid; - char *cmdline = make_message(BINDIR "/para_client %s", cmd); + char *cmdline = make_message("%s %s", exe, cmd); PARA_NOTICE_LOG("%s\n", cmdline); ret = para_exec_cmdline_pid(&pid, cmdline, fds); @@ -215,6 +215,16 @@ fail: exit(EXIT_FAILURE); } +static void client_cmd(const char *cmd) +{ + run(BINDIR "/para_client", cmd); +} + +static void audioc_cmd(const char *cmd) +{ + run(BINDIR "/para_audioc", cmd); +} + static void change_afs_mode(const char *afs_mode) { char *cmd; @@ -263,6 +273,13 @@ static int set_initial_volume(const struct mixer *m, struct mixer_handle *h) return 1; } +static void stop(void) +{ + audioc_cmd("off"); + client_cmd("stop"); + audioc_cmd("on"); +} + static int com_sleep(const struct mixer *m) { time_t t1, wake_time_epoch; @@ -317,8 +334,7 @@ static int com_sleep(const struct mixer *m) } wake_time_epoch = mktime(tm); PARA_INFO_LOG("waketime: %d:%02d\n", tm->tm_hour, tm->tm_min); - client_cmd("stop"); - sleep(1); + stop(); ret = set_initial_volume(m, h); if (ret < 0) goto close_mixer; @@ -334,7 +350,7 @@ static int com_sleep(const struct mixer *m) change_afs_mode(initial_mood); client_cmd("play"); sleep(delay); - client_cmd("stop"); + stop(); } if (fot && fo_mood && *fo_mood) { change_afs_mode(fo_mood); @@ -352,7 +368,7 @@ static int com_sleep(const struct mixer *m) if (!fot || !fo_mood) /* currently stopped */ client_cmd("play"); } else if (fot && fo_mood && *fo_mood) /* currently playing */ - client_cmd("stop"); + stop(); m->close(&h); if (!fit || !fi_mood || !*fi_mood) /* nothing to do */ return 1; @@ -367,13 +383,12 @@ static int com_sleep(const struct mixer *m) sleep(delay); } change_afs_mode(fi_mood); - if (sleep_mood && *sleep_mood) /* currently playing */ - client_cmd("next"); - else /* currently stopped */ - client_cmd("play"); ret = open_mixer_and_set_channel(m, &h); if (ret < 0) return ret; + if (sleep_mood && *sleep_mood) /* currently playing */ + stop(); + client_cmd("play"); ret = fade(m, h, fiv, fit); close_mixer: m->close(&h);