[vlc-commits] cli: implement is_playing statelessly

Rémi Denis-Courmont git at videolan.org
Sat Oct 17 20:35:44 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 17 12:31:17 2020 +0300| [9dc6715cbe1025590b3f21e04c47df363edb6161] | committer: Rémi Denis-Courmont

cli: implement is_playing statelessly

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9dc6715cbe1025590b3f21e04c47df363edb6161
---

 modules/control/cli/cli.h    |  1 -
 modules/control/cli/player.c | 10 +++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index f6b3ea6db2..feec2e936a 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -34,7 +34,6 @@ struct intf_sys_t
 
     /* status changes */
     vlc_mutex_t             status_lock;
-    enum vlc_player_state   last_state;
     bool                    b_input_buffering;
 
 #ifndef _WIN32
diff --git a/modules/control/cli/player.c b/modules/control/cli/player.c
index 4e147eb7fe..3f9fbe2e9e 100644
--- a/modules/control/cli/player.c
+++ b/modules/control/cli/player.c
@@ -715,10 +715,14 @@ void Statistics(intf_thread_t *intf)
 void IsPlaying(intf_thread_t *intf)
 {
     intf_sys_t *sys = intf->p_sys;
+    vlc_player_t *player = vlc_playlist_GetPlayer(sys->playlist);
+    enum vlc_player_state state;
 
-    msg_print(intf, "%d",
-              sys->last_state == VLC_PLAYER_STATE_PLAYING ||
-              sys->last_state == VLC_PLAYER_STATE_PAUSED);
+    vlc_player_Lock(player);
+    state = vlc_player_GetState(player);
+    msg_print(intf, "%d", state == VLC_PLAYER_STATE_PLAYING
+                       || state == VLC_PLAYER_STATE_PAUSED);
+    vlc_player_Unlock(player);
 }
 
 void *RegisterPlayer(intf_thread_t *intf)



More information about the vlc-commits mailing list