From 47fbbd7cd4176200056db1c509dd328c9954484e Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Fri, 8 May 2020 13:53:04 +0200
Subject: [PATCH] Set times to 0 when playback stops

---
 src/module/module_sdl2.c | 1 +
 src/module/module_x11.c  | 2 +-
 src/module/mpv.c         | 2 ++
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c
index bce1e3b6..8421533b 100644
--- a/src/module/module_sdl2.c
+++ b/src/module/module_sdl2.c
@@ -277,6 +277,7 @@ module_sdl2_close(struct lkt_win *const win)
 {
     RETURN_UNLESS(win && win->window, "Invalid arguments", NOTHING);
     struct module_sdl2_window *sdl2 = win->window;
+    sdl2->mpv_time_pos = (sdl2->mpv_duration = 0);
     RETURN_UNLESS(sdl2->mpv, "Missing mpv ctx", NOTHING);
     static const char *cmd[] = { "stop", NULL };
     mpv_command_async((mpv_handle *) sdl2->mpv, 0, cmd);
diff --git a/src/module/module_x11.c b/src/module/module_x11.c
index 5852a9c4..521acfda 100644
--- a/src/module/module_x11.c
+++ b/src/module/module_x11.c
@@ -200,7 +200,7 @@ module_x11_close(struct lkt_win *const win)
     struct module_x11_window *const x11_win = win->window;
     lmpv_free(&x11_win->mpv);
     x11_win->child_display = NULL;
-    x11_win->child_win = 0;
+    x11_win->child_win = (x11_win->mpv_time_pos = (x11_win->mpv_duration = 0));
 }
 
 void
diff --git a/src/module/mpv.c b/src/module/mpv.c
index 492ac110..8d7f4354 100644
--- a/src/module/mpv.c
+++ b/src/module/mpv.c
@@ -151,6 +151,8 @@ loop:
         break;
 
     case MPV_EVENT_SHUTDOWN:
+        *time_pos = 0;
+        *time_duration = 0;
         database_queue_stop(db);
         win->close(win);
         return 1;
-- 
GitLab