From 3feb2e111c068faaf329bce421f08621e25e09f5 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Sat, 18 Apr 2020 16:08:36 +0200
Subject: [PATCH] Using async mpv commands

---
 src/module/mpv.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/src/module/mpv.c b/src/module/mpv.c
index 74674109..c9e9d2e6 100644
--- a/src/module/mpv.c
+++ b/src/module/mpv.c
@@ -116,25 +116,6 @@ error:
     return NULL;
 }
 
-int
-lmpv_is_paused(mpv_handle *ctx, int *ret)
-{
-    int status;
-
-    if (!ctx) {
-        fprintf(stderr, " ! lmpv_is_paused: failed due to missing mpv ctx\n");
-        return 1;
-    }
-
-    if ((status = mpv_get_property(ctx, "pause", MPV_FORMAT_FLAG, ret)) < 0) {
-        fprintf(stderr, "lmpv_is_paused: Failed to get pause property: %s\n",
-                mpv_error_string(status));
-        return 1;
-    }
-
-    return 0;
-}
-
 int
 lmpv_set_volume(mpv_handle *ctx, int vol)
 {
@@ -149,7 +130,7 @@ lmpv_set_volume(mpv_handle *ctx, int vol)
     snprintf(str, 4, "%d", vol);
     const char *cmd[] = {"set", "ao-volume", str, NULL};
 
-    if ((status = mpv_command(ctx, cmd)) < 0) {
+    if ((status = mpv_command_async(ctx, 0, cmd)) < 0) {
         fprintf(stderr, " ! lmpv_set_volume: Failed to execute command: %s\n",
                 mpv_error_string(status));
         return 1;
@@ -173,7 +154,7 @@ lmpv_load_file(mpv_handle *ctx, const char *file)
     const char *cmd[] = {"loadfile", file, "replace", NULL};
     int status;
 
-    if ((status = mpv_command(ctx, cmd)) < 0) {
+    if ((status = mpv_command_async(ctx, 0, cmd)) < 0) {
         fprintf(stderr, " ! lmpv_load_file: Failed to add '%s': %s\n",
                 file, mpv_error_string(status));
         return 1;
@@ -192,7 +173,7 @@ lmpv_toggle_pause(mpv_handle *ctx)
     const char *cmd[] = {"cycle", "pause", "up", NULL};
     int status;
 
-    if ((status = mpv_command(ctx, cmd)) < 0) {
+    if ((status = mpv_command_async(ctx, 0, cmd)) < 0) {
         fprintf(stderr, "lmpv_toggle_pause: Failed issue command: %s\n",
                 mpv_error_string(status));
         return 1;
-- 
GitLab