[vlc-devel] [RFC PATCH 18/18] include/playlist: add helper to lock a playlist
Thomas Guillem
thomas at gllm.fr
Wed Jul 20 09:30:06 CEST 2016
On Wed, Jul 20, 2016, at 04:37, Filip Roséen wrote:
> Instead of having the declaration only accessible inside the relevant
> parts of gui/qt, make it so that other modules written in C++ could take
> advantage of its functionality.
>
> Given that we already have vlc_mutex_locker in include/vlc_threads.h, it
> feels somewhat relevant to also have a vlc_playlist_locker that works in
> the same way.
>
> --
>
> My main reason for not putting it here directly is that I do not know
> if modules written in c++ that requires this sort of helper are common
> enough to rationalize its addition.
>
> - What do you guys think?
Could be used for the next interface written in C++, but I don't know
any for the moment.
I think we should apply this patch only if we need it.
> ---
> include/vlc_playlist.h | 25 +++++++++++++++++++++++++
> modules/gui/qt/qt.hpp | 23 -----------------------
> 2 files changed, 25 insertions(+), 23 deletions(-)
>
> diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
> index 4363405..aed4c89 100644
> --- a/include/vlc_playlist.h
> +++ b/include/vlc_playlist.h
> @@ -421,6 +421,31 @@ static inline int playlist_CurrentSize( playlist_t
> *p_playlist )
>
> /** @} */
> # ifdef __cplusplus
> +
> +/**
> + * 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;
> +};
> +
> +
> }
> # endif
>
> diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
> index 7276bdc..0b83f1f 100644
> --- a/modules/gui/qt/qt.hpp
> +++ b/modules/gui/qt/qt.hpp
> @@ -98,29 +98,6 @@ 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 )
> --
> 2.9.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list