openaptx: Support libfreeaptx
authorJan Alexander Steffens (heftig) <heftig@archlinux.org>
Tue, 8 Feb 2022 14:22:39 +0000 (15:22 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 15 Feb 2022 08:18:44 +0000 (08:18 +0000)
[libfreeaptx][1] is a fork of libopenapt 0.2.0, used by pipewire.

[1]: https://github.com/iamthehorker/libfreeaptx

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1642
Closes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1589
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1667>

subprojects/gst-plugins-bad/ext/openaptx/gstopenaptxdec.h
subprojects/gst-plugins-bad/ext/openaptx/gstopenaptxenc.h
subprojects/gst-plugins-bad/ext/openaptx/meson.build

index 95b126c..081b194 100644 (file)
 #include <gst/gst.h>
 #include <gst/audio/audio.h>
 
+#ifdef USE_FREEAPTX
+#include <freeaptx.h>
+#else
 #include <openaptx.h>
+#endif
 
 G_BEGIN_DECLS
 
index ab80b61..4cf7e17 100644 (file)
 #include <gst/gst.h>
 #include <gst/audio/audio.h>
 
+#ifdef USE_FREEAPTX
+#include <freeaptx.h>
+#else
 #include <openaptx.h>
+#endif
 
 G_BEGIN_DECLS
 
index e361ef3..4db8fdb 100644 (file)
@@ -4,12 +4,23 @@ openaptx_sources = [
   'gstopenaptxenc.c',
 ]
 
-openaptx_dep = dependency('libopenaptx', version : '== 0.2.0', required : get_option('openaptx'))
+if not get_option('openaptx').allowed()
+  subdir_done()
+endif
+
+openaptx_defines = []
+
+openaptx_dep = dependency('libfreeaptx', version : '>= 0.1.1', required : false)
+if openaptx_dep.found()
+  openaptx_defines += ['-DUSE_FREEAPTX']
+else
+  openaptx_dep = dependency('libopenaptx', version : '== 0.2.0', required : get_option('openaptx'))
+endif
 
 if openaptx_dep.found()
   gstopenaptx = library('gstopenaptx',
     openaptx_sources,
-    c_args : gst_plugins_bad_args,
+    c_args : gst_plugins_bad_args + openaptx_defines,
     include_directories : [configinc],
     dependencies : [gstaudio_dep, openaptx_dep],
     install : true,