summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pjctl.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/pjctl.c b/src/pjctl.c
index 0c5c7b1..3efe693 100644
--- a/src/pjctl.c
+++ b/src/pjctl.c
@@ -441,11 +441,15 @@ source(struct pjctl *pjctl, char **argv, int argc)
return 0;
}
+static int
+avmute(struct pjctl *pjctl, char **argv, int argc);
+
static void
avmute_response(struct pjctl *pjctl, struct queue_command *cmd,
char *op, char *param)
{
int ret;
+ char *params[3] = { "mute", NULL, NULL };
fputs(cmd->prefix, stdout);
free(cmd->prefix);
@@ -459,18 +463,28 @@ avmute_response(struct pjctl *pjctl, struct queue_command *cmd,
return;
switch (param[0]) {
case '1':
+ params[1] = "video";
printf("video");
break;
case '2':
+ params[1] = "audio";
printf("audio");
break;
case '3':
+ params[1] = "av";
printf("video & audio");
break;
+ default:
+ // error?
+ break;
}
printf(" mute ");
- printf("%s\n", param[1] == '1' ? "on" : "off");
+ params[2] = param[1] == '1' ? "on" : "off";
+ printf("%s\n", params[2]);
+
+ if (cmd->toggle)
+ avmute(pjctl, params, 3);
}
}
@@ -480,7 +494,7 @@ avmute(struct pjctl *pjctl, char **argv, int argc)
struct queue_command *cmd;
int type = -1;
int i;
- int on;
+ char code;
const char *targets[] = { "video", "audio", "av" };
cmd = calloc(1, sizeof *cmd);
@@ -506,19 +520,22 @@ avmute(struct pjctl *pjctl, char **argv, int argc)
}
if (strcmp(argv[2], "on") == 0)
- on = 1;
+ code = '1';
else if (strcmp(argv[2], "off") == 0)
- on = 0;
- else {
+ code = '0';
+ else if (strcmp(argv[2], "toggle") == 0) {
+ code = '?';
+ cmd->toggle = 1;
+ } else {
fprintf(stderr, "invalid mute parameter\n");
return -1;
}
- if (asprintf(&cmd->command, "%%1AVMT %d%d\r", type, on) < 0)
+ if (asprintf(&cmd->command, "%%1AVMT %d%c\r", type, code) < 0)
return -1;
cmd->response_func = avmute_response;
if (asprintf(&cmd->prefix, "%s mute %s: ",
- targets[type-1], argv[2]) < 0)
+ targets[type-1], cmd->toggle ? "status" : argv[2]) < 0)
return -1;
insert_at_head(&pjctl->queue, cmd);