| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008 The gstreamermm Development Team |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <gst/gst.h> |
| 21 |
_PINCLUDE(gstreamermm/private/object_p.h) |
| 22 |
|
| 23 |
namespace |
| 24 |
{ |
| 25 |
|
| 26 |
extern "C" |
| 27 |
{ |
| 28 |
|
| 29 |
static void TaskPool_Push_gstreamermm_callback(void* data) |
| 30 |
{ |
| 31 |
Gst::TaskPool::SlotPush* the_slot = static_cast<Gst::TaskPool::SlotPush*>(data); |
| 32 |
|
| 33 |
try |
| 34 |
{ |
| 35 |
(*the_slot)(); |
| 36 |
delete the_slot; |
| 37 |
} |
| 38 |
catch(...) |
| 39 |
{ |
| 40 |
Glib::exception_handlers_invoke(); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
} // extern "C" |
| 45 |
|
| 46 |
} // anonymous namespace |
| 47 |
|
| 48 |
namespace Gst |
| 49 |
{ |
| 50 |
|
| 51 |
gpointer TaskPool::push(const SlotPush& slot) |
| 52 |
{ |
| 53 |
GError* gerror = 0; |
| 54 |
SlotPush* slot_copy = new SlotPush(slot); |
| 55 |
|
| 56 |
gpointer ret_val = gst_task_pool_push(gobj(), |
| 57 |
&TaskPool_Push_gstreamermm_callback, slot_copy, &gerror); |
| 58 |
|
| 59 |
if(gerror) |
| 60 |
::Glib::Error::throw_exception(gerror); |
| 61 |
|
| 62 |
return ret_val; |
| 63 |
} |
| 64 |
|
| 65 |
void TaskPool_Class::prepare_vfunc_callback(GstTaskPool* self, GError** error) |
| 66 |
{ |
| 67 |
Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>( |
| 68 |
Glib::ObjectBase::_get_current_wrapper((GObject*)self)); |
| 69 |
|
| 70 |
// Non-gtkmmproc-generated custom classes implicitly call the default |
| 71 |
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- |
| 72 |
// generated classes can use this optimisation, which avoids the unnecessary |
| 73 |
// parameter conversions if there is no possibility of the virtual function |
| 74 |
// being overridden: |
| 75 |
if(obj_base && obj_base->is_derived_()) |
| 76 |
{ |
| 77 |
CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base); |
| 78 |
if(obj) // This can be NULL during destruction. |
| 79 |
{ |
| 80 |
try // Trap C++ exceptions which would normally be lost because this is a C callback. |
| 81 |
{ |
| 82 |
// Call the virtual member method, which derived classes might override. |
| 83 |
obj->prepare_vfunc(); |
| 84 |
|
| 85 |
return; |
| 86 |
} |
| 87 |
catch(...) |
| 88 |
{ |
| 89 |
Glib::exception_handlers_invoke(); |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 95 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). |
| 96 |
); |
| 97 |
|
| 98 |
// Call the original underlying C function: |
| 99 |
if(base && base->prepare) |
| 100 |
(*base->prepare)(self, error); |
| 101 |
|
| 102 |
} |
| 103 |
void Gst::TaskPool::prepare_vfunc() |
| 104 |
{ |
| 105 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 106 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). |
| 107 |
); |
| 108 |
|
| 109 |
if(base && base->prepare) |
| 110 |
{ |
| 111 |
GError* gerror = 0; |
| 112 |
(*base->prepare)(gobj(),&gerror); |
| 113 |
|
| 114 |
if(gerror) |
| 115 |
::Glib::Error::throw_exception(gerror); |
| 116 |
} |
| 117 |
} |
| 118 |
gpointer TaskPool_Class::push_vfunc_callback(GstTaskPool* self, GstTaskPoolFunction func, gpointer user_data, GError** error) |
| 119 |
{ |
| 120 |
Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>( |
| 121 |
Glib::ObjectBase::_get_current_wrapper((GObject*)self)); |
| 122 |
|
| 123 |
// Non-gtkmmproc-generated custom classes implicitly call the default |
| 124 |
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- |
| 125 |
// generated classes can use this optimisation, which avoids the unnecessary |
| 126 |
// parameter conversions if there is no possibility of the virtual function |
| 127 |
// being overridden: |
| 128 |
if(obj_base && obj_base->is_derived_()) |
| 129 |
{ |
| 130 |
CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base); |
| 131 |
if(obj) // This can be NULL during destruction. |
| 132 |
{ |
| 133 |
try // Trap C++ exceptions which would normally be lost because this is a C callback. |
| 134 |
{ |
| 135 |
// Call the virtual member method, which derived classes might override. |
| 136 |
Gst::TaskPool::SlotPush* slot = |
| 137 |
static_cast<Gst::TaskPool::SlotPush*>(user_data); |
| 138 |
|
| 139 |
return obj->push_vfunc(*slot); |
| 140 |
|
| 141 |
} |
| 142 |
catch(...) |
| 143 |
{ |
| 144 |
Glib::exception_handlers_invoke(); |
| 145 |
} |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 150 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). |
| 151 |
); |
| 152 |
|
| 153 |
// Call the original underlying C function: |
| 154 |
if(base && base->push) |
| 155 |
return (*base->push)(self, func, user_data, error); |
| 156 |
|
| 157 |
|
| 158 |
typedef gpointer RType; |
| 159 |
return RType(); |
| 160 |
} |
| 161 |
gpointer Gst::TaskPool::push_vfunc(const SlotPush& slot) |
| 162 |
{ |
| 163 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 164 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). |
| 165 |
); |
| 166 |
|
| 167 |
if(base && base->push) |
| 168 |
{ |
| 169 |
GError* gerror = 0; |
| 170 |
gpointer result = (*base->push)(gobj(), |
| 171 |
&TaskPool_Push_gstreamermm_callback, const_cast<SlotPush*>(&slot), |
| 172 |
&gerror); |
| 173 |
|
| 174 |
if(gerror) |
| 175 |
::Glib::Error::throw_exception(gerror); |
| 176 |
|
| 177 |
return result; |
| 178 |
} |
| 179 |
|
| 180 |
typedef gpointer RType; |
| 181 |
return RType(); |
| 182 |
} |
| 183 |
|
| 184 |
} //namespace Gst |