Adapt to glib::Continue rename

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1293>
This commit is contained in:
Bilal Elmoussaoui 2023-07-06 15:15:14 +02:00 committed by Sebastian Dröge
parent 7cf66dbc61
commit b156ba2c59
19 changed files with 74 additions and 70 deletions

View file

@ -115,7 +115,7 @@ fn example_main() {
// we moved into this callback. // we moved into this callback.
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, 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}"); println!("Sending custom event to the pipeline with send_eos={send_eos}");
let ev = ExampleCustomEvent::new(*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 // Remove this handler, the pipeline will shutdown once our pad probe catches the custom
// event and sends EOS // event and sends EOS
glib::Continue(false) glib::ControlFlow::Break
}); });
} }
let main_loop_clone = main_loop.clone(); 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). // 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 // 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. // handler is removed and will never be called again. The mainloop still runs though.
let _bus_watch = bus let _bus_watch = bus
.add_watch(move |_, msg| { .add_watch(move |_, msg| {
@ -158,7 +158,7 @@ fn example_main() {
}; };
// Tell the mainloop to continue executing this callback. // Tell the mainloop to continue executing this callback.
glib::Continue(true) glib::ControlFlow::Continue
}) })
.expect("Failed to add bus watch"); .expect("Failed to add bus watch");

View file

@ -351,7 +351,7 @@ fn main() -> Result<()> {
_ => (), _ => (),
}; };
glib::Continue(true) glib::ControlFlow::Continue
}) })
.unwrap(); .unwrap();

View file

@ -50,14 +50,14 @@ fn example_main() {
// Add a timeout to the main loop. This closure will be executed // 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 // in an interval of 5 seconds. The return value of the handler function
// determines whether the handler still wants to be called: // determines whether the handler still wants to be called:
// - glib::Continue(false) - stop calling this handler, remove timeout // - glib::ControlFlow::Break - stop calling this handler, remove timeout
// - glib::Continue(true) - continue calling this handler // - glib::ControlFlow::Continue- continue calling this handler
glib::timeout_add_seconds(5, move || { glib::timeout_add_seconds(5, move || {
// Here we temporarily retrieve a strong reference on the pipeline from the weak one // Here we temporarily retrieve a strong reference on the pipeline from the weak one
// we moved into this callback. // we moved into this callback.
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
println!("sending eos"); println!("sending eos");
@ -77,7 +77,7 @@ fn example_main() {
// Remove this handler, the pipeline will shutdown anyway, now that we // Remove this handler, the pipeline will shutdown anyway, now that we
// sent the EOS event. // sent the EOS event.
glib::Continue(false) glib::ControlFlow::Break
}); });
//bus.add_signal_watch(); //bus.add_signal_watch();
@ -85,7 +85,7 @@ fn example_main() {
let main_loop_clone = main_loop.clone(); 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). // 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 // 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. // handler is removed and will never be called again. The mainloop still runs though.
let _bus_watch = bus let _bus_watch = bus
.add_watch(move |_, msg| { .add_watch(move |_, msg| {
@ -112,7 +112,7 @@ fn example_main() {
}; };
// Tell the mainloop to continue executing this callback. // Tell the mainloop to continue executing this callback.
glib::Continue(true) glib::ControlFlow::Continue
}) })
.expect("Failed to add bus watch"); .expect("Failed to add bus watch");

View file

@ -85,7 +85,7 @@ fn create_ui(app: &gtk::Application) {
// we moved into this callback. // we moved into this callback.
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(true), None => return glib::ControlFlow::Continue,
}; };
// Query the current playing position from the underlying pipeline. // Query the current playing position from the underlying pipeline.
@ -93,7 +93,7 @@ fn create_ui(app: &gtk::Application) {
// Display the playing position in the gui. // Display the playing position in the gui.
label.set_text(&format!("Position: {:.0}", position.display())); label.set_text(&format!("Position: {:.0}", position.display()));
// Tell the callback to continue calling this closure. // Tell the callback to continue calling this closure.
glib::Continue(true) glib::ControlFlow::Continue
}); });
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
@ -109,7 +109,7 @@ fn create_ui(app: &gtk::Application) {
let app = match app_weak.upgrade() { let app = match app_weak.upgrade() {
Some(app) => app, Some(app) => app,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
match msg.view() { match msg.view() {
@ -126,7 +126,7 @@ fn create_ui(app: &gtk::Application) {
_ => (), _ => (),
}; };
glib::Continue(true) glib::ControlFlow::Continue
}) })
.expect("Failed to add bus watch"); .expect("Failed to add bus watch");

View file

@ -186,7 +186,7 @@ fn create_ui(app: &gtk::Application) {
// we moved into this callback. // we moved into this callback.
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
// Query the current playing position from the underlying pipeline. // Query the current playing position from the underlying pipeline.
@ -194,7 +194,7 @@ fn create_ui(app: &gtk::Application) {
// Display the playing position in the gui. // Display the playing position in the gui.
label.set_text(&format!("Position: {:.0}", position.display())); label.set_text(&format!("Position: {:.0}", position.display()));
// Tell the timeout to continue calling this callback. // Tell the timeout to continue calling this callback.
glib::Continue(true) glib::ControlFlow::Continue
}); });
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
@ -210,7 +210,7 @@ fn create_ui(app: &gtk::Application) {
let app = match app_weak.upgrade() { let app = match app_weak.upgrade() {
Some(app) => app, Some(app) => app,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
match msg.view() { match msg.view() {
@ -227,7 +227,7 @@ fn create_ui(app: &gtk::Application) {
_ => (), _ => (),
}; };
glib::Continue(true) glib::ControlFlow::Continue
}) })
.expect("Failed to add bus watch"); .expect("Failed to add bus watch");

View file

@ -54,7 +54,7 @@ fn example_main() {
_ => (), _ => (),
}; };
glib::Continue(true) glib::ControlFlow::Continue
}) })
.expect("Failed to add bus watch"); .expect("Failed to add bus watch");

View file

@ -52,7 +52,7 @@ fn example_main() {
// we moved into this callback. // we moved into this callback.
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(true), None => return glib::ControlFlow::Continue,
}; };
//let pos = pipeline.query_position(gst::Format::Time).unwrap_or(-1); //let pos = pipeline.query_position(gst::Format::Time).unwrap_or(-1);
@ -87,7 +87,7 @@ fn example_main() {
println!("{} / {}", pos.display(), dur.display()); println!("{} / {}", pos.display(), dur.display());
glib::Continue(true) glib::ControlFlow::Continue
}); });
// Need to move a new reference into the closure. // 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"); .expect("Failed to add bus watch");

View file

@ -57,13 +57,13 @@ impl PtpClock {
/// Add a PTP clock statistics callback /// Add a PTP clock statistics callback
#[doc(alias = "gst_ptp_statistics_callback_add")] #[doc(alias = "gst_ptp_statistics_callback_add")]
pub fn add_statistics_callback< 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, func: F,
) -> PtpStatisticsCallback { ) -> PtpStatisticsCallback {
unsafe { unsafe {
unsafe extern "C" fn trampoline< 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, domain: u8,
stats: *const gst::ffi::GstStructure, stats: *const gst::ffi::GstStructure,
@ -74,7 +74,7 @@ impl PtpClock {
} }
unsafe extern "C" fn destroy< 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, user_data: glib::ffi::gpointer,
) { ) {

View file

@ -5,13 +5,15 @@ use std::mem::transmute;
use glib::{ use glib::{
ffi::{gboolean, gpointer}, ffi::{gboolean, gpointer},
prelude::*, prelude::*,
source::{Continue, Priority}, source::{ControlFlow, Priority},
translate::*, translate::*,
}; };
use crate::RTSPSessionPool; use crate::RTSPSessionPool;
unsafe extern "C" fn trampoline_watch<F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static>( unsafe extern "C" fn trampoline_watch<
F: FnMut(&RTSPSessionPool) -> ControlFlow + Send + 'static,
>(
pool: *mut ffi::GstRTSPSessionPool, pool: *mut ffi::GstRTSPSessionPool,
func: gpointer, func: gpointer,
) -> gboolean { ) -> gboolean {
@ -20,14 +22,14 @@ unsafe extern "C" fn trampoline_watch<F: FnMut(&RTSPSessionPool) -> Continue + S
} }
unsafe extern "C" fn destroy_closure_watch< unsafe extern "C" fn destroy_closure_watch<
F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static, F: FnMut(&RTSPSessionPool) -> ControlFlow + Send + 'static,
>( >(
ptr: gpointer, ptr: gpointer,
) { ) {
let _ = Box::<F>::from_raw(ptr as *mut _); let _ = Box::<F>::from_raw(ptr as *mut _);
} }
fn into_raw_watch<F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static>(func: F) -> gpointer { fn into_raw_watch<F: FnMut(&RTSPSessionPool) -> ControlFlow + Send + 'static>(func: F) -> gpointer {
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
let func: Box<F> = Box::new(func); let func: Box<F> = Box::new(func);
Box::into_raw(func) as gpointer Box::into_raw(func) as gpointer
@ -42,7 +44,7 @@ pub trait RTSPSessionPoolExtManual: sealed::Sealed + IsA<RTSPSessionPool> + 'sta
#[doc(alias = "gst_rtsp_session_pool_create_watch")] #[doc(alias = "gst_rtsp_session_pool_create_watch")]
fn create_watch<F>(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source fn create_watch<F>(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source
where where
F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static, F: FnMut(&RTSPSessionPool) -> ControlFlow + Send + 'static,
{ {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {

View file

@ -13,13 +13,13 @@ use futures_util::{stream::FusedStream, StreamExt};
use glib::{ use glib::{
ffi::{gboolean, gpointer}, ffi::{gboolean, gpointer},
prelude::*, prelude::*,
source::{Continue, Priority}, source::{ControlFlow, Priority},
translate::*, translate::*,
}; };
use crate::{Bus, BusSyncReply, Message, MessageType}; use crate::{Bus, BusSyncReply, Message, MessageType};
unsafe extern "C" fn trampoline_watch<F: FnMut(&Bus, &Message) -> Continue + Send + 'static>( unsafe extern "C" fn trampoline_watch<F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static>(
bus: *mut ffi::GstBus, bus: *mut ffi::GstBus,
msg: *mut ffi::GstMessage, msg: *mut ffi::GstMessage,
func: gpointer, func: gpointer,
@ -29,20 +29,20 @@ unsafe extern "C" fn trampoline_watch<F: FnMut(&Bus, &Message) -> Continue + Sen
} }
unsafe extern "C" fn destroy_closure_watch< unsafe extern "C" fn destroy_closure_watch<
F: FnMut(&Bus, &Message) -> Continue + Send + 'static, F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static,
>( >(
ptr: gpointer, ptr: gpointer,
) { ) {
let _ = Box::<F>::from_raw(ptr as *mut _); let _ = Box::<F>::from_raw(ptr as *mut _);
} }
fn into_raw_watch<F: FnMut(&Bus, &Message) -> Continue + Send + 'static>(func: F) -> gpointer { fn into_raw_watch<F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static>(func: F) -> gpointer {
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
let func: Box<F> = Box::new(func); let func: Box<F> = Box::new(func);
Box::into_raw(func) as gpointer Box::into_raw(func) as gpointer
} }
unsafe extern "C" fn trampoline_watch_local<F: FnMut(&Bus, &Message) -> Continue + 'static>( unsafe extern "C" fn trampoline_watch_local<F: FnMut(&Bus, &Message) -> ControlFlow + 'static>(
bus: *mut ffi::GstBus, bus: *mut ffi::GstBus,
msg: *mut ffi::GstMessage, msg: *mut ffi::GstMessage,
func: gpointer, func: gpointer,
@ -52,13 +52,15 @@ unsafe extern "C" fn trampoline_watch_local<F: FnMut(&Bus, &Message) -> Continue
(func.get_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).into_glib() (func.get_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).into_glib()
} }
unsafe extern "C" fn destroy_closure_watch_local<F: FnMut(&Bus, &Message) -> Continue + 'static>( unsafe extern "C" fn destroy_closure_watch_local<
F: FnMut(&Bus, &Message) -> ControlFlow + 'static,
>(
ptr: gpointer, ptr: gpointer,
) { ) {
let _ = Box::<glib::thread_guard::ThreadGuard<F>>::from_raw(ptr as *mut _); let _ = Box::<glib::thread_guard::ThreadGuard<F>>::from_raw(ptr as *mut _);
} }
fn into_raw_watch_local<F: FnMut(&Bus, &Message) -> Continue + 'static>(func: F) -> gpointer { fn into_raw_watch_local<F: FnMut(&Bus, &Message) -> ControlFlow + 'static>(func: F) -> gpointer {
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
let func: Box<glib::thread_guard::ThreadGuard<F>> = let func: Box<glib::thread_guard::ThreadGuard<F>> =
Box::new(glib::thread_guard::ThreadGuard::new(func)); Box::new(glib::thread_guard::ThreadGuard::new(func));
@ -109,7 +111,7 @@ impl Bus {
#[doc(alias = "gst_bus_create_watch")] #[doc(alias = "gst_bus_create_watch")]
pub fn create_watch<F>(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source pub fn create_watch<F>(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source
where where
F: FnMut(&Bus, &Message) -> Continue + Send + 'static, F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static,
{ {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
@ -137,7 +139,7 @@ impl Bus {
#[doc(alias = "gst_bus_add_watch_full")] #[doc(alias = "gst_bus_add_watch_full")]
pub fn add_watch<F>(&self, func: F) -> Result<BusWatchGuard, glib::BoolError> pub fn add_watch<F>(&self, func: F) -> Result<BusWatchGuard, glib::BoolError>
where where
F: FnMut(&Bus, &Message) -> Continue + Send + 'static, F: FnMut(&Bus, &Message) -> ControlFlow + Send + 'static,
{ {
unsafe { unsafe {
let res = ffi::gst_bus_add_watch_full( let res = ffi::gst_bus_add_watch_full(
@ -160,7 +162,7 @@ impl Bus {
#[doc(alias = "gst_bus_add_watch_full")] #[doc(alias = "gst_bus_add_watch_full")]
pub fn add_watch_local<F>(&self, func: F) -> Result<BusWatchGuard, glib::BoolError> pub fn add_watch_local<F>(&self, func: F) -> Result<BusWatchGuard, glib::BoolError>
where where
F: FnMut(&Bus, &Message) -> Continue + 'static, F: FnMut(&Bus, &Message) -> ControlFlow + 'static,
{ {
unsafe { unsafe {
let ctx = glib::MainContext::ref_thread_default(); let ctx = glib::MainContext::ref_thread_default();

View file

@ -27,7 +27,7 @@ fn tutorial_main() -> Result<(), Error> {
.add_watch(move |_, msg| { .add_watch(move |_, msg| {
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(true), None => return glib::ControlFlow::Continue,
}; };
let main_loop = &main_loop_clone; let main_loop = &main_loop_clone;
match msg.view() { match msg.view() {
@ -49,7 +49,7 @@ fn tutorial_main() -> Result<(), Error> {
gst::MessageView::Buffering(buffering) => { gst::MessageView::Buffering(buffering) => {
// If the stream is live, we do not care about buffering // If the stream is live, we do not care about buffering
if is_live { if is_live {
return glib::Continue(true); return glib::ControlFlow::Continue;
} }
let percent = buffering.percent(); 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"); .expect("Failed to add bus watch");

View file

@ -139,7 +139,7 @@ USAGE: Choose one of the following options, then press enter:
ready_rx.attach(Some(&main_loop.context()), move |command: Command| { ready_rx.attach(Some(&main_loop.context()), move |command: Command| {
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(true), None => return glib::ControlFlow::Continue,
}; };
match command { match command {
Command::PlayPause => { Command::PlayPause => {
@ -180,7 +180,7 @@ USAGE: Choose one of the following options, then press enter:
main_loop_clone.quit(); main_loop_clone.quit();
} }
} }
glib::Continue(true) glib::ControlFlow::Continue
}); });
main_loop.run(); main_loop.run();

View file

@ -145,7 +145,7 @@ mod tutorial5 {
} }
} }
Continue(true) glib::ControlFlow::Continue
}); });
let controls = gtk::Box::new(gtk::Orientation::Horizontal, 0); let controls = gtk::Box::new(gtk::Orientation::Horizontal, 0);

View file

@ -178,7 +178,7 @@ fn main() {
d.source_id = Some(glib::source::idle_add(move || { d.source_id = Some(glib::source::idle_add(move || {
let data = match data_weak.upgrade() { let data = match data_weak.upgrade() {
Some(data) => data, Some(data) => data,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
let (appsrc, buffer) = { let (appsrc, buffer) = {
@ -219,7 +219,7 @@ fn main() {
(data.appsrc.clone(), buffer) (data.appsrc.clone(), buffer)
}; };
glib::Continue(appsrc.push_buffer(buffer).is_ok()) glib::ControlFlow::from(appsrc.push_buffer(buffer).is_ok())
})); }));
} }
}) })

View file

@ -146,7 +146,7 @@ fn tutorial_main() -> Result<(), Error> {
); );
eprintln!("Debugging information: {:?}", err.debug()); eprintln!("Debugging information: {:?}", err.debug());
main_loop_clone.quit(); main_loop_clone.quit();
Continue(false) glib::ControlFlow::Break
} }
MessageView::StateChanged(state_changed) => { MessageView::StateChanged(state_changed) => {
if state_changed if state_changed
@ -157,14 +157,14 @@ fn tutorial_main() -> Result<(), Error> {
{ {
analyze_streams(&playbin_clone); analyze_streams(&playbin_clone);
} }
Continue(true) glib::ControlFlow::Continue
} }
MessageView::Eos(..) => { MessageView::Eos(..) => {
println!("Reached end of stream"); println!("Reached end of stream");
main_loop_clone.quit(); main_loop_clone.quit();
Continue(false) glib::ControlFlow::Break
} }
_ => Continue(true), _ => glib::ControlFlow::Continue,
} }
})?; })?;

View file

@ -151,7 +151,7 @@ fn tutorial_main() -> Result<(), Error> {
); );
eprintln!("Debugging information: {:?}", err.debug()); eprintln!("Debugging information: {:?}", err.debug());
main_loop_clone.quit(); main_loop_clone.quit();
Continue(false) glib::ControlFlow::Break
} }
MessageView::StateChanged(state_changed) => { MessageView::StateChanged(state_changed) => {
if state_changed if state_changed
@ -162,14 +162,14 @@ fn tutorial_main() -> Result<(), Error> {
{ {
analyze_streams(&playbin_clone); analyze_streams(&playbin_clone);
} }
Continue(true) glib::ControlFlow::Continue
} }
MessageView::Eos(..) => { MessageView::Eos(..) => {
println!("Reached end of stream"); println!("Reached end of stream");
main_loop_clone.quit(); main_loop_clone.quit();
Continue(false) glib::ControlFlow::Break
} }
_ => Continue(true), _ => glib::ControlFlow::Continue,
} }
})?; })?;

View file

@ -84,7 +84,7 @@ fn tutorial_main() -> Result<(), Error> {
d.source_id = Some(glib::source::idle_add(move || { d.source_id = Some(glib::source::idle_add(move || {
let data = match data_weak.upgrade() { let data = match data_weak.upgrade() {
Some(data) => data, Some(data) => data,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
let (appsrc, buffer) = { let (appsrc, buffer) = {
@ -128,7 +128,7 @@ fn tutorial_main() -> Result<(), Error> {
}; };
// Push the buffer into the appsrc // Push the buffer into the appsrc
glib::Continue(appsrc.push_buffer(buffer).is_ok()) glib::ControlFlow::from(appsrc.push_buffer(buffer).is_ok())
})); }));
} }
}) })

View file

@ -59,7 +59,7 @@ fn tutorial_main() -> Result<(), Error> {
let buffering_level = &buffering_level_clone; let buffering_level = &buffering_level_clone;
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
let main_loop = &main_loop_clone; let main_loop = &main_loop_clone;
match msg.view() { match msg.view() {
@ -78,7 +78,7 @@ fn tutorial_main() -> Result<(), Error> {
MessageView::Buffering(buffering) => { MessageView::Buffering(buffering) => {
// If the stream is live, we do not care about buffering. // If the stream is live, we do not care about buffering.
if is_live { if is_live {
return glib::Continue(true); return glib::ControlFlow::Continue;
} }
// Wait until buffering is complete before start/resume playing. // 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"); .expect("Failed to add bus watch");
@ -119,7 +119,7 @@ fn tutorial_main() -> Result<(), Error> {
let pipeline = match pipeline_weak_.upgrade() { let pipeline = match pipeline_weak_.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(false), None => return glib::ControlFlow::Break,
}; };
let mut graph = vec![b' '; GRAPH_LENGTH]; let mut graph = vec![b' '; GRAPH_LENGTH];
let mut buffering = gst::query::Buffering::new(gst::Format::Percent); let mut buffering = gst::query::Buffering::new(gst::Format::Percent);
@ -170,7 +170,7 @@ fn tutorial_main() -> Result<(), Error> {
std::io::stdout().flush().unwrap(); std::io::stdout().flush().unwrap();
glib::Continue(true) glib::ControlFlow::Continue
}); });
main_loop.run(); main_loop.run();

View file

@ -123,7 +123,7 @@ fn tutorial_main() -> Result<(), Error> {
ready_rx.attach(Some(&main_loop.context()), move |command: Command| { ready_rx.attach(Some(&main_loop.context()), move |command: Command| {
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(true), None => return glib::ControlFlow::Continue,
}; };
match command { match command {
@ -138,7 +138,7 @@ fn tutorial_main() -> Result<(), Error> {
main_loop_clone.quit(); main_loop_clone.quit();
} }
} }
glib::Continue(true) glib::ControlFlow::Continue
}); });
// Handle bus errors / EOS correctly // Handle bus errors / EOS correctly
@ -150,7 +150,7 @@ fn tutorial_main() -> Result<(), Error> {
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(true), None => return glib::ControlFlow::Continue,
}; };
match message.view() { match message.view() {
@ -162,7 +162,7 @@ fn tutorial_main() -> Result<(), Error> {
); );
eprintln!("Debugging information: {:?}", err.debug()); eprintln!("Debugging information: {:?}", err.debug());
main_loop_clone.quit(); main_loop_clone.quit();
Continue(false) glib::ControlFlow::Break
} }
MessageView::Eos(..) => { MessageView::Eos(..) => {
println!("Reached end of stream"); println!("Reached end of stream");
@ -170,9 +170,9 @@ fn tutorial_main() -> Result<(), Error> {
.set_state(gst::State::Ready) .set_state(gst::State::Ready)
.expect("Unable to set the pipeline to the `Ready` state"); .expect("Unable to set the pipeline to the `Ready` state");
main_loop_clone.quit(); main_loop_clone.quit();
Continue(false) glib::ControlFlow::Break
} }
_ => Continue(true), _ => glib::ControlFlow::Continue,
} }
})?; })?;