vlc | branch: master | Filip Roséen <[email protected]> | Wed Jul 20 04:36:52
2016 +0200| [e7986497fe532eeb17194a3e69eec53c2055b8b8] | committer:
Jean-Baptiste Kempf
gui/qt: add struct vlc_playlist_locker
Given that we currently do not have such entity in
include/vlc_playlist.h, this patch introduces such inside the
gui/Qt-module.
The perks of using this helper are:
1. it makes locking/unlocking the playlist thread-safe
2. it makes it "impossible" to forget to unlock the playlist
3. it often makes it easier to reason about the code
Signed-off-by: Jean-Baptiste Kempf <[email protected]>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7986497fe532eeb17194a3e69eec53c2055b8b8
---
modules/gui/qt/qt.hpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
index 0b83f1f..7276bdc 100644
--- a/modules/gui/qt/qt.hpp
+++ b/modules/gui/qt/qt.hpp
@@ -98,6 +98,29 @@ struct intf_sys_t
#define THEPL p_intf->p_sys->p_playlist
+/**
+ * This class may be used for scope-bound locking/unlocking
+ * of a playlist_t*. As hinted, the playlist is locked when
+ * the object is created, and unlocked when the object is
+ * destroyed.
+ */
+
+struct vlc_playlist_locker {
+ vlc_playlist_locker( playlist_t* p_playlist )
+ : p_playlist( p_playlist )
+ {
+ playlist_Lock( p_playlist );
+ }
+
+ ~vlc_playlist_locker()
+ {
+ playlist_Unlock( p_playlist );
+ }
+
+ private:
+ playlist_t* p_playlist;
+};
+
#define THEDP DialogsProvider::getInstance()
#define THEMIM MainInputManager::getInstance( p_intf )
#define THEAM ActionsManager::getInstance( p_intf )
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits