diff --git a/examples/src/bin/custom_events.rs b/examples/src/bin/custom_events.rs index 847b9b63e..07a7f5aed 100644 --- a/examples/src/bin/custom_events.rs +++ b/examples/src/bin/custom_events.rs @@ -115,7 +115,7 @@ fn example_main() { // we moved into this callback. let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; println!("Sending custom event to the pipeline with send_eos={send_eos}"); let ev = ExampleCustomEvent::new(*send_eos); @@ -124,14 +124,14 @@ fn example_main() { } // Remove this handler, the pipeline will shutdown once our pad probe catches the custom // event and sends EOS - glib::Continue(false) + glib::ControlFlow::Break }); } let main_loop_clone = main_loop.clone(); // This sets the bus's signal handler (don't be mislead by the "add", there can only be one). // Every message from the bus is passed through this function. Its returnvalue determines - // whether the handler wants to be called again. If glib::Continue(false) is returned, the + // whether the handler wants to be called again. If glib::ControlFlow::Break is returned, the // handler is removed and will never be called again. The mainloop still runs though. let _bus_watch = bus .add_watch(move |_, msg| { @@ -158,7 +158,7 @@ fn example_main() { }; // Tell the mainloop to continue executing this callback. - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); diff --git a/examples/src/bin/d3d11videosink.rs b/examples/src/bin/d3d11videosink.rs index b953158c5..e889c80b2 100644 --- a/examples/src/bin/d3d11videosink.rs +++ b/examples/src/bin/d3d11videosink.rs @@ -351,7 +351,7 @@ fn main() -> Result<()> { _ => (), }; - glib::Continue(true) + glib::ControlFlow::Continue }) .unwrap(); diff --git a/examples/src/bin/events.rs b/examples/src/bin/events.rs index 689ffda44..40f76a339 100644 --- a/examples/src/bin/events.rs +++ b/examples/src/bin/events.rs @@ -50,14 +50,14 @@ fn example_main() { // Add a timeout to the main loop. This closure will be executed // in an interval of 5 seconds. The return value of the handler function // determines whether the handler still wants to be called: - // - glib::Continue(false) - stop calling this handler, remove timeout - // - glib::Continue(true) - continue calling this handler + // - glib::ControlFlow::Break - stop calling this handler, remove timeout + // - glib::ControlFlow::Continue- continue calling this handler glib::timeout_add_seconds(5, move || { // Here we temporarily retrieve a strong reference on the pipeline from the weak one // we moved into this callback. let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; println!("sending eos"); @@ -77,7 +77,7 @@ fn example_main() { // Remove this handler, the pipeline will shutdown anyway, now that we // sent the EOS event. - glib::Continue(false) + glib::ControlFlow::Break }); //bus.add_signal_watch(); @@ -85,7 +85,7 @@ fn example_main() { let main_loop_clone = main_loop.clone(); // This sets the bus's signal handler (don't be mislead by the "add", there can only be one). // Every message from the bus is passed through this function. Its returnvalue determines - // whether the handler wants to be called again. If glib::Continue(false) is returned, the + // whether the handler wants to be called again. If glib::ControlFlow::Break is returned, the // handler is removed and will never be called again. The mainloop still runs though. let _bus_watch = bus .add_watch(move |_, msg| { @@ -112,7 +112,7 @@ fn example_main() { }; // Tell the mainloop to continue executing this callback. - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); diff --git a/examples/src/bin/gtksink.rs b/examples/src/bin/gtksink.rs index 69f04d222..317bac92c 100644 --- a/examples/src/bin/gtksink.rs +++ b/examples/src/bin/gtksink.rs @@ -85,7 +85,7 @@ fn create_ui(app: >k::Application) { // we moved into this callback. let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(true), + None => return glib::ControlFlow::Continue, }; // Query the current playing position from the underlying pipeline. @@ -93,7 +93,7 @@ fn create_ui(app: >k::Application) { // Display the playing position in the gui. label.set_text(&format!("Position: {:.0}", position.display())); // Tell the callback to continue calling this closure. - glib::Continue(true) + glib::ControlFlow::Continue }); let bus = pipeline.bus().unwrap(); @@ -109,7 +109,7 @@ fn create_ui(app: >k::Application) { let app = match app_weak.upgrade() { Some(app) => app, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; match msg.view() { @@ -126,7 +126,7 @@ fn create_ui(app: >k::Application) { _ => (), }; - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); diff --git a/examples/src/bin/gtkvideooverlay.rs b/examples/src/bin/gtkvideooverlay.rs index a27aa4145..191561ba2 100644 --- a/examples/src/bin/gtkvideooverlay.rs +++ b/examples/src/bin/gtkvideooverlay.rs @@ -186,7 +186,7 @@ fn create_ui(app: >k::Application) { // we moved into this callback. let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; // Query the current playing position from the underlying pipeline. @@ -194,7 +194,7 @@ fn create_ui(app: >k::Application) { // Display the playing position in the gui. label.set_text(&format!("Position: {:.0}", position.display())); // Tell the timeout to continue calling this callback. - glib::Continue(true) + glib::ControlFlow::Continue }); let bus = pipeline.bus().unwrap(); @@ -210,7 +210,7 @@ fn create_ui(app: >k::Application) { let app = match app_weak.upgrade() { Some(app) => app, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; match msg.view() { @@ -227,7 +227,7 @@ fn create_ui(app: >k::Application) { _ => (), }; - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); diff --git a/examples/src/bin/launch_glib_main.rs b/examples/src/bin/launch_glib_main.rs index 71c20b1c7..55859b96d 100644 --- a/examples/src/bin/launch_glib_main.rs +++ b/examples/src/bin/launch_glib_main.rs @@ -54,7 +54,7 @@ fn example_main() { _ => (), }; - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); diff --git a/examples/src/bin/queries.rs b/examples/src/bin/queries.rs index dce7c48d0..02eec3cd0 100644 --- a/examples/src/bin/queries.rs +++ b/examples/src/bin/queries.rs @@ -52,7 +52,7 @@ fn example_main() { // we moved into this callback. let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(true), + None => return glib::ControlFlow::Continue, }; //let pos = pipeline.query_position(gst::Format::Time).unwrap_or(-1); @@ -87,7 +87,7 @@ fn example_main() { println!("{} / {}", pos.display(), dur.display()); - glib::Continue(true) + glib::ControlFlow::Continue }); // Need to move a new reference into the closure. @@ -113,7 +113,7 @@ fn example_main() { _ => (), }; - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); diff --git a/gstreamer-net/src/ptp_clock.rs b/gstreamer-net/src/ptp_clock.rs index 61ef7246a..eb67c1551 100644 --- a/gstreamer-net/src/ptp_clock.rs +++ b/gstreamer-net/src/ptp_clock.rs @@ -57,13 +57,13 @@ impl PtpClock { /// Add a PTP clock statistics callback #[doc(alias = "gst_ptp_statistics_callback_add")] pub fn add_statistics_callback< - F: Fn(u8, &gst::StructureRef) -> glib::Continue + 'static + Send + Sync, + F: Fn(u8, &gst::StructureRef) -> glib::ControlFlow + 'static + Send + Sync, >( func: F, ) -> PtpStatisticsCallback { unsafe { unsafe extern "C" fn trampoline< - F: Fn(u8, &gst::StructureRef) -> glib::Continue + 'static + Send + Sync, + F: Fn(u8, &gst::StructureRef) -> glib::ControlFlow + 'static + Send + Sync, >( domain: u8, stats: *const gst::ffi::GstStructure, @@ -74,7 +74,7 @@ impl PtpClock { } unsafe extern "C" fn destroy< - F: Fn(u8, &gst::StructureRef) -> glib::Continue + 'static + Send + Sync, + F: Fn(u8, &gst::StructureRef) -> glib::ControlFlow + 'static + Send + Sync, >( user_data: glib::ffi::gpointer, ) { diff --git a/gstreamer-rtsp-server/src/rtsp_session_pool.rs b/gstreamer-rtsp-server/src/rtsp_session_pool.rs index 52b9fe4ab..49814354f 100644 --- a/gstreamer-rtsp-server/src/rtsp_session_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_session_pool.rs @@ -5,13 +5,15 @@ use std::mem::transmute; use glib::{ ffi::{gboolean, gpointer}, prelude::*, - source::{Continue, Priority}, + source::{ControlFlow, Priority}, translate::*, }; use crate::RTSPSessionPool; -unsafe extern "C" fn trampoline_watch Continue + Send + 'static>( +unsafe extern "C" fn trampoline_watch< + F: FnMut(&RTSPSessionPool) -> ControlFlow + Send + 'static, +>( pool: *mut ffi::GstRTSPSessionPool, func: gpointer, ) -> gboolean { @@ -20,14 +22,14 @@ unsafe extern "C" fn trampoline_watch Continue + S } unsafe extern "C" fn destroy_closure_watch< - F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static, + F: FnMut(&RTSPSessionPool) -> ControlFlow + Send + 'static, >( ptr: gpointer, ) { let _ = Box::::from_raw(ptr as *mut _); } -fn into_raw_watch Continue + Send + 'static>(func: F) -> gpointer { +fn into_raw_watch ControlFlow + Send + 'static>(func: F) -> gpointer { #[allow(clippy::type_complexity)] let func: Box = Box::new(func); Box::into_raw(func) as gpointer @@ -42,7 +44,7 @@ pub trait RTSPSessionPoolExtManual: sealed::Sealed + IsA + 'sta #[doc(alias = "gst_rtsp_session_pool_create_watch")] fn create_watch(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source where - F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static, + F: FnMut(&RTSPSessionPool) -> ControlFlow + Send + 'static, { skip_assert_initialized!(); unsafe { diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 8b92c6d56..542eda190 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -13,13 +13,13 @@ use futures_util::{stream::FusedStream, StreamExt}; use glib::{ ffi::{gboolean, gpointer}, prelude::*, - source::{Continue, Priority}, + source::{ControlFlow, Priority}, translate::*, }; use crate::{Bus, BusSyncReply, Message, MessageType}; -unsafe extern "C" fn trampoline_watch Continue + Send + 'static>( +unsafe extern "C" fn trampoline_watch ControlFlow + Send + 'static>( bus: *mut ffi::GstBus, msg: *mut ffi::GstMessage, func: gpointer, @@ -29,20 +29,20 @@ unsafe extern "C" fn trampoline_watch Continue + Sen } unsafe extern "C" fn destroy_closure_watch< - F: FnMut(&Bus, &Message) -> Continue + Send + 'static, + F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static, >( ptr: gpointer, ) { let _ = Box::::from_raw(ptr as *mut _); } -fn into_raw_watch Continue + Send + 'static>(func: F) -> gpointer { +fn into_raw_watch ControlFlow + Send + 'static>(func: F) -> gpointer { #[allow(clippy::type_complexity)] let func: Box = Box::new(func); Box::into_raw(func) as gpointer } -unsafe extern "C" fn trampoline_watch_local Continue + 'static>( +unsafe extern "C" fn trampoline_watch_local ControlFlow + 'static>( bus: *mut ffi::GstBus, msg: *mut ffi::GstMessage, func: gpointer, @@ -52,13 +52,15 @@ unsafe extern "C" fn trampoline_watch_local Continue (func.get_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).into_glib() } -unsafe extern "C" fn destroy_closure_watch_local Continue + 'static>( +unsafe extern "C" fn destroy_closure_watch_local< + F: FnMut(&Bus, &Message) -> ControlFlow + 'static, +>( ptr: gpointer, ) { let _ = Box::>::from_raw(ptr as *mut _); } -fn into_raw_watch_local Continue + 'static>(func: F) -> gpointer { +fn into_raw_watch_local ControlFlow + 'static>(func: F) -> gpointer { #[allow(clippy::type_complexity)] let func: Box> = Box::new(glib::thread_guard::ThreadGuard::new(func)); @@ -109,7 +111,7 @@ impl Bus { #[doc(alias = "gst_bus_create_watch")] pub fn create_watch(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source where - F: FnMut(&Bus, &Message) -> Continue + Send + 'static, + F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static, { skip_assert_initialized!(); unsafe { @@ -137,7 +139,7 @@ impl Bus { #[doc(alias = "gst_bus_add_watch_full")] pub fn add_watch(&self, func: F) -> Result where - F: FnMut(&Bus, &Message) -> Continue + Send + 'static, + F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static, { unsafe { let res = ffi::gst_bus_add_watch_full( @@ -160,7 +162,7 @@ impl Bus { #[doc(alias = "gst_bus_add_watch_full")] pub fn add_watch_local(&self, func: F) -> Result where - F: FnMut(&Bus, &Message) -> Continue + 'static, + F: FnMut(&Bus, &Message) -> ControlFlow + 'static, { unsafe { let ctx = glib::MainContext::ref_thread_default(); diff --git a/tutorials/src/bin/basic-tutorial-12.rs b/tutorials/src/bin/basic-tutorial-12.rs index d781fd87b..7f768c19e 100644 --- a/tutorials/src/bin/basic-tutorial-12.rs +++ b/tutorials/src/bin/basic-tutorial-12.rs @@ -27,7 +27,7 @@ fn tutorial_main() -> Result<(), Error> { .add_watch(move |_, msg| { let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(true), + None => return glib::ControlFlow::Continue, }; let main_loop = &main_loop_clone; match msg.view() { @@ -49,7 +49,7 @@ fn tutorial_main() -> Result<(), Error> { gst::MessageView::Buffering(buffering) => { // If the stream is live, we do not care about buffering if is_live { - return glib::Continue(true); + return glib::ControlFlow::Continue; } let percent = buffering.percent(); @@ -73,7 +73,7 @@ fn tutorial_main() -> Result<(), Error> { } _ => (), } - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); diff --git a/tutorials/src/bin/basic-tutorial-13.rs b/tutorials/src/bin/basic-tutorial-13.rs index 6a4c392ae..fc70562d0 100644 --- a/tutorials/src/bin/basic-tutorial-13.rs +++ b/tutorials/src/bin/basic-tutorial-13.rs @@ -139,7 +139,7 @@ USAGE: Choose one of the following options, then press enter: ready_rx.attach(Some(&main_loop.context()), move |command: Command| { let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(true), + None => return glib::ControlFlow::Continue, }; match command { Command::PlayPause => { @@ -180,7 +180,7 @@ USAGE: Choose one of the following options, then press enter: main_loop_clone.quit(); } } - glib::Continue(true) + glib::ControlFlow::Continue }); main_loop.run(); diff --git a/tutorials/src/bin/basic-tutorial-5.rs b/tutorials/src/bin/basic-tutorial-5.rs index 0e574ff51..d872bc91d 100644 --- a/tutorials/src/bin/basic-tutorial-5.rs +++ b/tutorials/src/bin/basic-tutorial-5.rs @@ -145,7 +145,7 @@ mod tutorial5 { } } - Continue(true) + glib::ControlFlow::Continue }); let controls = gtk::Box::new(gtk::Orientation::Horizontal, 0); diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index 8ce126af3..741480c30 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -178,7 +178,7 @@ fn main() { d.source_id = Some(glib::source::idle_add(move || { let data = match data_weak.upgrade() { Some(data) => data, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; let (appsrc, buffer) = { @@ -219,7 +219,7 @@ fn main() { (data.appsrc.clone(), buffer) }; - glib::Continue(appsrc.push_buffer(buffer).is_ok()) + glib::ControlFlow::from(appsrc.push_buffer(buffer).is_ok()) })); } }) diff --git a/tutorials/src/bin/playback-tutorial-1.rs b/tutorials/src/bin/playback-tutorial-1.rs index 997c82ed9..c518523bf 100644 --- a/tutorials/src/bin/playback-tutorial-1.rs +++ b/tutorials/src/bin/playback-tutorial-1.rs @@ -146,7 +146,7 @@ fn tutorial_main() -> Result<(), Error> { ); eprintln!("Debugging information: {:?}", err.debug()); main_loop_clone.quit(); - Continue(false) + glib::ControlFlow::Break } MessageView::StateChanged(state_changed) => { if state_changed @@ -157,14 +157,14 @@ fn tutorial_main() -> Result<(), Error> { { analyze_streams(&playbin_clone); } - Continue(true) + glib::ControlFlow::Continue } MessageView::Eos(..) => { println!("Reached end of stream"); main_loop_clone.quit(); - Continue(false) + glib::ControlFlow::Break } - _ => Continue(true), + _ => glib::ControlFlow::Continue, } })?; diff --git a/tutorials/src/bin/playback-tutorial-2.rs b/tutorials/src/bin/playback-tutorial-2.rs index 28c8feec8..5f6e9f9b3 100644 --- a/tutorials/src/bin/playback-tutorial-2.rs +++ b/tutorials/src/bin/playback-tutorial-2.rs @@ -151,7 +151,7 @@ fn tutorial_main() -> Result<(), Error> { ); eprintln!("Debugging information: {:?}", err.debug()); main_loop_clone.quit(); - Continue(false) + glib::ControlFlow::Break } MessageView::StateChanged(state_changed) => { if state_changed @@ -162,14 +162,14 @@ fn tutorial_main() -> Result<(), Error> { { analyze_streams(&playbin_clone); } - Continue(true) + glib::ControlFlow::Continue } MessageView::Eos(..) => { println!("Reached end of stream"); main_loop_clone.quit(); - Continue(false) + glib::ControlFlow::Break } - _ => Continue(true), + _ => glib::ControlFlow::Continue, } })?; diff --git a/tutorials/src/bin/playback-tutorial-3.rs b/tutorials/src/bin/playback-tutorial-3.rs index 21155092a..1273e722a 100644 --- a/tutorials/src/bin/playback-tutorial-3.rs +++ b/tutorials/src/bin/playback-tutorial-3.rs @@ -84,7 +84,7 @@ fn tutorial_main() -> Result<(), Error> { d.source_id = Some(glib::source::idle_add(move || { let data = match data_weak.upgrade() { Some(data) => data, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; let (appsrc, buffer) = { @@ -128,7 +128,7 @@ fn tutorial_main() -> Result<(), Error> { }; // Push the buffer into the appsrc - glib::Continue(appsrc.push_buffer(buffer).is_ok()) + glib::ControlFlow::from(appsrc.push_buffer(buffer).is_ok()) })); } }) diff --git a/tutorials/src/bin/playback-tutorial-4.rs b/tutorials/src/bin/playback-tutorial-4.rs index e0dca8bd3..ce0d0e839 100644 --- a/tutorials/src/bin/playback-tutorial-4.rs +++ b/tutorials/src/bin/playback-tutorial-4.rs @@ -59,7 +59,7 @@ fn tutorial_main() -> Result<(), Error> { let buffering_level = &buffering_level_clone; let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; let main_loop = &main_loop_clone; match msg.view() { @@ -78,7 +78,7 @@ fn tutorial_main() -> Result<(), Error> { MessageView::Buffering(buffering) => { // If the stream is live, we do not care about buffering. if is_live { - return glib::Continue(true); + return glib::ControlFlow::Continue; } // Wait until buffering is complete before start/resume playing. @@ -98,7 +98,7 @@ fn tutorial_main() -> Result<(), Error> { _ => (), }; - glib::Continue(true) + glib::ControlFlow::Continue }) .expect("Failed to add bus watch"); @@ -119,7 +119,7 @@ fn tutorial_main() -> Result<(), Error> { let pipeline = match pipeline_weak_.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(false), + None => return glib::ControlFlow::Break, }; let mut graph = vec![b' '; GRAPH_LENGTH]; let mut buffering = gst::query::Buffering::new(gst::Format::Percent); @@ -170,7 +170,7 @@ fn tutorial_main() -> Result<(), Error> { std::io::stdout().flush().unwrap(); - glib::Continue(true) + glib::ControlFlow::Continue }); main_loop.run(); diff --git a/tutorials/src/bin/playback-tutorial-5.rs b/tutorials/src/bin/playback-tutorial-5.rs index 8588ccff0..ebb322169 100644 --- a/tutorials/src/bin/playback-tutorial-5.rs +++ b/tutorials/src/bin/playback-tutorial-5.rs @@ -123,7 +123,7 @@ fn tutorial_main() -> Result<(), Error> { ready_rx.attach(Some(&main_loop.context()), move |command: Command| { let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(true), + None => return glib::ControlFlow::Continue, }; match command { @@ -138,7 +138,7 @@ fn tutorial_main() -> Result<(), Error> { main_loop_clone.quit(); } } - glib::Continue(true) + glib::ControlFlow::Continue }); // Handle bus errors / EOS correctly @@ -150,7 +150,7 @@ fn tutorial_main() -> Result<(), Error> { let pipeline = match pipeline_weak.upgrade() { Some(pipeline) => pipeline, - None => return glib::Continue(true), + None => return glib::ControlFlow::Continue, }; match message.view() { @@ -162,7 +162,7 @@ fn tutorial_main() -> Result<(), Error> { ); eprintln!("Debugging information: {:?}", err.debug()); main_loop_clone.quit(); - Continue(false) + glib::ControlFlow::Break } MessageView::Eos(..) => { println!("Reached end of stream"); @@ -170,9 +170,9 @@ fn tutorial_main() -> Result<(), Error> { .set_state(gst::State::Ready) .expect("Unable to set the pipeline to the `Ready` state"); main_loop_clone.quit(); - Continue(false) + glib::ControlFlow::Break } - _ => Continue(true), + _ => glib::ControlFlow::Continue, } })?;