diff --git a/examples/src/bin/subclass.rs b/examples/src/bin/subclass.rs index 9a4567362..0841f8986 100644 --- a/examples/src/bin/subclass.rs +++ b/examples/src/bin/subclass.rs @@ -58,7 +58,6 @@ mod fir_filter { const NAME: &'static str = "RsFirFilter"; type Type = super::FirFilter; type ParentType = gst_base::BaseTransform; - type Instance = gst::subclass::ElementInstanceStruct; } // Implementation of glib::Object virtual methods diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index eff738992..3e0ec0d92 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -530,10 +530,7 @@ impl AudioDecoderImplExt for T { } } -unsafe impl IsSubclassable for AudioDecoder -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for AudioDecoder { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -563,15 +560,12 @@ where unsafe extern "C" fn audio_decoder_open( ptr: *mut ffi::GstAudioDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.open(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -585,15 +579,12 @@ where unsafe extern "C" fn audio_decoder_close( ptr: *mut ffi::GstAudioDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.close(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -607,15 +598,12 @@ where unsafe extern "C" fn audio_decoder_start( ptr: *mut ffi::GstAudioDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -629,15 +617,12 @@ where unsafe extern "C" fn audio_decoder_stop( ptr: *mut ffi::GstAudioDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -652,15 +637,12 @@ where unsafe extern "C" fn audio_decoder_set_format( ptr: *mut ffi::GstAudioDecoder, caps: *mut gst::ffi::GstCaps, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { Ok(()) => true, Err(err) => { @@ -677,15 +659,12 @@ unsafe extern "C" fn audio_decoder_parse( adapter: *mut gst_base::ffi::GstAdapter, offset: *mut i32, len: *mut i32, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.parse(wrap.unsafe_cast_ref(), &from_glib_borrow(adapter)) { Ok((new_offset, new_len)) => { assert!(new_offset <= std::i32::MAX as u32); @@ -704,17 +683,14 @@ where unsafe extern "C" fn audio_decoder_handle_frame( ptr: *mut ffi::GstAudioDecoder, buffer: *mut *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { // FIXME: Misgenerated in gstreamer-audio-sys let buffer = buffer as *mut gst::ffi::GstBuffer; let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.handle_frame( wrap.unsafe_cast_ref(), Option::::from_glib_none(buffer).as_ref(), @@ -727,15 +703,12 @@ where unsafe extern "C" fn audio_decoder_pre_push( ptr: *mut ffi::GstAudioDecoder, buffer: *mut *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) { Ok(Some(new_buffer)) => { *buffer = new_buffer.into_ptr(); @@ -755,29 +728,24 @@ where unsafe extern "C" fn audio_decoder_flush( ptr: *mut ffi::GstAudioDecoder, hard: glib::ffi::gboolean, -) where - T::Instance: PanicPoison, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), (), { + gst::panic_to_error!(&wrap, &imp.panicked(), (), { AudioDecoderImpl::flush(imp, wrap.unsafe_cast_ref(), from_glib(hard)) }) } unsafe extern "C" fn audio_decoder_negotiate( ptr: *mut ffi::GstAudioDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.negotiate(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -792,15 +760,12 @@ where unsafe extern "C" fn audio_decoder_getcaps( ptr: *mut ffi::GstAudioDecoder, filter: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { AudioDecoderImpl::get_caps( imp, wrap.unsafe_cast_ref(), @@ -815,15 +780,12 @@ where unsafe extern "C" fn audio_decoder_sink_event( ptr: *mut ffi::GstAudioDecoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -832,15 +794,12 @@ where unsafe extern "C" fn audio_decoder_sink_query( ptr: *mut ffi::GstAudioDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -849,15 +808,12 @@ where unsafe extern "C" fn audio_decoder_src_event( ptr: *mut ffi::GstAudioDecoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -866,15 +822,12 @@ where unsafe extern "C" fn audio_decoder_src_query( ptr: *mut ffi::GstAudioDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -883,16 +836,13 @@ where unsafe extern "C" fn audio_decoder_propose_allocation( ptr: *mut ffi::GstAudioDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { @@ -907,16 +857,13 @@ where unsafe extern "C" fn audio_decoder_decide_allocation( ptr: *mut ffi::GstAudioDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index 50ef6fa35..b82053793 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -476,10 +476,7 @@ impl AudioEncoderImplExt for T { } } -unsafe impl IsSubclassable for AudioEncoder -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for AudioEncoder { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -508,15 +505,12 @@ where unsafe extern "C" fn audio_encoder_open( ptr: *mut ffi::GstAudioEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.open(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -530,15 +524,12 @@ where unsafe extern "C" fn audio_encoder_close( ptr: *mut ffi::GstAudioEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.close(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -552,15 +543,12 @@ where unsafe extern "C" fn audio_encoder_start( ptr: *mut ffi::GstAudioEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -574,15 +562,12 @@ where unsafe extern "C" fn audio_encoder_stop( ptr: *mut ffi::GstAudioEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -597,15 +582,12 @@ where unsafe extern "C" fn audio_encoder_set_format( ptr: *mut ffi::GstAudioEncoder, info: *mut ffi::GstAudioInfo, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_none(info)) { Ok(()) => true, Err(err) => { @@ -620,17 +602,14 @@ where unsafe extern "C" fn audio_encoder_handle_frame( ptr: *mut ffi::GstAudioEncoder, buffer: *mut *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { // FIXME: Misgenerated in gstreamer-audio-sys let buffer = buffer as *mut gst::ffi::GstBuffer; let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.handle_frame( wrap.unsafe_cast_ref(), Option::::from_glib_none(buffer).as_ref(), @@ -643,15 +622,12 @@ where unsafe extern "C" fn audio_encoder_pre_push( ptr: *mut ffi::GstAudioEncoder, buffer: *mut *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) { Ok(Some(new_buffer)) => { *buffer = new_buffer.into_ptr(); @@ -668,30 +644,24 @@ where .to_glib() } -unsafe extern "C" fn audio_encoder_flush(ptr: *mut ffi::GstAudioEncoder) -where - T::Instance: PanicPoison, -{ +unsafe extern "C" fn audio_encoder_flush(ptr: *mut ffi::GstAudioEncoder) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), (), { + gst::panic_to_error!(&wrap, &imp.panicked(), (), { AudioEncoderImpl::flush(imp, wrap.unsafe_cast_ref()) }) } unsafe extern "C" fn audio_encoder_negotiate( ptr: *mut ffi::GstAudioEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.negotiate(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -706,15 +676,12 @@ where unsafe extern "C" fn audio_encoder_getcaps( ptr: *mut ffi::GstAudioEncoder, filter: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { AudioEncoderImpl::get_caps( imp, wrap.unsafe_cast_ref(), @@ -729,15 +696,12 @@ where unsafe extern "C" fn audio_encoder_sink_event( ptr: *mut ffi::GstAudioEncoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -746,15 +710,12 @@ where unsafe extern "C" fn audio_encoder_sink_query( ptr: *mut ffi::GstAudioEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -763,15 +724,12 @@ where unsafe extern "C" fn audio_encoder_src_event( ptr: *mut ffi::GstAudioEncoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -780,15 +738,12 @@ where unsafe extern "C" fn audio_encoder_src_query( ptr: *mut ffi::GstAudioEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -797,16 +752,13 @@ where unsafe extern "C" fn audio_encoder_propose_allocation( ptr: *mut ffi::GstAudioEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { @@ -821,16 +773,13 @@ where unsafe extern "C" fn audio_encoder_decide_allocation( ptr: *mut ffi::GstAudioEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { diff --git a/gstreamer-audio/src/subclass/audio_sink.rs b/gstreamer-audio/src/subclass/audio_sink.rs index 3dbd04edd..ad7a7d9ac 100644 --- a/gstreamer-audio/src/subclass/audio_sink.rs +++ b/gstreamer-audio/src/subclass/audio_sink.rs @@ -4,7 +4,6 @@ use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use gst::subclass::prelude::*; use gst::LoggableError; use gst_base::subclass::prelude::*; @@ -184,10 +183,7 @@ impl AudioSinkImplExt for T { } } -unsafe impl IsSubclassable for AudioSink -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for AudioSink { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -207,15 +203,12 @@ where unsafe extern "C" fn audiosink_close( ptr: *mut ffi::GstAudioSink, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.close(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -227,30 +220,24 @@ where .to_glib() } -unsafe extern "C" fn audiosink_delay(ptr: *mut ffi::GstAudioSink) -> u32 -where - T::Instance: PanicPoison, -{ +unsafe extern "C" fn audiosink_delay(ptr: *mut ffi::GstAudioSink) -> u32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), 0, { + gst::panic_to_error!(&wrap, &imp.panicked(), 0, { imp.delay(wrap.unsafe_cast_ref()) }) } unsafe extern "C" fn audiosink_open( ptr: *mut ffi::GstAudioSink, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.open(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -265,17 +252,14 @@ where unsafe extern "C" fn audiosink_prepare( ptr: *mut ffi::GstAudioSink, spec: *mut ffi::GstAudioRingBufferSpec, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let spec = &mut *(spec as *mut AudioRingBufferSpec); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match AudioSinkImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) { Ok(()) => true, Err(err) => { @@ -289,15 +273,12 @@ where unsafe extern "C" fn audiosink_unprepare( ptr: *mut ffi::GstAudioSink, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.unprepare(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -313,29 +294,23 @@ unsafe extern "C" fn audiosink_write( ptr: *mut ffi::GstAudioSink, data: glib::ffi::gpointer, length: u32, -) -> i32 -where - T::Instance: PanicPoison, -{ +) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let data_slice = std::slice::from_raw_parts(data as *const u8, length as usize); - gst::panic_to_error!(&wrap, &instance.panicked(), -1, { + gst::panic_to_error!(&wrap, &imp.panicked(), -1, { imp.write(wrap.unsafe_cast_ref(), data_slice).unwrap_or(-1) }) } -unsafe extern "C" fn audiosink_reset(ptr: *mut ffi::GstAudioSink) -where - T::Instance: PanicPoison, -{ +unsafe extern "C" fn audiosink_reset(ptr: *mut ffi::GstAudioSink) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), (), { + gst::panic_to_error!(&wrap, &imp.panicked(), (), { imp.reset(wrap.unsafe_cast_ref()); }); } diff --git a/gstreamer-audio/src/subclass/audio_src.rs b/gstreamer-audio/src/subclass/audio_src.rs index 93b3e1c8c..89c02a60f 100644 --- a/gstreamer-audio/src/subclass/audio_src.rs +++ b/gstreamer-audio/src/subclass/audio_src.rs @@ -6,7 +6,6 @@ use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use gst::subclass::prelude::*; use gst::LoggableError; use gst_base::subclass::prelude::*; @@ -200,10 +199,7 @@ impl AudioSrcImplExt for T { } } -unsafe impl IsSubclassable for AudioSrc -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for AudioSrc { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -223,15 +219,12 @@ where unsafe extern "C" fn audiosrc_close( ptr: *mut ffi::GstAudioSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.close(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -243,30 +236,24 @@ where .to_glib() } -unsafe extern "C" fn audiosrc_delay(ptr: *mut ffi::GstAudioSrc) -> u32 -where - T::Instance: PanicPoison, -{ +unsafe extern "C" fn audiosrc_delay(ptr: *mut ffi::GstAudioSrc) -> u32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), 0, { + gst::panic_to_error!(&wrap, &imp.panicked(), 0, { imp.delay(wrap.unsafe_cast_ref()) }) } unsafe extern "C" fn audiosrc_open( ptr: *mut ffi::GstAudioSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.open(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -281,17 +268,14 @@ where unsafe extern "C" fn audiosrc_prepare( ptr: *mut ffi::GstAudioSrc, spec: *mut ffi::GstAudioRingBufferSpec, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let spec = &mut *(spec as *mut AudioRingBufferSpec); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match AudioSrcImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) { Ok(()) => true, Err(err) => { @@ -305,15 +289,12 @@ where unsafe extern "C" fn audiosrc_unprepare( ptr: *mut ffi::GstAudioSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.unprepare(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -330,16 +311,13 @@ unsafe extern "C" fn audiosrc_read( data: glib::ffi::gpointer, length: u32, timestamp: *mut gst::ffi::GstClockTime, -) -> u32 -where - T::Instance: PanicPoison, -{ +) -> u32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let data_slice = std::slice::from_raw_parts_mut(data as *mut u8, length as usize); - gst::panic_to_error!(&wrap, &instance.panicked(), 0, { + gst::panic_to_error!(&wrap, &imp.panicked(), 0, { let (res, timestamp_res) = imp .read(wrap.unsafe_cast_ref(), data_slice) .unwrap_or((0, gst::CLOCK_TIME_NONE)); @@ -349,15 +327,12 @@ where }) } -unsafe extern "C" fn audiosrc_reset(ptr: *mut ffi::GstAudioSrc) -where - T::Instance: PanicPoison, -{ +unsafe extern "C" fn audiosrc_reset(ptr: *mut ffi::GstAudioSrc) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), (), { + gst::panic_to_error!(&wrap, &imp.panicked(), (), { imp.reset(wrap.unsafe_cast_ref()); }); } diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index 80f204f74..0733b128d 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -703,10 +703,7 @@ impl AggregatorImplExt for T { } } -unsafe impl IsSubclassable for Aggregator -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for Aggregator { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -743,15 +740,12 @@ where unsafe extern "C" fn aggregator_flush( ptr: *mut ffi::GstAggregator, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.flush(wrap.unsafe_cast_ref()).into() }) .to_glib() @@ -761,15 +755,12 @@ unsafe extern "C" fn aggregator_clip( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, buffer: *mut gst::ffi::GstBuffer, -) -> *mut gst::ffi::GstBuffer -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstBuffer { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - let ret = gst::panic_to_error!(&wrap, &instance.panicked(), None, { + let ret = gst::panic_to_error!(&wrap, &imp.panicked(), None, { imp.clip( wrap.unsafe_cast_ref(), &from_glib_borrow(aggregator_pad), @@ -783,15 +774,12 @@ where unsafe extern "C" fn aggregator_finish_buffer( ptr: *mut ffi::GstAggregator, buffer: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.finish_buffer(wrap.unsafe_cast_ref(), from_glib_full(buffer)) .into() }) @@ -803,15 +791,12 @@ where unsafe extern "C" fn aggregator_finish_buffer_list( ptr: *mut ffi::GstAggregator, buffer_list: *mut gst::ffi::GstBufferList, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.finish_buffer_list(wrap.unsafe_cast_ref(), from_glib_full(buffer_list)) .into() }) @@ -822,15 +807,12 @@ unsafe extern "C" fn aggregator_sink_event( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(wrap, &instance.panicked(), false, { + gst::panic_to_error!(wrap, &imp.panicked(), false, { imp.sink_event( wrap.unsafe_cast_ref(), &from_glib_borrow(aggregator_pad), @@ -846,15 +828,12 @@ unsafe extern "C" fn aggregator_sink_event_pre_queue( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, event: *mut gst::ffi::GstEvent, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.sink_event_pre_queue( wrap.unsafe_cast_ref(), &from_glib_borrow(aggregator_pad), @@ -869,15 +848,12 @@ unsafe extern "C" fn aggregator_sink_query( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_query( wrap.unsafe_cast_ref(), &from_glib_borrow(aggregator_pad), @@ -893,15 +869,12 @@ unsafe extern "C" fn aggregator_sink_query_pre_queue( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_query_pre_queue( wrap.unsafe_cast_ref(), &from_glib_borrow(aggregator_pad), @@ -914,15 +887,12 @@ where unsafe extern "C" fn aggregator_src_event( ptr: *mut ffi::GstAggregator, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -931,15 +901,12 @@ where unsafe extern "C" fn aggregator_src_query( ptr: *mut ffi::GstAggregator, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -949,15 +916,12 @@ unsafe extern "C" fn aggregator_src_activate( ptr: *mut ffi::GstAggregator, mode: gst::ffi::GstPadMode, active: glib::ffi::gboolean, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.src_activate(wrap.unsafe_cast_ref(), from_glib(mode), from_glib(active)) { Ok(()) => true, Err(err) => { @@ -972,15 +936,12 @@ where unsafe extern "C" fn aggregator_aggregate( ptr: *mut ffi::GstAggregator, timeout: glib::ffi::gboolean, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.aggregate(wrap.unsafe_cast_ref(), from_glib(timeout)) .into() }) @@ -989,15 +950,12 @@ where unsafe extern "C" fn aggregator_start( ptr: *mut ffi::GstAggregator, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -1011,15 +969,12 @@ where unsafe extern "C" fn aggregator_stop( ptr: *mut ffi::GstAggregator, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -1033,15 +988,12 @@ where unsafe extern "C" fn aggregator_get_next_time( ptr: *mut ffi::GstAggregator, -) -> gst::ffi::GstClockTime -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstClockTime { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::CLOCK_TIME_NONE, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::CLOCK_TIME_NONE, { imp.get_next_time(wrap.unsafe_cast_ref()) }) .to_glib() @@ -1052,15 +1004,12 @@ unsafe extern "C" fn aggregator_create_new_pad( templ: *mut gst::ffi::GstPadTemplate, req_name: *const libc::c_char, caps: *const gst::ffi::GstCaps, -) -> *mut ffi::GstAggregatorPad -where - T::Instance: PanicPoison, -{ +) -> *mut ffi::GstAggregatorPad { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), None, { + gst::panic_to_error!(&wrap, &imp.panicked(), None, { let req_name: Borrowed> = from_glib_borrow(req_name); imp.create_new_pad( @@ -1079,17 +1028,14 @@ unsafe extern "C" fn aggregator_update_src_caps( ptr: *mut ffi::GstAggregator, caps: *mut gst::ffi::GstCaps, res: *mut *mut gst::ffi::GstCaps, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); *res = ptr::null_mut(); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.update_src_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { Ok(res_caps) => { *res = res_caps.into_ptr(); @@ -1104,15 +1050,12 @@ where unsafe extern "C" fn aggregator_fixate_src_caps( ptr: *mut ffi::GstAggregator, caps: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { imp.fixate_src_caps(wrap.unsafe_cast_ref(), from_glib_full(caps)) }) .into_ptr() @@ -1121,15 +1064,12 @@ where unsafe extern "C" fn aggregator_negotiated_src_caps( ptr: *mut ffi::GstAggregator, caps: *mut gst::ffi::GstCaps, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.negotiated_src_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { Ok(()) => true, Err(err) => { @@ -1145,15 +1085,12 @@ where #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] unsafe extern "C" fn aggregator_negotiate( ptr: *mut ffi::GstAggregator, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.negotiate(wrap.unsafe_cast_ref()) }) .to_glib() @@ -1164,15 +1101,12 @@ where unsafe extern "C" fn aggregator_peek_next_sample( ptr: *mut ffi::GstAggregator, pad: *mut ffi::GstAggregatorPad, -) -> *mut gst::ffi::GstSample -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstSample { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), None, { + gst::panic_to_error!(&wrap, &imp.panicked(), None, { imp.peek_next_sample(wrap.unsafe_cast_ref(), &from_glib_borrow(pad)) }) .to_glib_full() diff --git a/gstreamer-base/src/subclass/base_parse.rs b/gstreamer-base/src/subclass/base_parse.rs index 799b33c05..535fd643a 100644 --- a/gstreamer-base/src/subclass/base_parse.rs +++ b/gstreamer-base/src/subclass/base_parse.rs @@ -203,10 +203,7 @@ impl BaseParseImplExt for T { } } -unsafe impl IsSubclassable for BaseParse -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for BaseParse { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -224,15 +221,12 @@ where unsafe extern "C" fn base_parse_start( ptr: *mut ffi::GstBaseParse, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -246,15 +240,12 @@ where unsafe extern "C" fn base_parse_stop( ptr: *mut ffi::GstBaseParse, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -269,16 +260,13 @@ where unsafe extern "C" fn base_parse_set_sink_caps( ptr: *mut ffi::GstBaseParse, caps: *mut gst::ffi::GstCaps, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let caps: Borrowed = from_glib_borrow(caps); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_sink_caps(wrap.unsafe_cast_ref(), &caps) { Ok(()) => true, Err(err) => { @@ -294,16 +282,13 @@ unsafe extern "C" fn base_parse_handle_frame( ptr: *mut ffi::GstBaseParse, frame: *mut ffi::GstBaseParseFrame, skipsize: *mut i32, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let wrap_frame = BaseParseFrame::new(frame, &wrap); - let res = gst::panic_to_error!(&wrap, &instance.panicked(), Err(gst::FlowError::Error), { + let res = gst::panic_to_error!(&wrap, &imp.panicked(), Err(gst::FlowError::Error), { imp.handle_frame(&wrap.unsafe_cast_ref(), wrap_frame) }); @@ -323,16 +308,13 @@ unsafe extern "C" fn base_parse_convert( source_value: i64, dest_format: gst::ffi::GstFormat, dest_value: *mut i64, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let source = gst::GenericFormattedValue::new(from_glib(source_format), source_value); - let res = gst::panic_to_error!(&wrap, &instance.panicked(), None, { + let res = gst::panic_to_error!(&wrap, &imp.panicked(), None, { imp.convert(wrap.unsafe_cast_ref(), source, from_glib(dest_format)) }); diff --git a/gstreamer-base/src/subclass/base_sink.rs b/gstreamer-base/src/subclass/base_sink.rs index d326f169c..8f62da818 100644 --- a/gstreamer-base/src/subclass/base_sink.rs +++ b/gstreamer-base/src/subclass/base_sink.rs @@ -400,10 +400,7 @@ impl BaseSinkImplExt for T { } } -unsafe impl IsSubclassable for BaseSink -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for BaseSink { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -429,15 +426,12 @@ where unsafe extern "C" fn base_sink_start( ptr: *mut ffi::GstBaseSink, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -451,15 +445,12 @@ where unsafe extern "C" fn base_sink_stop( ptr: *mut ffi::GstBaseSink, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -474,16 +465,13 @@ where unsafe extern "C" fn base_sink_render( ptr: *mut ffi::GstBaseSink, buffer: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let buffer = from_glib_borrow(buffer); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.render(wrap.unsafe_cast_ref(), &buffer).into() }) .to_glib() @@ -492,16 +480,13 @@ where unsafe extern "C" fn base_sink_prepare( ptr: *mut ffi::GstBaseSink, buffer: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let buffer = from_glib_borrow(buffer); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.prepare(wrap.unsafe_cast_ref(), &buffer).into() }) .to_glib() @@ -510,16 +495,13 @@ where unsafe extern "C" fn base_sink_render_list( ptr: *mut ffi::GstBaseSink, list: *mut gst::ffi::GstBufferList, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let list = from_glib_borrow(list); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.render_list(wrap.unsafe_cast_ref(), &list).into() }) .to_glib() @@ -528,16 +510,13 @@ where unsafe extern "C" fn base_sink_prepare_list( ptr: *mut ffi::GstBaseSink, list: *mut gst::ffi::GstBufferList, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let list = from_glib_borrow(list); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.prepare_list(wrap.unsafe_cast_ref(), &list).into() }) .to_glib() @@ -546,16 +525,13 @@ where unsafe extern "C" fn base_sink_query( ptr: *mut ffi::GstBaseSink, query_ptr: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query_ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { BaseSinkImpl::query(imp, wrap.unsafe_cast_ref(), query) }) .to_glib() @@ -564,15 +540,12 @@ where unsafe extern "C" fn base_sink_event( ptr: *mut ffi::GstBaseSink, event_ptr: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.event(wrap.unsafe_cast_ref(), from_glib_full(event_ptr)) }) .to_glib() @@ -581,16 +554,13 @@ where unsafe extern "C" fn base_sink_get_caps( ptr: *mut ffi::GstBaseSink, filter: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let filter = Option::::from_glib_borrow(filter); - gst::panic_to_error!(&wrap, &instance.panicked(), None, { + gst::panic_to_error!(&wrap, &imp.panicked(), None, { imp.get_caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref()) }) .map(|caps| caps.into_ptr()) @@ -600,16 +570,13 @@ where unsafe extern "C" fn base_sink_set_caps( ptr: *mut ffi::GstBaseSink, caps: *mut gst::ffi::GstCaps, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let caps = from_glib_borrow(caps); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_caps(wrap.unsafe_cast_ref(), &caps) { Ok(()) => true, Err(err) => { @@ -624,16 +591,13 @@ where unsafe extern "C" fn base_sink_fixate( ptr: *mut ffi::GstBaseSink, caps: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let caps = from_glib_full(caps); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { imp.fixate(wrap.unsafe_cast_ref(), caps) }) .into_ptr() @@ -641,15 +605,12 @@ where unsafe extern "C" fn base_sink_unlock( ptr: *mut ffi::GstBaseSink, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.unlock(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -663,15 +624,12 @@ where unsafe extern "C" fn base_sink_unlock_stop( ptr: *mut ffi::GstBaseSink, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.unlock_stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { diff --git a/gstreamer-base/src/subclass/base_src.rs b/gstreamer-base/src/subclass/base_src.rs index 68452644c..ad512f95d 100644 --- a/gstreamer-base/src/subclass/base_src.rs +++ b/gstreamer-base/src/subclass/base_src.rs @@ -580,10 +580,7 @@ impl BaseSrcImplExt for T { } } -unsafe impl IsSubclassable for BaseSrc -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for BaseSrc { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -613,15 +610,12 @@ where unsafe extern "C" fn base_src_start( ptr: *mut ffi::GstBaseSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -633,15 +627,14 @@ where .to_glib() } -unsafe extern "C" fn base_src_stop(ptr: *mut ffi::GstBaseSrc) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +unsafe extern "C" fn base_src_stop( + ptr: *mut ffi::GstBaseSrc, +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -655,15 +648,12 @@ where unsafe extern "C" fn base_src_is_seekable( ptr: *mut ffi::GstBaseSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.is_seekable(wrap.unsafe_cast_ref()) }) .to_glib() @@ -672,15 +662,12 @@ where unsafe extern "C" fn base_src_get_size( ptr: *mut ffi::GstBaseSrc, size: *mut u64, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.get_size(wrap.unsafe_cast_ref()) { Some(s) => { *size = s; @@ -697,9 +684,7 @@ unsafe extern "C" fn base_src_get_times( buffer: *mut gst::ffi::GstBuffer, start: *mut gst::ffi::GstClockTime, stop: *mut gst::ffi::GstClockTime, -) where - T::Instance: PanicPoison, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -708,7 +693,7 @@ unsafe extern "C" fn base_src_get_times( *start = gst::ffi::GST_CLOCK_TIME_NONE; *stop = gst::ffi::GST_CLOCK_TIME_NONE; - gst::panic_to_error!(&wrap, &instance.panicked(), (), { + gst::panic_to_error!(&wrap, &imp.panicked(), (), { let (start_, stop_) = imp.get_times(wrap.unsafe_cast_ref(), buffer); *start = start_.to_glib(); *stop = stop_.to_glib(); @@ -720,16 +705,13 @@ unsafe extern "C" fn base_src_fill( offset: u64, length: u32, buffer: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let buffer = gst::BufferRef::from_mut_ptr(buffer); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.fill(wrap.unsafe_cast_ref(), offset, length, buffer) .into() }) @@ -741,10 +723,7 @@ unsafe extern "C" fn base_src_alloc( offset: u64, length: u32, buffer_ptr: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -752,7 +731,7 @@ where // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer; - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.alloc(wrap.unsafe_cast_ref(), offset, length) { Ok(buffer) => { *buffer_ptr = buffer.into_ptr(); @@ -769,10 +748,7 @@ unsafe extern "C" fn base_src_create( offset: u64, length: u32, buffer_ptr: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -786,7 +762,7 @@ where Some(gst::BufferRef::from_mut_ptr(*buffer_ptr)) }; - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.create( wrap.unsafe_cast_ref(), offset, @@ -856,15 +832,12 @@ where unsafe extern "C" fn base_src_do_seek( ptr: *mut ffi::GstBaseSrc, segment: *mut gst::ffi::GstSegment, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { let mut s = from_glib_none(segment); let res = imp.do_seek(wrap.unsafe_cast_ref(), &mut s); ptr::write(segment, *(s.to_glib_none().0)); @@ -877,16 +850,13 @@ where unsafe extern "C" fn base_src_query( ptr: *mut ffi::GstBaseSrc, query_ptr: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query_ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { BaseSrcImpl::query(imp, wrap.unsafe_cast_ref(), query) }) .to_glib() @@ -895,15 +865,12 @@ where unsafe extern "C" fn base_src_event( ptr: *mut ffi::GstBaseSrc, event_ptr: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.event(wrap.unsafe_cast_ref(), &from_glib_borrow(event_ptr)) }) .to_glib() @@ -912,16 +879,13 @@ where unsafe extern "C" fn base_src_get_caps( ptr: *mut ffi::GstBaseSrc, filter: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let filter = Option::::from_glib_borrow(filter); - gst::panic_to_error!(&wrap, &instance.panicked(), None, { + gst::panic_to_error!(&wrap, &imp.panicked(), None, { imp.get_caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref()) }) .map(|caps| caps.into_ptr()) @@ -930,15 +894,12 @@ where unsafe extern "C" fn base_src_negotiate( ptr: *mut ffi::GstBaseSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.negotiate(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -953,16 +914,13 @@ where unsafe extern "C" fn base_src_set_caps( ptr: *mut ffi::GstBaseSrc, caps: *mut gst::ffi::GstCaps, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let caps = from_glib_borrow(caps); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_caps(wrap.unsafe_cast_ref(), &caps) { Ok(()) => true, Err(err) => { @@ -977,16 +935,13 @@ where unsafe extern "C" fn base_src_fixate( ptr: *mut ffi::GstBaseSrc, caps: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let caps = from_glib_full(caps); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { imp.fixate(wrap.unsafe_cast_ref(), caps) }) .into_ptr() @@ -994,15 +949,12 @@ where unsafe extern "C" fn base_src_unlock( ptr: *mut ffi::GstBaseSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.unlock(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -1016,15 +968,12 @@ where unsafe extern "C" fn base_src_unlock_stop( ptr: *mut ffi::GstBaseSrc, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.unlock_stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { diff --git a/gstreamer-base/src/subclass/base_transform.rs b/gstreamer-base/src/subclass/base_transform.rs index e7079b418..f60a3c712 100644 --- a/gstreamer-base/src/subclass/base_transform.rs +++ b/gstreamer-base/src/subclass/base_transform.rs @@ -834,10 +834,7 @@ impl BaseTransformImplExt for T { } } -unsafe impl IsSubclassable for BaseTransform -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for BaseTransform { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -898,15 +895,12 @@ pub enum PrepareOutputBufferSuccess { unsafe extern "C" fn base_transform_start( ptr: *mut ffi::GstBaseTransform, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -920,15 +914,12 @@ where unsafe extern "C" fn base_transform_stop( ptr: *mut ffi::GstBaseTransform, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -945,15 +936,12 @@ unsafe extern "C" fn base_transform_transform_caps( direction: gst::ffi::GstPadDirection, caps: *mut gst::ffi::GstCaps, filter: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), None, { + gst::panic_to_error!(&wrap, &imp.panicked(), None, { let filter: Borrowed> = from_glib_borrow(filter); imp.transform_caps( @@ -972,15 +960,12 @@ unsafe extern "C" fn base_transform_fixate_caps( direction: gst::ffi::GstPadDirection, caps: *mut gst::ffi::GstCaps, othercaps: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { imp.fixate_caps( wrap.unsafe_cast_ref(), from_glib(direction), @@ -995,15 +980,12 @@ unsafe extern "C" fn base_transform_set_caps( ptr: *mut ffi::GstBaseTransform, incaps: *mut gst::ffi::GstCaps, outcaps: *mut gst::ffi::GstCaps, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_caps( wrap.unsafe_cast_ref(), &from_glib_borrow(incaps), @@ -1023,15 +1005,12 @@ unsafe extern "C" fn base_transform_accept_caps( ptr: *mut ffi::GstBaseTransform, direction: gst::ffi::GstPadDirection, caps: *mut gst::ffi::GstCaps, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.accept_caps( wrap.unsafe_cast_ref(), from_glib(direction), @@ -1045,15 +1024,12 @@ unsafe extern "C" fn base_transform_query( ptr: *mut ffi::GstBaseTransform, direction: gst::ffi::GstPadDirection, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { BaseTransformImpl::query( imp, wrap.unsafe_cast_ref(), @@ -1071,15 +1047,12 @@ unsafe extern "C" fn base_transform_transform_size( size: usize, othercaps: *mut gst::ffi::GstCaps, othersize: *mut usize, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.transform_size( wrap.unsafe_cast_ref(), from_glib(direction), @@ -1101,15 +1074,12 @@ unsafe extern "C" fn base_transform_get_unit_size( ptr: *mut ffi::GstBaseTransform, caps: *mut gst::ffi::GstCaps, size: *mut usize, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.get_unit_size(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { Some(s) => { *size = s; @@ -1125,10 +1095,7 @@ unsafe extern "C" fn base_transform_prepare_output_buffer( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, outbuf: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -1136,7 +1103,7 @@ where // FIXME: Wrong signature in FFI let outbuf = outbuf as *mut *mut gst::ffi::GstBuffer; - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.prepare_output_buffer(wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(inbuf)) { Ok(PrepareOutputBufferSuccess::InputBuffer) => { *outbuf = inbuf; @@ -1155,15 +1122,12 @@ where unsafe extern "C" fn base_transform_sink_event( ptr: *mut ffi::GstBaseTransform, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -1172,15 +1136,12 @@ where unsafe extern "C" fn base_transform_src_event( ptr: *mut ffi::GstBaseTransform, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -1190,15 +1151,12 @@ unsafe extern "C" fn base_transform_transform( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, outbuf: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.transform( wrap.unsafe_cast_ref(), &from_glib_borrow(inbuf), @@ -1212,10 +1170,7 @@ where unsafe extern "C" fn base_transform_transform_ip( ptr: *mut ffi::GstBaseTransform, buf: *mut *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -1223,7 +1178,7 @@ where // FIXME: Wrong signature in FFI let buf = buf as *mut gst::ffi::GstBuffer; - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { if from_glib(ffi::gst_base_transform_is_passthrough(ptr)) { imp.transform_ip_passthrough(wrap.unsafe_cast_ref(), &from_glib_borrow(buf)) .into() @@ -1240,17 +1195,14 @@ unsafe extern "C" fn base_transform_transform_meta( outbuf: *mut gst::ffi::GstBuffer, meta: *mut gst::ffi::GstMeta, inbuf: *mut gst::ffi::GstBuffer, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let inbuf = gst::BufferRef::from_ptr(inbuf); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.transform_meta( wrap.unsafe_cast_ref(), gst::BufferRef::from_mut_ptr(outbuf), @@ -1265,10 +1217,7 @@ unsafe extern "C" fn base_transform_copy_metadata( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, outbuf: *mut gst::ffi::GstBuffer, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -1283,7 +1232,7 @@ where return glib::ffi::GFALSE; } - gst::panic_to_error!(&wrap, &instance.panicked(), true, { + gst::panic_to_error!(&wrap, &imp.panicked(), true, { match imp.copy_metadata( wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(inbuf), @@ -1302,14 +1251,12 @@ where unsafe extern "C" fn base_transform_before_transform( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, -) where - T::Instance: PanicPoison, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), (), { + gst::panic_to_error!(&wrap, &imp.panicked(), (), { imp.before_transform(wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(inbuf)); }) } @@ -1318,15 +1265,12 @@ unsafe extern "C" fn base_transform_submit_input_buffer( ptr: *mut ffi::GstBaseTransform, is_discont: glib::ffi::gboolean, buf: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.submit_input_buffer( wrap.unsafe_cast_ref(), from_glib(is_discont), @@ -1340,17 +1284,14 @@ where unsafe extern "C" fn base_transform_generate_output( ptr: *mut ffi::GstBaseTransform, buf: *mut *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); *buf = ptr::null_mut(); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match imp.generate_output(wrap.unsafe_cast_ref()) { Ok(GenerateOutputSuccess::Dropped) => crate::BASE_TRANSFORM_FLOW_DROPPED.into(), Ok(GenerateOutputSuccess::NoOutput) => gst::FlowReturn::Ok, diff --git a/gstreamer-base/src/subclass/push_src.rs b/gstreamer-base/src/subclass/push_src.rs index a9320b4e8..a5ed5fb7c 100644 --- a/gstreamer-base/src/subclass/push_src.rs +++ b/gstreamer-base/src/subclass/push_src.rs @@ -4,8 +4,6 @@ use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; -use gst::subclass::prelude::*; - use std::ptr; use super::base_src::BaseSrcImpl; @@ -110,10 +108,7 @@ impl PushSrcImplExt for T { } } -unsafe impl IsSubclassable for PushSrc -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for PushSrc { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -130,16 +125,13 @@ where unsafe extern "C" fn push_src_fill( ptr: *mut ffi::GstPushSrc, buffer: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let buffer = gst::BufferRef::from_mut_ptr(buffer); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { PushSrcImpl::fill(imp, wrap.unsafe_cast_ref(), buffer).into() }) .to_glib() @@ -148,10 +140,7 @@ where unsafe extern "C" fn push_src_alloc( ptr: *mut ffi::GstPushSrc, buffer_ptr: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -159,7 +148,7 @@ where // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer; - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match PushSrcImpl::alloc(imp, wrap.unsafe_cast_ref()) { Ok(buffer) => { *buffer_ptr = buffer.into_ptr(); @@ -174,10 +163,7 @@ where unsafe extern "C" fn push_src_create( ptr: *mut ffi::GstPushSrc, buffer_ptr: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -185,7 +171,7 @@ where // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer; - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { match PushSrcImpl::create(imp, wrap.unsafe_cast_ref()) { Ok(buffer) => { *buffer_ptr = buffer.into_ptr(); diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index 710bc412f..c037ee089 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -532,10 +532,7 @@ impl VideoDecoderImplExt for T { } } -unsafe impl IsSubclassable for VideoDecoder -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for VideoDecoder { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -566,15 +563,12 @@ where unsafe extern "C" fn video_decoder_open( ptr: *mut ffi::GstVideoDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.open(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -588,15 +582,12 @@ where unsafe extern "C" fn video_decoder_close( ptr: *mut ffi::GstVideoDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.close(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -610,15 +601,12 @@ where unsafe extern "C" fn video_decoder_start( ptr: *mut ffi::GstVideoDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -632,15 +620,12 @@ where unsafe extern "C" fn video_decoder_stop( ptr: *mut ffi::GstVideoDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -654,15 +639,12 @@ where unsafe extern "C" fn video_decoder_finish( ptr: *mut ffi::GstVideoDecoder, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.finish(wrap.unsafe_cast_ref()).into() }) .to_glib() @@ -670,15 +652,12 @@ where unsafe extern "C" fn video_decoder_drain( ptr: *mut ffi::GstVideoDecoder, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.drain(wrap.unsafe_cast_ref()).into() }) .to_glib() @@ -687,17 +666,14 @@ where unsafe extern "C" fn video_decoder_set_format( ptr: *mut ffi::GstVideoDecoder, state: *mut ffi::GstVideoCodecState, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); ffi::gst_video_codec_state_ref(state); let wrap_state = VideoCodecState::::new(state); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_format(wrap.unsafe_cast_ref(), &wrap_state) { Ok(()) => true, Err(err) => { @@ -714,10 +690,7 @@ unsafe extern "C" fn video_decoder_parse( frame: *mut ffi::GstVideoCodecFrame, adapter: *mut gst_base::ffi::GstAdapter, at_eos: glib::ffi::gboolean, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -726,7 +699,7 @@ where let wrap_adapter: Borrowed = from_glib_borrow(adapter); let at_eos: bool = from_glib(at_eos); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.parse(wrap.unsafe_cast_ref(), &wrap_frame, &wrap_adapter, at_eos) .into() }) @@ -736,16 +709,13 @@ where unsafe extern "C" fn video_decoder_handle_frame( ptr: *mut ffi::GstVideoDecoder, frame: *mut ffi::GstVideoCodecFrame, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let wrap_frame = VideoCodecFrame::new(frame, &*wrap); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.handle_frame(wrap.unsafe_cast_ref(), wrap_frame).into() }) .to_glib() @@ -753,15 +723,12 @@ where unsafe extern "C" fn video_decoder_flush( ptr: *mut ffi::GstVideoDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { VideoDecoderImpl::flush(imp, wrap.unsafe_cast_ref()) }) .to_glib() @@ -769,15 +736,12 @@ where unsafe extern "C" fn video_decoder_negotiate( ptr: *mut ffi::GstVideoDecoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.negotiate(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -792,15 +756,12 @@ where unsafe extern "C" fn video_decoder_getcaps( ptr: *mut ffi::GstVideoDecoder, filter: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { VideoDecoderImpl::get_caps( imp, wrap.unsafe_cast_ref(), @@ -815,15 +776,12 @@ where unsafe extern "C" fn video_decoder_sink_event( ptr: *mut ffi::GstVideoDecoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -832,15 +790,12 @@ where unsafe extern "C" fn video_decoder_sink_query( ptr: *mut ffi::GstVideoDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -849,15 +804,12 @@ where unsafe extern "C" fn video_decoder_src_event( ptr: *mut ffi::GstVideoDecoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -866,15 +818,12 @@ where unsafe extern "C" fn video_decoder_src_query( ptr: *mut ffi::GstVideoDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -883,16 +832,13 @@ where unsafe extern "C" fn video_decoder_propose_allocation( ptr: *mut ffi::GstVideoDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { @@ -907,16 +853,13 @@ where unsafe extern "C" fn video_decoder_decide_allocation( ptr: *mut ffi::GstVideoDecoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index 7ca3a7c79..5284b4f3d 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -466,10 +466,7 @@ impl VideoEncoderImplExt for T { } } -unsafe impl IsSubclassable for VideoEncoder -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for VideoEncoder { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -498,15 +495,12 @@ where unsafe extern "C" fn video_encoder_open( ptr: *mut ffi::GstVideoEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.open(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -520,15 +514,12 @@ where unsafe extern "C" fn video_encoder_close( ptr: *mut ffi::GstVideoEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.close(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -542,15 +533,12 @@ where unsafe extern "C" fn video_encoder_start( ptr: *mut ffi::GstVideoEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.start(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -564,15 +552,12 @@ where unsafe extern "C" fn video_encoder_stop( ptr: *mut ffi::GstVideoEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.stop(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -586,15 +571,12 @@ where unsafe extern "C" fn video_encoder_finish( ptr: *mut ffi::GstVideoEncoder, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.finish(wrap.unsafe_cast_ref()).into() }) .to_glib() @@ -603,17 +585,14 @@ where unsafe extern "C" fn video_encoder_set_format( ptr: *mut ffi::GstVideoEncoder, state: *mut ffi::GstVideoCodecState, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); ffi::gst_video_codec_state_ref(state); let wrap_state = VideoCodecState::::new(state); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.set_format(wrap.unsafe_cast_ref(), &wrap_state) { Ok(()) => true, Err(err) => { @@ -628,16 +607,13 @@ where unsafe extern "C" fn video_encoder_handle_frame( ptr: *mut ffi::GstVideoEncoder, frame: *mut ffi::GstVideoCodecFrame, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let wrap_frame = VideoCodecFrame::new(frame, &*wrap); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.handle_frame(wrap.unsafe_cast_ref(), wrap_frame).into() }) .to_glib() @@ -645,15 +621,12 @@ where unsafe extern "C" fn video_encoder_flush( ptr: *mut ffi::GstVideoEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { VideoEncoderImpl::flush(imp, wrap.unsafe_cast_ref()) }) .to_glib() @@ -661,15 +634,12 @@ where unsafe extern "C" fn video_encoder_negotiate( ptr: *mut ffi::GstVideoEncoder, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.negotiate(wrap.unsafe_cast_ref()) { Ok(()) => true, Err(err) => { @@ -684,15 +654,12 @@ where unsafe extern "C" fn video_encoder_getcaps( ptr: *mut ffi::GstVideoEncoder, filter: *mut gst::ffi::GstCaps, -) -> *mut gst::ffi::GstCaps -where - T::Instance: PanicPoison, -{ +) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), { VideoEncoderImpl::get_caps( imp, wrap.unsafe_cast_ref(), @@ -707,15 +674,12 @@ where unsafe extern "C" fn video_encoder_sink_event( ptr: *mut ffi::GstVideoEncoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -724,15 +688,12 @@ where unsafe extern "C" fn video_encoder_sink_query( ptr: *mut ffi::GstVideoEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -741,15 +702,12 @@ where unsafe extern "C" fn video_encoder_src_event( ptr: *mut ffi::GstVideoEncoder, event: *mut gst::ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -758,15 +716,12 @@ where unsafe extern "C" fn video_encoder_src_query( ptr: *mut ffi::GstVideoEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query)) }) .to_glib() @@ -775,16 +730,13 @@ where unsafe extern "C" fn video_encoder_propose_allocation( ptr: *mut ffi::GstVideoEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { @@ -799,16 +751,13 @@ where unsafe extern "C" fn video_encoder_decide_allocation( ptr: *mut ffi::GstVideoEncoder, query: *mut gst::ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = gst::QueryRef::from_mut_ptr(query); - gst::panic_to_error!(&wrap, &instance.panicked(), false, { + gst::panic_to_error!(&wrap, &imp.panicked(), false, { match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { diff --git a/gstreamer-video/src/subclass/video_sink.rs b/gstreamer-video/src/subclass/video_sink.rs index 970a89e75..6ea1136b4 100644 --- a/gstreamer-video/src/subclass/video_sink.rs +++ b/gstreamer-video/src/subclass/video_sink.rs @@ -50,10 +50,7 @@ impl VideoSinkImplExt for T { } } -unsafe impl IsSubclassable for VideoSink -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for VideoSink { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -68,16 +65,13 @@ where unsafe extern "C" fn video_sink_show_frame( ptr: *mut ffi::GstVideoSink, buffer: *mut gst::ffi::GstBuffer, -) -> gst::ffi::GstFlowReturn -where - T::Instance: PanicPoison, -{ +) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let buffer = from_glib_borrow(buffer); - gst::panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, { imp.show_frame(wrap.unsafe_cast_ref(), &buffer).into() }) .to_glib() diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index 452914b31..44774d911 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -98,10 +98,7 @@ impl BinImplExt for T { } } -unsafe impl IsSubclassable for Bin -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for Bin { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let klass = klass.as_mut(); @@ -118,15 +115,12 @@ where unsafe extern "C" fn bin_add_element( ptr: *mut ffi::GstBin, element: *mut ffi::GstElement, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - panic_to_error!(&wrap, &instance.panicked(), false, { + panic_to_error!(&wrap, &imp.panicked(), false, { match imp.add_element(wrap.unsafe_cast_ref(), &from_glib_none(element)) { Ok(()) => true, Err(err) => { @@ -141,10 +135,7 @@ where unsafe extern "C" fn bin_remove_element( ptr: *mut ffi::GstBin, element: *mut ffi::GstElement, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -158,7 +149,7 @@ where return glib::ffi::GFALSE; } - panic_to_error!(&wrap, &instance.panicked(), false, { + panic_to_error!(&wrap, &imp.panicked(), false, { match imp.remove_element(wrap.unsafe_cast_ref(), &from_glib_none(element)) { Ok(()) => true, Err(err) => { @@ -173,14 +164,12 @@ where unsafe extern "C" fn bin_handle_message( ptr: *mut ffi::GstBin, message: *mut ffi::GstMessage, -) where - T::Instance: PanicPoison, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - panic_to_error!(&wrap, &instance.panicked(), (), { + panic_to_error!(&wrap, &imp.panicked(), (), { imp.handle_message(wrap.unsafe_cast_ref(), from_glib_full(message)) }); } diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index 9a7ba8145..f5e8048c4 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -1,6 +1,5 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use super::prelude::*; use crate::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; @@ -14,6 +13,8 @@ use crate::StateChangeError; use crate::StateChangeReturn; use crate::StateChangeSuccess; +use std::sync::atomic; + #[derive(Debug, Clone)] pub struct ElementMetadata { long_name: String, @@ -140,6 +141,8 @@ pub trait ElementImplExt: ObjectSubclass { fn parent_post_message(&self, element: &Self::Type, msg: crate::Message) -> bool; + fn panicked(&self) -> &atomic::AtomicBool; + fn catch_panic R, G: FnOnce() -> R, P: IsA>( &self, element: &P, @@ -154,10 +157,7 @@ pub trait ElementImplExt: ObjectSubclass { ) -> R; } -impl ElementImplExt for T -where - T::Instance: PanicPoison, -{ +impl ElementImplExt for T { fn parent_change_state( &self, element: &Self::Type, @@ -316,6 +316,11 @@ where } } + fn panicked(&self) -> &atomic::AtomicBool { + self.get_instance_data::(crate::Element::static_type()) + .expect("instance not initialized correctly") + } + fn catch_panic R, G: FnOnce() -> R, P: IsA>( &self, element: &P, @@ -328,7 +333,7 @@ where let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); - panic_to_error!(element, &instance.panicked(), fallback(), { f(&imp) }) + panic_to_error!(element, &imp.panicked(), fallback(), { f(&imp) }) } } @@ -344,17 +349,14 @@ where let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); - panic_to_error!(wrap, &instance.panicked(), fallback(), { + panic_to_error!(wrap, &imp.panicked(), fallback(), { f(&imp, wrap.unsafe_cast_ref()) }) } } } -unsafe impl IsSubclassable for Element -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for Element { fn class_init(klass: &mut glib::Class) { >::class_init(klass); @@ -396,16 +398,18 @@ where fn instance_init(instance: &mut glib::subclass::InitializingObject) { >::instance_init(instance); + + instance.set_instance_data( + crate::Element::static_type(), + atomic::AtomicBool::new(false), + ); } } unsafe extern "C" fn element_change_state( ptr: *mut ffi::GstElement, transition: ffi::GstStateChange, -) -> ffi::GstStateChangeReturn -where - T::Instance: PanicPoison, -{ +) -> ffi::GstStateChangeReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -420,7 +424,7 @@ where _ => StateChangeReturn::Failure, }; - panic_to_error!(&wrap, &instance.panicked(), fallback, { + panic_to_error!(&wrap, &imp.panicked(), fallback, { imp.change_state(wrap.unsafe_cast_ref(), transition).into() }) .to_glib() @@ -431,10 +435,7 @@ unsafe extern "C" fn element_request_new_pad( templ: *mut ffi::GstPadTemplate, name: *const libc::c_char, caps: *const ffi::GstCaps, -) -> *mut ffi::GstPad -where - T::Instance: PanicPoison, -{ +) -> *mut ffi::GstPad { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -443,7 +444,7 @@ where // XXX: This is effectively unsafe but the best we can do // See https://bugzilla.gnome.org/show_bug.cgi?id=791193 - let pad = panic_to_error!(&wrap, &instance.panicked(), None, { + let pad = panic_to_error!(&wrap, &imp.panicked(), None, { imp.request_new_pad( wrap.unsafe_cast_ref(), &from_glib_borrow(templ), @@ -468,9 +469,7 @@ where unsafe extern "C" fn element_release_pad( ptr: *mut ffi::GstElement, pad: *mut ffi::GstPad, -) where - T::Instance: PanicPoison, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -483,7 +482,7 @@ unsafe extern "C" fn element_release_pad( return; } - panic_to_error!(&wrap, &instance.panicked(), (), { + panic_to_error!(&wrap, &imp.panicked(), (), { imp.release_pad(wrap.unsafe_cast_ref(), &from_glib_none(pad)) }) } @@ -491,15 +490,12 @@ unsafe extern "C" fn element_release_pad( unsafe extern "C" fn element_send_event( ptr: *mut ffi::GstElement, event: *mut ffi::GstEvent, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - panic_to_error!(&wrap, &instance.panicked(), false, { + panic_to_error!(&wrap, &imp.panicked(), false, { imp.send_event(wrap.unsafe_cast_ref(), from_glib_full(event)) }) .to_glib() @@ -508,16 +504,13 @@ where unsafe extern "C" fn element_query( ptr: *mut ffi::GstElement, query: *mut ffi::GstQuery, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let query = QueryRef::from_mut_ptr(query); - panic_to_error!(&wrap, &instance.panicked(), false, { + panic_to_error!(&wrap, &imp.panicked(), false, { imp.query(wrap.unsafe_cast_ref(), query) }) .to_glib() @@ -526,14 +519,12 @@ where unsafe extern "C" fn element_set_context( ptr: *mut ffi::GstElement, context: *mut ffi::GstContext, -) where - T::Instance: PanicPoison, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - panic_to_error!(&wrap, &instance.panicked(), (), { + panic_to_error!(&wrap, &imp.panicked(), (), { imp.set_context(wrap.unsafe_cast_ref(), &from_glib_borrow(context)) }) } @@ -541,17 +532,14 @@ unsafe extern "C" fn element_set_context( unsafe extern "C" fn element_set_clock( ptr: *mut ffi::GstElement, clock: *mut ffi::GstClock, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); let clock = Option::::from_glib_borrow(clock); - panic_to_error!(&wrap, &instance.panicked(), false, { + panic_to_error!(&wrap, &imp.panicked(), false, { imp.set_clock(wrap.unsafe_cast_ref(), clock.as_ref().as_ref()) }) .to_glib() @@ -559,15 +547,12 @@ where unsafe extern "C" fn element_provide_clock( ptr: *mut ffi::GstElement, -) -> *mut ffi::GstClock -where - T::Instance: PanicPoison, -{ +) -> *mut ffi::GstClock { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); - panic_to_error!(&wrap, &instance.panicked(), None, { + panic_to_error!(&wrap, &imp.panicked(), None, { imp.provide_clock(wrap.unsafe_cast_ref()) }) .to_glib_full() @@ -576,10 +561,7 @@ where unsafe extern "C" fn element_post_message( ptr: *mut ffi::GstElement, msg: *mut ffi::GstMessage, -) -> glib::ffi::gboolean -where - T::Instance: PanicPoison, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Borrowed = from_glib_borrow(ptr); @@ -660,7 +642,6 @@ mod tests { const NAME: &'static str = "TestElement"; type Type = super::TestElement; type ParentType = Element; - type Instance = crate::subclass::ElementInstanceStruct; fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/gstreamer/src/subclass/mod.rs b/gstreamer/src/subclass/mod.rs index 7631cca97..8693e363c 100644 --- a/gstreamer/src/subclass/mod.rs +++ b/gstreamer/src/subclass/mod.rs @@ -55,28 +55,4 @@ pub mod prelude { pub use super::system_clock::SystemClockImpl; pub use super::tag_setter::TagSetterImpl; pub use super::uri_handler::URIHandlerImpl; - pub use super::PanicPoison; -} - -use self::prelude::*; -use std::sync::atomic::AtomicBool; - -#[repr(C)] -pub struct ElementInstanceStruct { - parent: ::GlibType, - panicked: AtomicBool, -} - -unsafe impl InstanceStruct for ElementInstanceStruct { - type Type = T; -} - -pub trait PanicPoison { - fn panicked(&self) -> &AtomicBool; -} - -impl PanicPoison for ElementInstanceStruct { - fn panicked(&self) -> &AtomicBool { - &self.panicked - } } diff --git a/gstreamer/src/subclass/pipeline.rs b/gstreamer/src/subclass/pipeline.rs index 7b5cedff3..06956e4c9 100644 --- a/gstreamer/src/subclass/pipeline.rs +++ b/gstreamer/src/subclass/pipeline.rs @@ -7,10 +7,7 @@ use crate::Pipeline; pub trait PipelineImpl: BinImpl {} -unsafe impl IsSubclassable for Pipeline -where - ::Instance: PanicPoison, -{ +unsafe impl IsSubclassable for Pipeline { fn class_init(klass: &mut glib::Class) { >::class_init(klass); let _klass = klass.as_mut();