openh264: Don't use GOnce for ABI check
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Thu, 13 May 2021 19:18:34 +0000 (15:18 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 13 May 2021 21:40:02 +0000 (21:40 +0000)
It turns out the value used for g_once_* APIs can't be
zero. And this is a very cheap check, so let's just do it every time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2240>

ext/openh264/gstopenh264element.c

index 5d8f9d3..3c5c378 100644 (file)
 gboolean
 openh264_element_init (GstPlugin * plugin)
 {
-  static gsize res = FALSE;
-
-  if (g_once_init_enter (&res)) {
-    gsize value;
-    OpenH264Version libver;
-    /* g_stCodecVersion is the version detected at build time as defined in the
-     * headers and WelsGetCodecVersion() is the version detected at runtime.
-     * This is a safeguard to avoid crashes since OpenH264  has been changing
-     * ABI without changing the SONAME.
-     */
-    libver = WelsGetCodecVersion ();
-    value = memcmp (&libver, &g_stCodecVersion, sizeof (libver)) == 0;
-    g_once_init_leave (&res, value);
-  }
-
-  return res;
+  OpenH264Version libver;
+  /* g_stCodecVersion is the version detected at build time as defined in the
+   * headers and WelsGetCodecVersion() is the version detected at runtime.
+   * This is a safeguard to avoid crashes since OpenH264  has been changing
+   * ABI without changing the SONAME.
+   */
+  libver = WelsGetCodecVersion ();
+  return (memcmp (&libver, &g_stCodecVersion, sizeof (libver)) == 0);
 }