summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-15 14:44:25 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:13 +0900
commitead565afb31db72c97ba5b2cd17bec2bfa115eb7 (patch)
treebe08ce78a23d69031c523da260f838ea03d265be /input
parent9f80936ddc05b27945637b7944b8b6c894ff87ac (diff)
downloadmpv-ead565afb31db72c97ba5b2cd17bec2bfa115eb7.tar.bz2
mpv-ead565afb31db72c97ba5b2cd17bec2bfa115eb7.tar.xz
client API: be more lenient about mpv_suspend/resume mismatches
Before this commit, this was defined to trigger undefined behavior. This was nice because it required less code; but on the other hand, Lua as well as IPC support had to check these things manually. Do it directly in the API to avoid code duplication, and to make the API more robust. (The total code size still grows, though...) Since all of the failure cases were originally meant to ruin things forever, there is no way to return error codes. So just print the errors.
Diffstat (limited to 'input')
-rw-r--r--input/ipc.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/input/ipc.c b/input/ipc.c
index 876f40c8a7..7d15ac84d0 100644
--- a/input/ipc.c
+++ b/input/ipc.c
@@ -61,8 +61,6 @@ struct client_arg {
bool close_client_fd;
bool writable;
-
- int suspend_counter;
};
static mpv_node *mpv_node_map_get(mpv_node *src, const char *key)
@@ -420,21 +418,11 @@ static char *json_execute_command(struct client_arg *arg, void *ta_parent,
rc = mpv_request_log_messages(arg->client,
cmd_node->u.list->values[1].u.string);
} else if (!strcmp("suspend", cmd)) {
- if (arg->suspend_counter < INT_MAX) {
- mpv_suspend(arg->client);
- arg->suspend_counter++;
- rc = MPV_ERROR_SUCCESS;
- } else {
- rc = MPV_ERROR_INVALID_PARAMETER;
- }
+ mpv_suspend(arg->client);
+ rc = MPV_ERROR_SUCCESS;
} else if (!strcmp("resume", cmd)) {
- if (arg->suspend_counter > 0) {
- mpv_resume(arg->client);
- arg->suspend_counter--;
- rc = MPV_ERROR_SUCCESS;
- } else {
- rc = MPV_ERROR_INVALID_PARAMETER;
- }
+ mpv_resume(arg->client);
+ rc = MPV_ERROR_SUCCESS;
} else {
mpv_node result_node;