[vlc-devel] [PATCH v4 3/5] display: add macro to set the callbacks and check type of the Open/Close
Steve Lhomme
robux4 at ycbcr.xyz
Wed Jul 10 10:39:06 CEST 2019
---
include/vlc_vout_display.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index fd4940cf6d..1cbd6b1891 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -215,6 +215,23 @@ typedef int (*vout_display_open_cb)(vout_display_t *vd,
*/
typedef void (*vout_display_close_cb)(vout_display_t *vd);
+#ifndef __cplusplus
+#define set_callbacks_display(Activate, Deactivate) \
+ static_assert( _Generic( Activate, vout_display_open_cb: 1, default: 0 ) == 1, \
+ "Not a display activate callback"); \
+ static_assert( _Generic( Deactivate, vout_display_close_cb: 1, void*: 1, default: 0 ) == 1, \
+ "Not a display deactivate callback"); \
+ set_callbacks( Activate, Deactivate )
+#else /* __cplusplus */
+#define set_callbacks_display(Activate, Deactivate) \
+ static_assert( std::is_same<std::add_pointer<decltype(Activate)>::type, vout_display_open_cb>::value, \
+ "Not a display activate callback"); \
+ static_assert( std::is_same<std::add_pointer<decltype(Deactivate)>::type, vout_display_close_cb>::value || \
+ std::is_same<decltype(Deactivate),std::nullptr_t>::value, \
+ "Not a display deactivate callback"); \
+ set_callbacks( Activate, Deactivate )
+#endif /* __cplusplus */
+
struct vout_display_t {
struct vlc_object_t obj;
--
2.17.1
More information about the vlc-devel
mailing list