No need to check for gst::init

This commit is contained in:
Vladimir Romashchenko 2024-09-19 21:28:42 -04:00
parent 4400f3a7a1
commit 5d3340dd51
No known key found for this signature in database
GPG key ID: E5B7EA4A9E1D48F4

View file

@ -121,10 +121,7 @@ impl Video {
/// Expects an appsink plugin to be present with name set to `iced_video` and caps to /// Expects an appsink plugin to be present with name set to `iced_video` and caps to
/// `video/x-raw,format=RGBA,pixel-aspect-ratio=1/1` /// `video/x-raw,format=RGBA,pixel-aspect-ratio=1/1`
pub fn from_pipeline<S: AsRef<str>>(pipeline: S, is_live: Option<bool>) -> Result<Self, Error> { pub fn from_pipeline<S: AsRef<str>>(pipeline: S, is_live: Option<bool>) -> Result<Self, Error> {
if !gst::INITIALIZED.load(Ordering::SeqCst) { gst::init()?;
gst::init()?;
}
let pipeline = gst::parse::launch(pipeline.as_ref())? let pipeline = gst::parse::launch(pipeline.as_ref())?
.downcast::<gst::Pipeline>() .downcast::<gst::Pipeline>()
.map_err(|_| Error::Cast)?; .map_err(|_| Error::Cast)?;
@ -139,11 +136,9 @@ impl Video {
pipeline: gst::Pipeline, pipeline: gst::Pipeline,
is_live: Option<bool>, is_live: Option<bool>,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
gst::init()?;
static NEXT_ID: AtomicU64 = AtomicU64::new(0); static NEXT_ID: AtomicU64 = AtomicU64::new(0);
let id = NEXT_ID.fetch_add(1, Ordering::SeqCst); let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
if !gst::INITIALIZED.load(Ordering::SeqCst) {
gst::init()?;
}
let mut live = false; let mut live = false;