c# AddSignalHandler

James Linder jam at tigger.ws
Thu Feb 23 09:36:02 UTC 2023



> On 23 Feb 2023, at 4:09 pm, Armin Erkert via gstreamer-devel <gstreamer-devel at lists.freedesktop.org> wrote:
> 
> 
> Hi,
> 
> when I try to add a SignalHandler
> 
> 
> public delegate void MyDelegateNewFormat(object sender, GLib.SignalArg args);
> 
> ....
> 
> splitElement.AddSignalHandler("format-location", new MyDelegateNewFormat(NewFormat));
> 
> .....
> 
> static void NewFormat(object sender, GLib.SignalArgs args)
> {
> }
> 
> 
> I get this Error:
> 
> System.ArgumentException: Object of type 'System.EventArgs' cannot be converted to type 'GLib.SignalArgs'.
>   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
>   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
>   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
>   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
>   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
>   at System.Delegate.DynamicInvokeImpl(Object[] args)
>   at System.Delegate.DynamicInvoke(Object[] args)
>   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
>   at GLib.SignalClosure.Invoke(ClosureInvokedArgs args)
>   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
> PushData
>   at GLib.ExceptionManager.RaiseUnhandledException(Exception e, Boolean is_terminal)
>   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
> 
> 
> Can anyone help ne ?


I used straight forward signals

/*----------------------------------------------------------------------------------------
 * quit -- on int EOS and exit
 *---------------------------------------------------------------------------------------*/
void byebye (int signum)
{
    g_print ("[handler function]\npost EOS\n");

    //post EOS message to pipe line
    gst_element_send_event (data.pipeline, gst_event_new_eos ());

    //block until EOS is detected
    g_print ("waiting for message answer\n");
    gst_bus_timed_pop_filtered (gst_element_get_bus(data.pipeline), GST_CLOCK_TIME_NONE, GST_MESSAGE_EOS);
    g_print ("exit\n");
    fflush (stdout);
    exit (0);
} 

and

…
    signal (SIGUSR2, byebye);
…
James


More information about the gstreamer-devel mailing list