From faa6463bdae12c33b77287639211d85ff2ec0745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 9 Feb 2021 16:13:26 +0200 Subject: [PATCH] gstreamer/clock: Move away from deprecated atomic API --- gstreamer/src/clock.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index dfb3ed02a..6eb8989b6 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -312,13 +312,21 @@ impl AtomicClockReturn { unsafe { from_glib(self.0.swap(val.to_glib(), atomic::Ordering::SeqCst)) } } - pub fn compare_and_swap(&self, current: ClockReturn, new: ClockReturn) -> ClockReturn { + pub fn compare_exchange( + &self, + current: ClockReturn, + new: ClockReturn, + ) -> Result { unsafe { - from_glib(self.0.compare_and_swap( - current.to_glib(), - new.to_glib(), - atomic::Ordering::SeqCst, - )) + self.0 + .compare_exchange( + current.to_glib(), + new.to_glib(), + atomic::Ordering::SeqCst, + atomic::Ordering::SeqCst, + ) + .map(|v| from_glib(v)) + .map_err(|v| from_glib(v)) } } }