about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-12-03 14:04:36 +0100
committerptitSeb <sebastien.chev@gmail.com>2022-12-03 14:04:36 +0100
commit0973e7009e05d99a2dc284b68a124b093efe2367 (patch)
tree9bf22748827151e732c622ae803113122a9f7a4c
parentd0d18441cfdedac53b0ed8a772a88a1c26be7984 (diff)
downloadbox64-0973e7009e05d99a2dc284b68a124b093efe2367.tar.gz
box64-0973e7009e05d99a2dc284b68a124b093efe2367.zip
Wrapped GstAllocator and GstObject structures
-rwxr-xr-xsrc/include/gtkclass.h16
-rwxr-xr-xsrc/tools/gtkclass.c70
-rw-r--r--src/wrapped/wrappedgstreamer.c13
3 files changed, 96 insertions, 3 deletions
diff --git a/src/include/gtkclass.h b/src/include/gtkclass.h
index 376f2173..6e8d302f 100755
--- a/src/include/gtkclass.h
+++ b/src/include/gtkclass.h
@@ -585,6 +585,20 @@ typedef struct my_AtkUtilClass_s
    void*    (* get_toolkit_version)          (void);
 } my_AtkUtilClass_t;
 
+typedef struct my_GstObjectClass_s {
+  my_GInitiallyUnownedClass_t parent;
+  const char*   path_string_separator;
+  void          (*deep_notify)      (void* object, void* orig, void* pspec);
+  void*        _gst_reserved[4];
+} my_GstObjectClass_t;
+
+typedef struct my_GstAllocatorClass_s {
+  my_GstObjectClass_t parent;
+  void*     (*alloc)      (void *allocator, size_t size, void *params);
+  void      (*free)       (void *allocator, void *memory);
+  void*    _gst_reserved[4];
+} my_GstAllocatorClass_t;
+
 
 // GTypeValueTable
 typedef struct my_GTypeValueTable_s {
@@ -673,6 +687,8 @@ GTKCLASS(MetaFrames2)               \
 GTKCLASS(GDBusObjectManagerClient)  \
 GTKCLASS(AtkObject)                 \
 GTKCLASS(AtkUtil)                   \
+GTKCLASS(GstObject)                 \
+GTKCLASS(GstAllocator)              \
 
 #define GTKCLASS(A) void Set##A##ID(size_t id);
 GTKCLASSES()
diff --git a/src/tools/gtkclass.c b/src/tools/gtkclass.c
index e57e54a9..34ee00e6 100755
--- a/src/tools/gtkclass.c
+++ b/src/tools/gtkclass.c
@@ -1716,6 +1716,76 @@ static void bridgeAtkUtilClass(my_AtkUtilClass_t* class)
 
 #undef SUPERGO
 
+// ----- GstObjectClass ------
+// wrapper x86 -> natives of callbacks
+WRAPPER(GstObject, deep_notify, void, (void* object, void* origin, void* pspec), 3, object, origin, pspec);
+
+#define SUPERGO() \
+    GO(deep_notify, vFppp); \
+
+// wrap (so bridge all calls, just in case)
+static void wrapGstObjectClass(my_GstObjectClass_t* class)
+{
+    wrapGInitiallyUnownedClass(&class->parent);
+    #define GO(A, W) class->A = reverse_##A##_GstObject (W, class->A)
+    SUPERGO()
+    #undef GO
+}
+// unwrap (and use callback if not a native call anymore)
+static void unwrapGstObjectClass(my_GstObjectClass_t* class)
+{   
+    unwrapGInitiallyUnownedClass(&class->parent);
+    #define GO(A, W)   class->A = find_##A##_GstObject (class->A)
+    SUPERGO()
+    #undef GO
+}
+// autobridge
+static void bridgeGstObjectClass(my_GstObjectClass_t* class)
+{
+    bridgeGInitiallyUnownedClass(&class->parent);
+    #define GO(A, W) autobridge_##A##_GstObject (W, class->A)
+    SUPERGO()
+    #undef GO
+}
+
+#undef SUPERGO
+
+// ----- GstAllocatorClass ------
+// wrapper x86 -> natives of callbacks
+WRAPPER(GstAllocator, alloc, void*, (void *allocator, size_t size, void *params), 3, allocator, size, params);
+WRAPPER(GstAllocator,free, void,    (void *allocator, void *memory), 2, allocator, memory);
+
+#define SUPERGO() \
+    GO(alloc, pFpLp);       \
+    GO(free, vFpp);         \
+
+// wrap (so bridge all calls, just in case)
+static void wrapGstAllocatorClass(my_GstAllocatorClass_t* class)
+{
+    wrapGstObjectClass(&class->parent);
+    #define GO(A, W) class->A = reverse_##A##_GstAllocator (W, class->A)
+    SUPERGO()
+    #undef GO
+}
+// unwrap (and use callback if not a native call anymore)
+static void unwrapGstAllocatorClass(my_GstAllocatorClass_t* class)
+{   
+    unwrapGstObjectClass(&class->parent);
+    #define GO(A, W)   class->A = find_##A##_GstAllocator (class->A)
+    SUPERGO()
+    #undef GO
+}
+// autobridge
+static void bridgeGstAllocatorClass(my_GstAllocatorClass_t* class)
+{
+    bridgeGstObjectClass(&class->parent);
+    #define GO(A, W) autobridge_##A##_GstAllocator (W, class->A)
+    SUPERGO()
+    #undef GO
+}
+
+#undef SUPERGO
+
 // No more wrap/unwrap
 #undef WRAPPER
 #undef FIND
diff --git a/src/wrapped/wrappedgstreamer.c b/src/wrapped/wrappedgstreamer.c
index 18a58700..35f5610a 100644
--- a/src/wrapped/wrappedgstreamer.c
+++ b/src/wrapped/wrappedgstreamer.c
@@ -17,14 +17,18 @@
 #include "box64context.h"
 #include "emu/x64emu_private.h"
 #include "myalign.h"
+#include "gtkclass.h"
 
 const char* gstreamerName = "libgstreamer-1.0.so.0";
 #define LIBNAME gstreamer
 
-typedef void* (*pFppA_t)(void*, void*, va_list);
-typedef void* (*pFp_t)(void*);
+typedef void*   (*pFppA_t)(void*, void*, va_list);
+typedef size_t  (*LFv_t)();
+typedef void*   (*pFp_t)(void*);
 
 #define ADDED_FUNCTIONS()                   \
+    GO(gst_object_get_type, LFv_t)          \
+    GO(gst_allocator_get_type, LFv_t)       \
     GO(gst_structure_new_valist, pFppA_t)   \
     GO(gst_structure_new_empty, pFp_t)
 
@@ -310,7 +314,10 @@ EXPORT void* my_gst_structure_new(x64emu_t* emu, void* name, void* first, uint64
         return -1;
 
 #define CUSTOM_INIT \
-    getMy(lib);
+    getMy(lib);     \
+    SetGstObjectID(my->gst_object_get_type());                 \
+    SetGstAllocatorID(my->gst_allocator_get_type());           \
+    setNeededLibs(lib, 1, "libgtk-3.so.0");
 
 #define CUSTOM_FINI \
     freeMy();