mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-09 08:45:27 +00:00
gstreamer/promise: Convert None promise replies to an empty structure in the change_func
webrtcbin likes to put a NULL structure into the reply under some circumstances when the promise successfully resolved. See https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1300 for details.
This commit is contained in:
parent
8e96888c63
commit
c2acb000b1
1 changed files with 7 additions and 3 deletions
|
@ -52,15 +52,19 @@ impl Promise {
|
||||||
promise: *mut gst_sys::GstPromise,
|
promise: *mut gst_sys::GstPromise,
|
||||||
user_data: glib_sys::gpointer,
|
user_data: glib_sys::gpointer,
|
||||||
) {
|
) {
|
||||||
|
lazy_static! {
|
||||||
|
static ref EMPTY: Structure = Structure::new_empty("EMPTY");
|
||||||
|
}
|
||||||
|
|
||||||
let user_data: &mut Option<F> = &mut *(user_data as *mut _);
|
let user_data: &mut Option<F> = &mut *(user_data as *mut _);
|
||||||
let callback = user_data.take().unwrap();
|
let callback = user_data.take().unwrap();
|
||||||
|
|
||||||
let promise: Promise = from_glib_borrow(promise);
|
let promise: Promise = from_glib_borrow(promise);
|
||||||
|
|
||||||
let res = match promise.wait() {
|
let res = match promise.wait() {
|
||||||
PromiseResult::Replied => {
|
// Return an empty structure if it's None as workaround for
|
||||||
Ok(promise.get_reply().expect("Promise resolved but no reply"))
|
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1300
|
||||||
}
|
PromiseResult::Replied => Ok(promise.get_reply().unwrap_or(&EMPTY)),
|
||||||
PromiseResult::Interrupted => Err(PromiseError::Interrupted),
|
PromiseResult::Interrupted => Err(PromiseError::Interrupted),
|
||||||
PromiseResult::Expired => Err(PromiseError::Expired),
|
PromiseResult::Expired => Err(PromiseError::Expired),
|
||||||
PromiseResult::Pending => {
|
PromiseResult::Pending => {
|
||||||
|
|
Loading…
Reference in a new issue