[vlc-devel] [RFC 18/82] qt: use the new player/playlist in qt.h

Pierre Lamot pierre at videolabs.io
Fri Feb 1 14:01:22 CET 2019


---
 modules/gui/qt/qt.cpp | 19 +++++++++++--------
 modules/gui/qt/qt.hpp | 36 ++++++++++++++++++++++++++++++------
 2 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index f71d8d7695..38870c6467 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -420,9 +420,10 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
 
     /* set up the playlist to work on */
     if( isDialogProvider )
-        p_sys->p_playlist = pl_Get( (intf_thread_t *)p_intf->obj.parent );
+        p_sys->p_playlist = vlc_intf_GetMainPlaylist( (intf_thread_t *)p_intf->obj.parent );
     else
-        p_sys->p_playlist = pl_Get( p_intf );
+        p_sys->p_playlist = vlc_intf_GetMainPlaylist( p_intf );
+    p_sys->p_player = vlc_playlist_GetPlayer( p_sys->p_playlist );
 
     /* */
     vlc_sem_init (&ready, 0);
@@ -589,13 +590,15 @@ static void *Thread( void *obj )
             known_type = false;
         }
 
-        var_Create( THEPL, "qt4-iface", VLC_VAR_ADDRESS );
-        var_Create( THEPL, "window", VLC_VAR_STRING );
+        var_Create( p_sys->p_player, "qt4-iface", VLC_VAR_ADDRESS );
+        var_Create( p_sys->p_player, "window", VLC_VAR_STRING );
+
 
         if( known_type )
         {
-            var_SetAddress( THEPL, "qt4-iface", p_intf );
-            var_SetString( THEPL, "window", "qt,any" );
+
+            var_SetAddress( p_sys->p_player, "qt4-iface", p_intf );
+            var_SetString( p_sys->p_player, "window", "qt,any" );
         }
     }
 
@@ -629,8 +632,8 @@ static void *Thread( void *obj )
     msg_Dbg( p_intf, "QApp exec() finished" );
     if (p_mi != NULL)
     {
-        var_Destroy( THEPL, "window" );
-        var_Destroy( THEPL, "qt4-iface" );
+        var_Destroy( p_sys->p_player, "window" );
+        var_Destroy( p_sys->p_player, "qt4-iface" );
 
         QMutexLocker locker (&lock);
         active = false;
diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
index d7645dc244..c32a6ba5c8 100644
--- a/modules/gui/qt/qt.hpp
+++ b/modules/gui/qt/qt.hpp
@@ -30,7 +30,8 @@
 
 #include <vlc_common.h>
 #include <vlc_interface.h> /* intf_thread_t */
-#include <vlc_playlist_legacy.h>  /* playlist_t */
+#include <vlc_playlist.h>  /* vlc_playlist_t */
+#include <vlc_player.h>  /* vlc_player_t */
 
 #include <qconfig.h>
 
@@ -75,7 +76,8 @@ struct intf_sys_t
 
     unsigned voutWindowType; /* Type of vout_window_t provided */
     bool b_isDialogProvider; /* Qt mode or Skins mode */
-    playlist_t *p_playlist;  /* playlist */
+    vlc_playlist_t *p_playlist;  /* playlist */
+    vlc_player_t *p_player; /* player */
 #ifdef _WIN32
     bool disable_volume_keys;
 #endif
@@ -91,19 +93,41 @@ struct intf_sys_t
  */
 
 struct vlc_playlist_locker {
-    vlc_playlist_locker( playlist_t* p_playlist )
+    vlc_playlist_locker( vlc_playlist_t* p_playlist )
         : p_playlist( p_playlist )
     {
-        playlist_Lock( p_playlist );
+        vlc_playlist_Lock( p_playlist );
     }
 
     ~vlc_playlist_locker()
     {
-        playlist_Unlock( p_playlist );
+        vlc_playlist_Unlock( p_playlist );
     }
 
     private:
-        playlist_t* p_playlist;
+        vlc_playlist_t* p_playlist;
+};
+
+/**
+ * This class may be used for scope-bound locking/unlocking
+ * of a player_t*. As hinted, the player is locked when
+ * the object is created, and unlocked when the object is
+ * destroyed.
+ */
+struct vlc_player_locker {
+    vlc_player_locker( vlc_player_t* p_player )
+        : p_player( p_player )
+    {
+        vlc_player_Lock( p_player );
+    }
+
+    ~vlc_player_locker()
+    {
+        vlc_player_Unlock( p_player );
+    }
+
+    private:
+        vlc_player_t* p_player;
 };
 
 #define THEDP DialogsProvider::getInstance()
-- 
2.19.1



More information about the vlc-devel mailing list