diff options
Diffstat (limited to 'ext/jack')
-rw-r--r-- | ext/jack/Makefile.am | 10 | ||||
-rwxr-xr-x | ext/jack/Makefile.in | 926 | ||||
-rw-r--r-- | ext/jack/gstjack.c | 117 | ||||
-rw-r--r-- | ext/jack/gstjack.h | 79 | ||||
-rwxr-xr-x | ext/jack/gstjackaudioclient.c | 629 | ||||
-rw-r--r-- | ext/jack/gstjackaudioclient.h | 61 | ||||
-rwxr-xr-x | ext/jack/gstjackaudiosink.c | 941 | ||||
-rw-r--r-- | ext/jack/gstjackaudiosink.h | 81 | ||||
-rwxr-xr-x | ext/jack/gstjackaudiosrc.c | 961 | ||||
-rw-r--r-- | ext/jack/gstjackaudiosrc.h | 99 | ||||
-rw-r--r-- | ext/jack/gstjackringbuffer.h | 88 | ||||
-rw-r--r-- | ext/jack/gstjackutil.c | 110 | ||||
-rw-r--r-- | ext/jack/gstjackutil.h | 31 |
13 files changed, 4133 insertions, 0 deletions
diff --git a/ext/jack/Makefile.am b/ext/jack/Makefile.am new file mode 100644 index 0000000..e786a8d --- /dev/null +++ b/ext/jack/Makefile.am @@ -0,0 +1,10 @@ + +plugin_LTLIBRARIES = libgstjack.la + +libgstjack_la_SOURCES = gstjackutil.c gstjack.c gstjackaudiosrc.c gstjackaudiosink.c gstjackaudioclient.c +libgstjack_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(JACK_CFLAGS) +libgstjack_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) $(JACK_LIBS) +libgstjack_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgstjack_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) + +noinst_HEADERS = gstjackutil.h gstjackaudiosrc.h gstjackaudiosink.h gstjackaudioclient.h gstjack.h gstjackringbuffer.h diff --git a/ext/jack/Makefile.in b/ext/jack/Makefile.in new file mode 100755 index 0000000..0ecf697 --- /dev/null +++ b/ext/jack/Makefile.in @@ -0,0 +1,926 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = ext/jack +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/depcomp $(noinst_HEADERS) +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \ + $(top_srcdir)/common/m4/as-auto-alt.m4 \ + $(top_srcdir)/common/m4/as-compiler-flag.m4 \ + $(top_srcdir)/common/m4/as-gcc-inline-assembly.m4 \ + $(top_srcdir)/common/m4/as-libtool.m4 \ + $(top_srcdir)/common/m4/as-version.m4 \ + $(top_srcdir)/common/m4/ax_create_stdint_h.m4 \ + $(top_srcdir)/common/m4/gst-arch.m4 \ + $(top_srcdir)/common/m4/gst-args.m4 \ + $(top_srcdir)/common/m4/gst-check.m4 \ + $(top_srcdir)/common/m4/gst-default.m4 \ + $(top_srcdir)/common/m4/gst-dowhile.m4 \ + $(top_srcdir)/common/m4/gst-error.m4 \ + $(top_srcdir)/common/m4/gst-feature.m4 \ + $(top_srcdir)/common/m4/gst-gettext.m4 \ + $(top_srcdir)/common/m4/gst-glib2.m4 \ + $(top_srcdir)/common/m4/gst-package-release-datetime.m4 \ + $(top_srcdir)/common/m4/gst-platform.m4 \ + $(top_srcdir)/common/m4/gst-plugin-docs.m4 \ + $(top_srcdir)/common/m4/gst-plugindir.m4 \ + $(top_srcdir)/common/m4/gst-x11.m4 \ + $(top_srcdir)/common/m4/gst.m4 \ + $(top_srcdir)/common/m4/gtk-doc.m4 \ + $(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \ + $(top_srcdir)/m4/aalib.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gst-fionread.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(plugindir)" +LTLIBRARIES = $(plugin_LTLIBRARIES) +am__DEPENDENCIES_1 = +libgstjack_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_libgstjack_la_OBJECTS = libgstjack_la-gstjackutil.lo \ + libgstjack_la-gstjack.lo libgstjack_la-gstjackaudiosrc.lo \ + libgstjack_la-gstjackaudiosink.lo \ + libgstjack_la-gstjackaudioclient.lo +libgstjack_la_OBJECTS = $(am_libgstjack_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libgstjack_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ + $(CCLD) $(libgstjack_la_CFLAGS) $(CFLAGS) \ + $(libgstjack_la_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libgstjack_la_SOURCES) +DIST_SOURCES = $(libgstjack_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +AALIB_CFLAGS = @AALIB_CFLAGS@ +AALIB_CONFIG = @AALIB_CONFIG@ +AALIB_LIBS = @AALIB_LIBS@ +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BZ2_LIBS = @BZ2_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@ +DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@ +DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@ +DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@ +DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@ +DIRECTSOUND_CFLAGS = @DIRECTSOUND_CFLAGS@ +DIRECTSOUND_LDFLAGS = @DIRECTSOUND_LDFLAGS@ +DIRECTSOUND_LIBS = @DIRECTSOUND_LIBS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DV1394_CFLAGS = @DV1394_CFLAGS@ +DV1394_LIBS = @DV1394_LIBS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ERROR_CFLAGS = @ERROR_CFLAGS@ +ERROR_CXXFLAGS = @ERROR_CXXFLAGS@ +ERROR_OBJCFLAGS = @ERROR_OBJCFLAGS@ +EXEEXT = @EXEEXT@ +FFLAGS = @FFLAGS@ +FGREP = @FGREP@ +FLAC_CFLAGS = @FLAC_CFLAGS@ +FLAC_LIBS = @FLAC_LIBS@ +GCOV = @GCOV@ +GCOV_CFLAGS = @GCOV_CFLAGS@ +GCOV_LIBS = @GCOV_LIBS@ +GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@ +GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GIO_CFLAGS = @GIO_CFLAGS@ +GIO_LDFLAGS = @GIO_LDFLAGS@ +GIO_LIBS = @GIO_LIBS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GLIB_PREFIX = @GLIB_PREFIX@ +GLIB_REQ = @GLIB_REQ@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@ +GSTPB_PREFIX = @GSTPB_PREFIX@ +GST_AGE = @GST_AGE@ +GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@ +GST_API_VERSION = @GST_API_VERSION@ +GST_BASE_CFLAGS = @GST_BASE_CFLAGS@ +GST_BASE_LIBS = @GST_BASE_LIBS@ +GST_CFLAGS = @GST_CFLAGS@ +GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@ +GST_CHECK_LIBS = @GST_CHECK_LIBS@ +GST_CONTROLLER_CFLAGS = @GST_CONTROLLER_CFLAGS@ +GST_CONTROLLER_LIBS = @GST_CONTROLLER_LIBS@ +GST_CURRENT = @GST_CURRENT@ +GST_CXXFLAGS = @GST_CXXFLAGS@ +GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@ +GST_LIBS = @GST_LIBS@ +GST_LIBVERSION = @GST_LIBVERSION@ +GST_LICENSE = @GST_LICENSE@ +GST_LT_LDFLAGS = @GST_LT_LDFLAGS@ +GST_NET_CFLAGS = @GST_NET_CFLAGS@ +GST_NET_LIBS = @GST_NET_LIBS@ +GST_OBJCFLAGS = @GST_OBJCFLAGS@ +GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@ +GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@ +GST_OPTION_OBJCFLAGS = @GST_OPTION_OBJCFLAGS@ +GST_PACKAGE_NAME = @GST_PACKAGE_NAME@ +GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@ +GST_PLUGINS_ALL = @GST_PLUGINS_ALL@ +GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@ +GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@ +GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@ +GST_PLUGINS_DIR = @GST_PLUGINS_DIR@ +GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@ +GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@ +GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@ +GST_PLUGIN_LIBTOOLFLAGS = @GST_PLUGIN_LIBTOOLFLAGS@ +GST_PREFIX = @GST_PREFIX@ +GST_REVISION = @GST_REVISION@ +GST_TOOLS_DIR = @GST_TOOLS_DIR@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +GTK_X11_CFLAGS = @GTK_X11_CFLAGS@ +GTK_X11_LIBS = @GTK_X11_LIBS@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HAVE_AVC1394 = @HAVE_AVC1394@ +HAVE_CXX = @HAVE_CXX@ +HAVE_DIRECTSOUND = @HAVE_DIRECTSOUND@ +HAVE_ROM1394 = @HAVE_ROM1394@ +HAVE_SPEEX = @HAVE_SPEEX@ +HAVE_X = @HAVE_X@ +HAVE_XSHM = @HAVE_XSHM@ +HAVE_ZLIB = @HAVE_ZLIB@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JACK_0_120_1_CFLAGS = @JACK_0_120_1_CFLAGS@ +JACK_0_120_1_LIBS = @JACK_0_120_1_LIBS@ +JACK_1_9_7_CFLAGS = @JACK_1_9_7_CFLAGS@ +JACK_1_9_7_LIBS = @JACK_1_9_7_LIBS@ +JACK_CFLAGS = @JACK_CFLAGS@ +JACK_LIBS = @JACK_LIBS@ +JPEG_LIBS = @JPEG_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBCACA_CFLAGS = @LIBCACA_CFLAGS@ +LIBCACA_LIBS = @LIBCACA_LIBS@ +LIBDV_CFLAGS = @LIBDV_CFLAGS@ +LIBDV_LIBS = @LIBDV_LIBS@ +LIBICONV = @LIBICONV@ +LIBIEC61883_CFLAGS = @LIBIEC61883_CFLAGS@ +LIBIEC61883_LIBS = @LIBIEC61883_LIBS@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ +LIBPNG_CFLAGS = @LIBPNG_CFLAGS@ +LIBPNG_LIBS = @LIBPNG_LIBS@ +LIBRT = @LIBRT@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBV4L2_CFLAGS = @LIBV4L2_CFLAGS@ +LIBV4L2_LIBS = @LIBV4L2_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOCALEDIR = @LOCALEDIR@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORCC = @ORCC@ +ORCC_FLAGS = @ORCC_FLAGS@ +ORC_CFLAGS = @ORC_CFLAGS@ +ORC_LIBS = @ORC_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ +PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@ +PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ +PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@ +PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PLUGINDIR = @PLUGINDIR@ +POSUB = @POSUB@ +PROFILE_CFLAGS = @PROFILE_CFLAGS@ +PULSE_CFLAGS = @PULSE_CFLAGS@ +PULSE_LIBS = @PULSE_LIBS@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RAW1394_CFLAGS = @RAW1394_CFLAGS@ +RAW1394_LIBS = @RAW1394_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SHOUT2_CFLAGS = @SHOUT2_CFLAGS@ +SHOUT2_LIBS = @SHOUT2_LIBS@ +SOUP_CFLAGS = @SOUP_CFLAGS@ +SOUP_LIBS = @SOUP_LIBS@ +SPEEX_CFLAGS = @SPEEX_CFLAGS@ +SPEEX_LIBS = @SPEEX_LIBS@ +STRIP = @STRIP@ +TAGLIB_CFLAGS = @TAGLIB_CFLAGS@ +TAGLIB_CXXFLAGS = @TAGLIB_CXXFLAGS@ +TAGLIB_LIBS = @TAGLIB_LIBS@ +USE_NLS = @USE_NLS@ +VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ +VALGRIND_LIBS = @VALGRIND_LIBS@ +VALGRIND_PATH = @VALGRIND_PATH@ +VERSION = @VERSION@ +VPX_130_CFLAGS = @VPX_130_CFLAGS@ +VPX_130_LIBS = @VPX_130_LIBS@ +VPX_CFLAGS = @VPX_CFLAGS@ +VPX_LIBS = @VPX_LIBS@ +WARNING_CFLAGS = @WARNING_CFLAGS@ +WARNING_CXXFLAGS = @WARNING_CXXFLAGS@ +WARNING_OBJCFLAGS = @WARNING_OBJCFLAGS@ +WAVPACK_CFLAGS = @WAVPACK_CFLAGS@ +WAVPACK_LIBS = @WAVPACK_LIBS@ +XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@ +XDAMAGE_LIBS = @XDAMAGE_LIBS@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +XMKMF = @XMKMF@ +XSHM_LIBS = @XSHM_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ZLIB_LIBS = @ZLIB_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +plugindir = @plugindir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +plugin_LTLIBRARIES = libgstjack.la +libgstjack_la_SOURCES = gstjackutil.c gstjack.c gstjackaudiosrc.c gstjackaudiosink.c gstjackaudioclient.c +libgstjack_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(JACK_CFLAGS) +libgstjack_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) $(JACK_LIBS) +libgstjack_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgstjack_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) +noinst_HEADERS = gstjackutil.h gstjackaudiosrc.h gstjackaudiosink.h gstjackaudioclient.h gstjack.h gstjackringbuffer.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/jack/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu ext/jack/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(plugindir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \ + } + +uninstall-pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \ + done + +clean-pluginLTLIBRARIES: + -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) + @list='$(plugin_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libgstjack.la: $(libgstjack_la_OBJECTS) $(libgstjack_la_DEPENDENCIES) $(EXTRA_libgstjack_la_DEPENDENCIES) + $(AM_V_CCLD)$(libgstjack_la_LINK) -rpath $(plugindir) $(libgstjack_la_OBJECTS) $(libgstjack_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstjack_la-gstjack.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstjack_la-gstjackaudioclient.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstjack_la-gstjackaudiosink.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstjack_la-gstjackaudiosrc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstjack_la-gstjackutil.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libgstjack_la-gstjackutil.lo: gstjackutil.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -MT libgstjack_la-gstjackutil.lo -MD -MP -MF $(DEPDIR)/libgstjack_la-gstjackutil.Tpo -c -o libgstjack_la-gstjackutil.lo `test -f 'gstjackutil.c' || echo '$(srcdir)/'`gstjackutil.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstjack_la-gstjackutil.Tpo $(DEPDIR)/libgstjack_la-gstjackutil.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstjackutil.c' object='libgstjack_la-gstjackutil.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -c -o libgstjack_la-gstjackutil.lo `test -f 'gstjackutil.c' || echo '$(srcdir)/'`gstjackutil.c + +libgstjack_la-gstjack.lo: gstjack.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -MT libgstjack_la-gstjack.lo -MD -MP -MF $(DEPDIR)/libgstjack_la-gstjack.Tpo -c -o libgstjack_la-gstjack.lo `test -f 'gstjack.c' || echo '$(srcdir)/'`gstjack.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstjack_la-gstjack.Tpo $(DEPDIR)/libgstjack_la-gstjack.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstjack.c' object='libgstjack_la-gstjack.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -c -o libgstjack_la-gstjack.lo `test -f 'gstjack.c' || echo '$(srcdir)/'`gstjack.c + +libgstjack_la-gstjackaudiosrc.lo: gstjackaudiosrc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -MT libgstjack_la-gstjackaudiosrc.lo -MD -MP -MF $(DEPDIR)/libgstjack_la-gstjackaudiosrc.Tpo -c -o libgstjack_la-gstjackaudiosrc.lo `test -f 'gstjackaudiosrc.c' || echo '$(srcdir)/'`gstjackaudiosrc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstjack_la-gstjackaudiosrc.Tpo $(DEPDIR)/libgstjack_la-gstjackaudiosrc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstjackaudiosrc.c' object='libgstjack_la-gstjackaudiosrc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -c -o libgstjack_la-gstjackaudiosrc.lo `test -f 'gstjackaudiosrc.c' || echo '$(srcdir)/'`gstjackaudiosrc.c + +libgstjack_la-gstjackaudiosink.lo: gstjackaudiosink.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -MT libgstjack_la-gstjackaudiosink.lo -MD -MP -MF $(DEPDIR)/libgstjack_la-gstjackaudiosink.Tpo -c -o libgstjack_la-gstjackaudiosink.lo `test -f 'gstjackaudiosink.c' || echo '$(srcdir)/'`gstjackaudiosink.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstjack_la-gstjackaudiosink.Tpo $(DEPDIR)/libgstjack_la-gstjackaudiosink.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstjackaudiosink.c' object='libgstjack_la-gstjackaudiosink.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -c -o libgstjack_la-gstjackaudiosink.lo `test -f 'gstjackaudiosink.c' || echo '$(srcdir)/'`gstjackaudiosink.c + +libgstjack_la-gstjackaudioclient.lo: gstjackaudioclient.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -MT libgstjack_la-gstjackaudioclient.lo -MD -MP -MF $(DEPDIR)/libgstjack_la-gstjackaudioclient.Tpo -c -o libgstjack_la-gstjackaudioclient.lo `test -f 'gstjackaudioclient.c' || echo '$(srcdir)/'`gstjackaudioclient.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstjack_la-gstjackaudioclient.Tpo $(DEPDIR)/libgstjack_la-gstjackaudioclient.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstjackaudioclient.c' object='libgstjack_la-gstjackaudioclient.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstjack_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstjack_la_CFLAGS) $(CFLAGS) -c -o libgstjack_la-gstjackaudioclient.lo `test -f 'gstjackaudioclient.c' || echo '$(srcdir)/'`gstjackaudioclient.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(plugindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pluginLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pluginLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-pluginLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-pluginLTLIBRARIES install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ + uninstall-pluginLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ext/jack/gstjack.c b/ext/jack/gstjack.c new file mode 100644 index 0000000..ca98dc4 --- /dev/null +++ b/ext/jack/gstjack.c @@ -0,0 +1,117 @@ +/* GStreamer Jack plugins + * Copyright (C) 2006 Wim Taymans <wim@fluendo.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstjack.h" +#include "gstjackaudiosrc.h" +#include "gstjackaudiosink.h" + +GType +gst_jack_connect_get_type (void) +{ + static volatile gsize jack_connect_type = 0; + + if (g_once_init_enter (&jack_connect_type)) { + static const GEnumValue jack_connect_enums[] = { + {GST_JACK_CONNECT_NONE, + "Don't automatically connect ports to physical ports", "none"}, + {GST_JACK_CONNECT_AUTO, + "Automatically connect ports to physical ports", "auto"}, + {GST_JACK_CONNECT_AUTO_FORCED, + "Automatically connect ports to as many physical ports as possible", + "auto-forced"}, + {0, NULL, NULL}, + }; + GType tmp = g_enum_register_static ("GstJackConnect", jack_connect_enums); + g_once_init_leave (&jack_connect_type, tmp); + } + return (GType) jack_connect_type; +} + +GType +gst_jack_transport_get_type (void) +{ + static volatile gsize type = 0; + + if (g_once_init_enter (&type)) { + static const GFlagsValue flag_values[] = { + {GST_JACK_TRANSPORT_MASTER, + "Start and stop transport with state changes", "master"}, + {GST_JACK_TRANSPORT_SLAVE, + "Follow transport state changes", "slave"}, + {0, NULL, NULL}, + }; + GType tmp = g_flags_register_static ("GstJackTransport", flag_values); + g_once_init_leave (&type, tmp); + } + return (GType) type; +} + + +static gpointer +gst_jack_client_copy (gpointer jclient) +{ + return jclient; +} + + +static void +gst_jack_client_free (gpointer jclient) +{ + return; +} + + +GType +gst_jack_client_get_type (void) +{ + static volatile gsize jack_client_type = 0; + + if (g_once_init_enter (&jack_client_type)) { + /* hackish, but makes it show up nicely in gst-inspect */ + GType tmp = g_boxed_type_register_static ("JackClient", + (GBoxedCopyFunc) gst_jack_client_copy, + (GBoxedFreeFunc) gst_jack_client_free); + g_once_init_leave (&jack_client_type, tmp); + } + + return (GType) jack_client_type; +} + +static gboolean +plugin_init (GstPlugin * plugin) +{ + if (!gst_element_register (plugin, "jackaudiosrc", GST_RANK_PRIMARY, + GST_TYPE_JACK_AUDIO_SRC)) + return FALSE; + if (!gst_element_register (plugin, "jackaudiosink", GST_RANK_PRIMARY, + GST_TYPE_JACK_AUDIO_SINK)) + return FALSE; + + return TRUE; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + jack, + "JACK audio elements", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/ext/jack/gstjack.h b/ext/jack/gstjack.h new file mode 100644 index 0000000..15b040e --- /dev/null +++ b/ext/jack/gstjack.h @@ -0,0 +1,79 @@ +/* GStreamer + * Copyright (C) 2006 Wim Taymans <wim@fluendo.com> + * + * gstjack.h: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_JACK_H_ +#define _GST_JACK_H_ + +#include <jack/jack.h> +#include <gst/audio/audio.h> + +/** + * GstJackConnect: + * @GST_JACK_CONNECT_NONE: Don't automatically connect to physical ports. + * In this mode, the element will accept any number of input channels and will + * create (but not connect) an output port for each channel. + * @GST_JACK_CONNECT_AUTO: In this mode, the element will try to connect each + * output port to a random physical jack input pin. The sink will + * expose the number of physical channels on its pad caps. + * @GST_JACK_CONNECT_AUTO_FORCED: In this mode, the element will try to connect each + * output port to a random physical jack input pin. The element will accept any number + * of input channels. + * + * Specify how the output ports will be connected. + */ +typedef enum { + GST_JACK_CONNECT_NONE, + GST_JACK_CONNECT_AUTO, + GST_JACK_CONNECT_AUTO_FORCED +} GstJackConnect; + +/** + * GstJackTransport: + * @GST_JACK_TRANSPORT_AUTONOMOUS: no transport support + * @GST_JACK_TRANSPORT_MASTER: start and stop transport with state-changes + * @GST_JACK_TRANSPORT_SLAVE: follow transport state changes + * + * The jack transport state allow to sync multiple clients. This enum defines a + * client behaviour regarding to the transport mechanism. + */ +typedef enum { + GST_JACK_TRANSPORT_AUTONOMOUS = 0, + GST_JACK_TRANSPORT_MASTER = (1 << 0), + GST_JACK_TRANSPORT_SLAVE = (1 << 1), +} GstJackTransport; + +typedef jack_default_audio_sample_t sample_t; + +#define GST_TYPE_JACK_CONNECT (gst_jack_connect_get_type ()) +#define GST_TYPE_JACK_TRANSPORT (gst_jack_transport_get_type ()) +#define GST_TYPE_JACK_CLIENT (gst_jack_client_get_type ()) + +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +#define GST_JACK_FORMAT_STR "F32LE" +#else +#define GST_JACK_FORMAT_STR "F32BE" +#endif + +GType gst_jack_client_get_type(void); +GType gst_jack_connect_get_type(void); +GType gst_jack_transport_get_type(void); + +#endif // _GST_JACK_H_ diff --git a/ext/jack/gstjackaudioclient.c b/ext/jack/gstjackaudioclient.c new file mode 100755 index 0000000..0f06d10 --- /dev/null +++ b/ext/jack/gstjackaudioclient.c @@ -0,0 +1,629 @@ +/* GStreamer + * Copyright (C) 2006 Wim Taymans <wim@fluendo.com> + * + * gstjackaudioclient.c: jack audio client implementation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <string.h> + +#include "gstjackaudioclient.h" +#include "gstjack.h" + +#include <gst/glib-compat-private.h> + +GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_client_debug); +#define GST_CAT_DEFAULT gst_jack_audio_client_debug + +static void +jack_log_error (const gchar * msg) +{ + GST_ERROR ("%s", msg); +} + +static void +jack_info_error (const gchar * msg) +{ + GST_INFO ("%s", msg); +} + +void +gst_jack_audio_client_init (void) +{ + GST_DEBUG_CATEGORY_INIT (gst_jack_audio_client_debug, "jackclient", 0, + "jackclient helpers"); + + jack_set_error_function (jack_log_error); + jack_set_info_function (jack_info_error); +} + +/* a list of global connections indexed by id and server. */ +G_LOCK_DEFINE_STATIC (connections_lock); +static GList *connections; + +/* the connection to a server */ +typedef struct +{ + gint refcount; + GMutex lock; + GCond flush_cond; + + /* id/server pair and the connection */ + gchar *id; + gchar *server; + jack_client_t *client; + + /* lists of GstJackAudioClients */ + gint n_clients; + GList *src_clients; + GList *sink_clients; + + /* transport state handling */ + gint cur_ts; + GstState transport_state; +} GstJackAudioConnection; + +/* an object sharing a jack_client_t connection. */ +struct _GstJackAudioClient +{ + GstJackAudioConnection *conn; + + GstJackClientType type; + gboolean active; + gboolean deactivate; + + JackShutdownCallback shutdown; + JackProcessCallback process; + JackBufferSizeCallback buffer_size; + JackSampleRateCallback sample_rate; + gpointer user_data; +}; + +typedef struct +{ + jack_nframes_t nframes; + gpointer user_data; +} JackCB; + +static gboolean +jack_handle_transport_change (GstJackAudioClient * client, GstState state) +{ + GstObject *obj = GST_OBJECT_PARENT (client->user_data); + guint mode; + + g_object_get (obj, "transport", &mode, NULL); + if ((mode & GST_JACK_TRANSPORT_SLAVE) && (GST_STATE (obj) != state)) { + GST_INFO_OBJECT (obj, "requesting state change: %s", + gst_element_state_get_name (state)); + gst_element_post_message (GST_ELEMENT (obj), + gst_message_new_request_state (obj, state)); + return TRUE; + } + return FALSE; +} + +static int +jack_process_cb (jack_nframes_t nframes, void *arg) +{ + GstJackAudioConnection *conn = (GstJackAudioConnection *) arg; + GList *walk; + int res = 0; + jack_transport_state_t ts = jack_transport_query (conn->client, NULL); + + if (ts != conn->cur_ts) { + conn->cur_ts = ts; + switch (ts) { + case JackTransportStopped: + GST_DEBUG ("transport state is 'stopped'"); + conn->transport_state = GST_STATE_PAUSED; + break; + case JackTransportStarting: + GST_DEBUG ("transport state is 'starting'"); + conn->transport_state = GST_STATE_READY; + break; + case JackTransportRolling: + GST_DEBUG ("transport state is 'rolling'"); + conn->transport_state = GST_STATE_PLAYING; + break; + default: + break; + } + GST_DEBUG ("num of clients: src=%d, sink=%d", + g_list_length (conn->src_clients), g_list_length (conn->sink_clients)); + } + + g_mutex_lock (&conn->lock); + /* call sources first, then sinks. Sources will either push data into the + * ringbuffer of the sinks, which will then pull the data out of it, or + * sinks will pull the data from the sources. */ + for (walk = conn->src_clients; walk; walk = g_list_next (walk)) { + GstJackAudioClient *client = (GstJackAudioClient *) walk->data; + + /* only call active clients */ + if ((client->active || client->deactivate) && client->process) { + res = client->process (nframes, client->user_data); + if (client->deactivate) { + client->deactivate = FALSE; + g_cond_signal (&conn->flush_cond); + } + } + } + for (walk = conn->sink_clients; walk; walk = g_list_next (walk)) { + GstJackAudioClient *client = (GstJackAudioClient *) walk->data; + + /* only call active clients */ + if ((client->active || client->deactivate) && client->process) { + res = client->process (nframes, client->user_data); + if (client->deactivate) { + client->deactivate = FALSE; + g_cond_signal (&conn->flush_cond); + } + } + } + + /* handle transport state requisition, do sinks first, stop after the first + * element that handled it */ + if (conn->transport_state != GST_STATE_VOID_PENDING) { + for (walk = conn->sink_clients; walk; walk = g_list_next (walk)) { + if (jack_handle_transport_change ((GstJackAudioClient *) walk->data, + conn->transport_state)) { + conn->transport_state = GST_STATE_VOID_PENDING; + break; + } + } + } + if (conn->transport_state != GST_STATE_VOID_PENDING) { + for (walk = conn->src_clients; walk; walk = g_list_next (walk)) { + if (jack_handle_transport_change ((GstJackAudioClient *) walk->data, + conn->transport_state)) { + conn->transport_state = GST_STATE_VOID_PENDING; + break; + } + } + } + g_mutex_unlock (&conn->lock); + + return res; +} + +/* we error out */ +static int +jack_sample_rate_cb (jack_nframes_t nframes, void *arg) +{ + return 0; +} + +/* we error out */ +static int +jack_buffer_size_cb (jack_nframes_t nframes, void *arg) +{ + return 0; +} + +static void +jack_shutdown_cb (void *arg) +{ + GstJackAudioConnection *conn = (GstJackAudioConnection *) arg; + GList *walk; + + GST_DEBUG ("disconnect client %s from server %s", conn->id, + GST_STR_NULL (conn->server)); + + g_mutex_lock (&conn->lock); + for (walk = conn->src_clients; walk; walk = g_list_next (walk)) { + GstJackAudioClient *client = (GstJackAudioClient *) walk->data; + + if (client->shutdown) + client->shutdown (client->user_data); + } + for (walk = conn->sink_clients; walk; walk = g_list_next (walk)) { + GstJackAudioClient *client = (GstJackAudioClient *) walk->data; + + if (client->shutdown) + client->shutdown (client->user_data); + } + g_mutex_unlock (&conn->lock); +} + +typedef struct +{ + const gchar *id; + const gchar *server; +} FindData; + +static gint +connection_find (GstJackAudioConnection * conn, FindData * data) +{ + /* id's must match */ + if (strcmp (conn->id, data->id)) + return 1; + + /* both the same or NULL */ + if (conn->server == data->server) + return 0; + + /* we cannot compare NULL */ + if (conn->server == NULL || data->server == NULL) + return 1; + + if (strcmp (conn->server, data->server)) + return 1; + + return 0; +} + +/* make a connection with @id and @server. Returns NULL on failure with the + * status set. */ +static GstJackAudioConnection * +gst_jack_audio_make_connection (const gchar * id, const gchar * server, + jack_client_t * jclient, jack_status_t * status) +{ + GstJackAudioConnection *conn; + jack_options_t options; + gint res; + + *status = 0; + + GST_DEBUG ("new client %s, connecting to server %s", id, + GST_STR_NULL (server)); + + /* never start a server */ + options = JackNoStartServer; + /* if we have a servername, use it */ + if (server != NULL) + options |= JackServerName; + /* open the client */ + if (jclient == NULL) + jclient = jack_client_open (id, options, status, server); + if (jclient == NULL) + goto could_not_open; + + /* now create object */ + conn = g_new (GstJackAudioConnection, 1); + conn->refcount = 1; + g_mutex_init (&conn->lock); + g_cond_init (&conn->flush_cond); + conn->id = g_strdup (id); + conn->server = g_strdup (server); + conn->client = jclient; + conn->n_clients = 0; + conn->src_clients = NULL; + conn->sink_clients = NULL; + conn->cur_ts = -1; + conn->transport_state = GST_STATE_VOID_PENDING; + + /* set our callbacks */ + jack_set_process_callback (jclient, jack_process_cb, conn); + /* these callbacks cause us to error */ + jack_set_buffer_size_callback (jclient, jack_buffer_size_cb, conn); + jack_set_sample_rate_callback (jclient, jack_sample_rate_cb, conn); + jack_on_shutdown (jclient, jack_shutdown_cb, conn); + + /* all callbacks are set, activate the client */ + GST_INFO ("activate jack_client %p", jclient); + if ((res = jack_activate (jclient))) + goto could_not_activate; + + GST_DEBUG ("opened connection %p", conn); + + return conn; + + /* ERRORS */ +could_not_open: + { + GST_DEBUG ("failed to open jack client, %d", *status); + return NULL; + } +could_not_activate: + { + GST_ERROR ("Could not activate client (%d)", res); + *status = JackFailure; + g_mutex_clear (&conn->lock); + g_free (conn->id); + g_free (conn->server); + g_free (conn); + return NULL; + } +} + +static GstJackAudioConnection * +gst_jack_audio_get_connection (const gchar * id, const gchar * server, + jack_client_t * jclient, jack_status_t * status) +{ + GstJackAudioConnection *conn; + GList *found; + FindData data; + + GST_DEBUG ("getting connection for id %s, server %s", id, + GST_STR_NULL (server)); + + data.id = id; + data.server = server; + + G_LOCK (connections_lock); + found = + g_list_find_custom (connections, &data, (GCompareFunc) connection_find); + if (found != NULL && jclient != NULL) { + /* we found it, increase refcount and return it */ + conn = (GstJackAudioConnection *) found->data; + conn->refcount++; + + GST_DEBUG ("found connection %p", conn); + } else { + /* make new connection */ + conn = gst_jack_audio_make_connection (id, server, jclient, status); + if (conn != NULL) { + GST_DEBUG ("created connection %p", conn); + /* add to list on success */ + connections = g_list_prepend (connections, conn); + } else { + GST_WARNING ("could not create connection"); + } + } + G_UNLOCK (connections_lock); + + return conn; +} + +static void +gst_jack_audio_unref_connection (GstJackAudioConnection * conn) +{ + gint res; + gboolean zero; + + GST_DEBUG ("unref connection %p refcnt %d", conn, conn->refcount); + + G_LOCK (connections_lock); + conn->refcount--; + if ((zero = (conn->refcount == 0))) { + GST_DEBUG ("closing connection %p", conn); + /* remove from list, we can release the mutex after removing the connection + * from the list because after that, nobody can access the connection anymore. */ + connections = g_list_remove (connections, conn); + } + G_UNLOCK (connections_lock); + + /* if we are zero, close and cleanup the connection */ + if (zero) { + /* don't use conn->lock here. two reasons: + * + * 1) its not necessary: jack_deactivate() will not return until the JACK thread + * associated with this connection is cleaned up by a thread join, hence + * no more callbacks can occur or be in progress. + * + * 2) it would deadlock anyway, because jack_deactivate() will sleep + * waiting for the JACK thread, and can thus cause deadlock in + * jack_process_cb() + */ + GST_INFO ("deactivate jack_client %p", conn->client); + if ((res = jack_deactivate (conn->client))) { + /* we only warn, this means the server is probably shut down and the client + * is gone anyway. */ + GST_WARNING ("Could not deactivate Jack client (%d)", res); + } + /* close connection */ + if ((res = jack_client_close (conn->client))) { + /* we assume the client is gone. */ + GST_WARNING ("close failed (%d)", res); + } + + /* free resources */ + g_mutex_clear (&conn->lock); + g_cond_clear (&conn->flush_cond); + g_free (conn->id); + g_free (conn->server); + g_free (conn); + } +} + +static void +gst_jack_audio_connection_add_client (GstJackAudioConnection * conn, + GstJackAudioClient * client) +{ + g_mutex_lock (&conn->lock); + switch (client->type) { + case GST_JACK_CLIENT_SOURCE: + conn->src_clients = g_list_append (conn->src_clients, client); + conn->n_clients++; + break; + case GST_JACK_CLIENT_SINK: + conn->sink_clients = g_list_append (conn->sink_clients, client); + conn->n_clients++; + break; + default: + g_warning ("trying to add unknown client type"); + break; + } + g_mutex_unlock (&conn->lock); +} + +static void +gst_jack_audio_connection_remove_client (GstJackAudioConnection * conn, + GstJackAudioClient * client) +{ + g_mutex_lock (&conn->lock); + switch (client->type) { + case GST_JACK_CLIENT_SOURCE: + conn->src_clients = g_list_remove (conn->src_clients, client); + conn->n_clients--; + break; + case GST_JACK_CLIENT_SINK: + conn->sink_clients = g_list_remove (conn->sink_clients, client); + conn->n_clients--; + break; + default: + g_warning ("trying to remove unknown client type"); + break; + } + g_mutex_unlock (&conn->lock); +} + +/** + * gst_jack_audio_client_get: + * @id: the client id + * @server: the server to connect to or NULL for the default server + * @type: the client type + * @shutdown: a callback when the jack server shuts down + * @process: a callback when samples are available + * @buffer_size: a callback when the buffer_size changes + * @sample_rate: a callback when the sample_rate changes + * @user_data: user data passed to the callbacks + * @status: pointer to hold the jack status code in case of errors + * + * Get the jack client connection for @id and @server. Connections to the same + * @id and @server will receive the same physical Jack client connection and + * will therefore be scheduled in the same process callback. + * + * Returns: a #GstJackAudioClient. + */ +GstJackAudioClient * +gst_jack_audio_client_new (const gchar * id, const gchar * server, + jack_client_t * jclient, GstJackClientType type, + void (*shutdown) (void *arg), JackProcessCallback process, + JackBufferSizeCallback buffer_size, JackSampleRateCallback sample_rate, + gpointer user_data, jack_status_t * status) +{ + GstJackAudioClient *client; + GstJackAudioConnection *conn; + + g_return_val_if_fail (id != NULL, NULL); + g_return_val_if_fail (status != NULL, NULL); + + /* first get a connection for the id/server pair */ + conn = gst_jack_audio_get_connection (id, server, jclient, status); + if (conn == NULL) + goto no_connection; + + GST_INFO ("new client %s", id); + + /* make new client using the connection */ + client = g_new (GstJackAudioClient, 1); + client->active = client->deactivate = FALSE; + client->conn = conn; + client->type = type; + client->shutdown = shutdown; + client->process = process; + client->buffer_size = buffer_size; + client->sample_rate = sample_rate; + client->user_data = user_data; + + /* add the client to the connection */ + gst_jack_audio_connection_add_client (conn, client); + + return client; + + /* ERRORS */ +no_connection: + { + GST_DEBUG ("Could not get server connection (%d)", *status); + return NULL; + } +} + +/** + * gst_jack_audio_client_free: + * @client: a #GstJackAudioClient + * + * Free the resources used by @client. + */ +void +gst_jack_audio_client_free (GstJackAudioClient * client) +{ + GstJackAudioConnection *conn; + + g_return_if_fail (client != NULL); + + GST_INFO ("free client"); + + conn = client->conn; + + /* remove from connection first so that it's not scheduled anymore after this + * call */ + gst_jack_audio_connection_remove_client (conn, client); + gst_jack_audio_unref_connection (conn); + + g_free (client); +} + +/** + * gst_jack_audio_client_get_client: + * @client: a #GstJackAudioClient + * + * Get the jack audio client for @client. This function is used to perform + * operations on the jack server from this client. + * + * Returns: The jack audio client. + */ +jack_client_t * +gst_jack_audio_client_get_client (GstJackAudioClient * client) +{ + g_return_val_if_fail (client != NULL, NULL); + + /* no lock needed, the connection and the client does not change + * once the client is created. */ + return client->conn->client; +} + +/** + * gst_jack_audio_client_set_active: + * @client: a #GstJackAudioClient + * @active: new mode for the client + * + * Activate or deactive @client. When a client is activated it will receive + * callbacks when data should be processed. + * + * Returns: 0 if all ok. + */ +gint +gst_jack_audio_client_set_active (GstJackAudioClient * client, gboolean active) +{ + g_return_val_if_fail (client != NULL, -1); + + /* make sure that we are not dispatching the client */ + g_mutex_lock (&client->conn->lock); + if (client->active && !active) { + /* we need to process once more to flush the port */ + client->deactivate = TRUE; + + /* need to wait for process_cb run once more */ + while (client->deactivate) + g_cond_wait (&client->conn->flush_cond, &client->conn->lock); + } + client->active = active; + g_mutex_unlock (&client->conn->lock); + + return 0; +} + +/** + * gst_jack_audio_client_get_transport_state: + * @client: a #GstJackAudioClient + * + * Check the current transport state. The client can use this to request a state + * change from the application. + * + * Returns: the state, %GST_STATE_VOID_PENDING for no change in the transport + * state + */ +GstState +gst_jack_audio_client_get_transport_state (GstJackAudioClient * client) +{ + GstState state = client->conn->transport_state; + + client->conn->transport_state = GST_STATE_VOID_PENDING; + return state; +} diff --git a/ext/jack/gstjackaudioclient.h b/ext/jack/gstjackaudioclient.h new file mode 100644 index 0000000..5dcd70c --- /dev/null +++ b/ext/jack/gstjackaudioclient.h @@ -0,0 +1,61 @@ +/* GStreamer + * Copyright (C) 2006 Wim Taymans <wim@fluendo.com> + * + * gstjackaudioclient.h: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_JACK_AUDIO_CLIENT_H__ +#define __GST_JACK_AUDIO_CLIENT_H__ + +#include <jack/jack.h> + +#include <gst/gst.h> + +G_BEGIN_DECLS + +typedef enum +{ + GST_JACK_CLIENT_SOURCE, + GST_JACK_CLIENT_SINK +} GstJackClientType; + +typedef struct _GstJackAudioClient GstJackAudioClient; + +void gst_jack_audio_client_init (void); + + +GstJackAudioClient * gst_jack_audio_client_new (const gchar *id, const gchar *server, + jack_client_t *jclient, + GstJackClientType type, + void (*shutdown) (void *arg), + JackProcessCallback process, + JackBufferSizeCallback buffer_size, + JackSampleRateCallback sample_rate, + gpointer user_data, + jack_status_t *status); +void gst_jack_audio_client_free (GstJackAudioClient *client); + +jack_client_t * gst_jack_audio_client_get_client (GstJackAudioClient *client); + +gboolean gst_jack_audio_client_set_active (GstJackAudioClient *client, gboolean active); + +GstState gst_jack_audio_client_get_transport_state (GstJackAudioClient *client); + +G_END_DECLS + +#endif /* __GST_JACK_AUDIO_CLIENT_H__ */ diff --git a/ext/jack/gstjackaudiosink.c b/ext/jack/gstjackaudiosink.c new file mode 100755 index 0000000..3a83567 --- /dev/null +++ b/ext/jack/gstjackaudiosink.c @@ -0,0 +1,941 @@ +/* GStreamer + * Copyright (C) 2006 Wim Taymans <wim@fluendo.com> + * + * gstjackaudiosink.c: jack audio sink implementation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * SECTION:element-jackaudiosink + * @see_also: #GstAudioBaseSink, #GstAudioRingBuffer + * + * A Sink that outputs data to Jack ports. + * + * It will create N Jack ports named out_<name>_<num> where + * <name> is the element name and <num> is starting from 1. + * Each port corresponds to a gstreamer channel. + * + * The samplerate as exposed on the caps is always the same as the samplerate of + * the jack server. + * + * When the #GstJackAudioSink:connect property is set to auto, this element + * will try to connect each output port to a random physical jack input pin. In + * this mode, the sink will expose the number of physical channels on its pad + * caps. + * + * When the #GstJackAudioSink:connect property is set to none, the element will + * accept any number of input channels and will create (but not connect) an + * output port for each channel. + * + * The element will generate an error when the Jack server is shut down when it + * was PAUSED or PLAYING. This element does not support dynamic rate and buffer + * size changes at runtime. + * + * <refsect2> + * <title>Example launch line</title> + * |[ + * gst-launch-1.0 audiotestsrc ! jackaudiosink + * ]| Play a sine wave to using jack. + * </refsect2> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gst/gst-i18n-plugin.h> +#include <stdlib.h> +#include <string.h> +#include <gst/audio/audio.h> + +#include "gstjackaudiosink.h" +#include "gstjackringbuffer.h" + +GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_sink_debug); +#define GST_CAT_DEFAULT gst_jack_audio_sink_debug + +static gboolean +gst_jack_audio_sink_allocate_channels (GstJackAudioSink * sink, gint channels) +{ + jack_client_t *client; + + client = gst_jack_audio_client_get_client (sink->client); + + /* remove ports we don't need */ + while (sink->port_count > channels) { + jack_port_unregister (client, sink->ports[--sink->port_count]); + } + + /* alloc enough output ports */ + sink->ports = g_realloc (sink->ports, sizeof (jack_port_t *) * channels); + sink->buffers = g_realloc (sink->buffers, sizeof (sample_t *) * channels); + + /* create an output port for each channel */ + while (sink->port_count < channels) { + gchar *name; + + /* port names start from 1 and are local to the element */ + name = + g_strdup_printf ("out_%s_%d", GST_ELEMENT_NAME (sink), + sink->port_count + 1); + sink->ports[sink->port_count] = + jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE, + JackPortIsOutput, 0); + if (sink->ports[sink->port_count] == NULL) + return FALSE; + + sink->port_count++; + + g_free (name); + } + return TRUE; +} + +static void +gst_jack_audio_sink_free_channels (GstJackAudioSink * sink) +{ + gint res, i = 0; + jack_client_t *client; + + client = gst_jack_audio_client_get_client (sink->client); + + /* get rid of all ports */ + while (sink->port_count) { + GST_LOG_OBJECT (sink, "unregister port %d", i); + if ((res = jack_port_unregister (client, sink->ports[i++]))) { + GST_DEBUG_OBJECT (sink, "unregister of port failed (%d)", res); + } + sink->port_count--; + } + g_free (sink->ports); + sink->ports = NULL; + g_free (sink->buffers); + sink->buffers = NULL; +} + +/* ringbuffer abstract base class */ +static GType +gst_jack_ring_buffer_get_type (void) +{ + static volatile gsize ringbuffer_type = 0; + + if (g_once_init_enter (&ringbuffer_type)) { + static const GTypeInfo ringbuffer_info = { + sizeof (GstJackRingBufferClass), + NULL, + NULL, + (GClassInitFunc) gst_jack_ring_buffer_class_init, + NULL, + NULL, + sizeof (GstJackRingBuffer), + 0, + (GInstanceInitFunc) gst_jack_ring_buffer_init, + NULL + }; + GType tmp = g_type_register_static (GST_TYPE_AUDIO_RING_BUFFER, + "GstJackAudioSinkRingBuffer", &ringbuffer_info, 0); + g_once_init_leave (&ringbuffer_type, tmp); + } + + return (GType) ringbuffer_type; +} + +static void +gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass) +{ + GstAudioRingBufferClass *gstringbuffer_class; + + gstringbuffer_class = (GstAudioRingBufferClass *) klass; + + ring_parent_class = g_type_class_peek_parent (klass); + + gstringbuffer_class->open_device = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_open_device); + gstringbuffer_class->close_device = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_close_device); + gstringbuffer_class->acquire = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_acquire); + gstringbuffer_class->release = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_release); + gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start); + gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_pause); + gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start); + gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_stop); + + gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_delay); +} + +/* this is the callback of jack. This should RT-safe. + */ +static int +jack_process_cb (jack_nframes_t nframes, void *arg) +{ + GstJackAudioSink *sink; + GstAudioRingBuffer *buf; + gint readseg, len; + guint8 *readptr; + gint i, j, flen, channels; + sample_t *data; + + buf = GST_AUDIO_RING_BUFFER_CAST (arg); + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info); + + /* get target buffers */ + for (i = 0; i < channels; i++) { + sink->buffers[i] = + (sample_t *) jack_port_get_buffer (sink->ports[i], nframes); + } + + if (gst_audio_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) { + flen = len / channels; + + /* the number of samples must be exactly the segment size */ + if (nframes * sizeof (sample_t) != flen) + goto wrong_size; + + GST_DEBUG_OBJECT (sink, "copy %d frames: %p, %d bytes, %d channels", + nframes, readptr, flen, channels); + data = (sample_t *) readptr; + + /* the samples in the ringbuffer have the channels interleaved, we need to + * deinterleave into the jack target buffers */ + for (i = 0; i < nframes; i++) { + for (j = 0; j < channels; j++) { + sink->buffers[j][i] = *data++; + } + } + + /* clear written samples in the ringbuffer */ + gst_audio_ring_buffer_clear (buf, readseg); + + /* we wrote one segment */ + gst_audio_ring_buffer_advance (buf, 1); + } else { + GST_DEBUG_OBJECT (sink, "write %d frames silence", nframes); + /* We are not allowed to read from the ringbuffer, write silence to all + * jack output buffers */ + for (i = 0; i < channels; i++) { + memset (sink->buffers[i], 0, nframes * sizeof (sample_t)); + } + } + return 0; + + /* ERRORS */ +wrong_size: + { + GST_ERROR_OBJECT (sink, "nbytes (%d) != flen (%d)", + (gint) (nframes * sizeof (sample_t)), flen); + return 1; + } +} + +/* we error out */ +static int +jack_sample_rate_cb (jack_nframes_t nframes, void *arg) +{ + GstJackAudioSink *sink; + GstJackRingBuffer *abuf; + + abuf = GST_JACK_RING_BUFFER_CAST (arg); + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (arg)); + + if (abuf->sample_rate != -1 && abuf->sample_rate != nframes) + goto not_supported; + + return 0; + + /* ERRORS */ +not_supported: + { + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, + (NULL), ("Jack changed the sample rate, which is not supported")); + return 1; + } +} + +/* we error out */ +static int +jack_buffer_size_cb (jack_nframes_t nframes, void *arg) +{ + GstJackAudioSink *sink; + GstJackRingBuffer *abuf; + + abuf = GST_JACK_RING_BUFFER_CAST (arg); + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (arg)); + + if (abuf->buffer_size != -1 && abuf->buffer_size != nframes) + goto not_supported; + + return 0; + + /* ERRORS */ +not_supported: + { + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, + (NULL), ("Jack changed the buffer size, which is not supported")); + return 1; + } +} + +static void +jack_shutdown_cb (void *arg) +{ + GstJackAudioSink *sink; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (arg)); + + GST_DEBUG_OBJECT (sink, "shutdown"); + + GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, + (NULL), ("Jack server shutdown")); +} + +static void +gst_jack_ring_buffer_init (GstJackRingBuffer * buf, + GstJackRingBufferClass * g_class) +{ + buf->channels = -1; + buf->buffer_size = -1; + buf->sample_rate = -1; +} + +/* the _open_device method should make a connection with the server + */ +static gboolean +gst_jack_ring_buffer_open_device (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + jack_status_t status = 0; + const gchar *name; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (sink, "open"); + + if (sink->client_name) { + name = sink->client_name; + } else { + name = g_get_application_name (); + } + if (!name) + name = "GStreamer"; + + sink->client = gst_jack_audio_client_new (name, sink->server, + sink->jclient, + GST_JACK_CLIENT_SINK, + jack_shutdown_cb, + jack_process_cb, jack_buffer_size_cb, jack_sample_rate_cb, buf, &status); + if (sink->client == NULL) + goto could_not_open; + + GST_DEBUG_OBJECT (sink, "opened"); + + return TRUE; + + /* ERRORS */ +could_not_open: + { + if (status & JackServerFailed) { + GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, + (_("Jack server not found")), + ("Cannot connect to the Jack server (status %d)", status)); + } else { + GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, + (NULL), ("Jack client open error (status %d)", status)); + } + return FALSE; + } +} + +/* close the connection with the server + */ +static gboolean +gst_jack_ring_buffer_close_device (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (sink, "close"); + + gst_jack_audio_sink_free_channels (sink); + gst_jack_audio_client_free (sink->client); + sink->client = NULL; + + return TRUE; +} + +/* allocate a buffer and setup resources to process the audio samples of + * the format as specified in @spec. + * + * We allocate N jack ports, one for each channel. If we are asked to + * automatically make a connection with physical ports, we connect as many + * ports as there are physical ports, leaving leftover ports unconnected. + * + * It is assumed that samplerate and number of channels are acceptable since our + * getcaps method will always provide correct values. If unacceptable caps are + * received for some reason, we fail here. + */ +static gboolean +gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf, + GstAudioRingBufferSpec * spec) +{ + GstJackAudioSink *sink; + GstJackRingBuffer *abuf; + const char **ports; + gint sample_rate, buffer_size; + gint i, rate, bpf, channels, res; + jack_client_t *client; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + abuf = GST_JACK_RING_BUFFER_CAST (buf); + + GST_DEBUG_OBJECT (sink, "acquire"); + + client = gst_jack_audio_client_get_client (sink->client); + + rate = GST_AUDIO_INFO_RATE (&spec->info); + + /* sample rate must be that of the server */ + sample_rate = jack_get_sample_rate (client); + if (sample_rate != rate) + goto wrong_samplerate; + + channels = GST_AUDIO_INFO_CHANNELS (&spec->info); + bpf = GST_AUDIO_INFO_BPF (&spec->info); + + if (!gst_jack_audio_sink_allocate_channels (sink, channels)) + goto out_of_ports; + + buffer_size = jack_get_buffer_size (client); + + /* the segment size in bytes, this is large enough to hold a buffer of 32bit floats + * for all channels */ + spec->segsize = buffer_size * sizeof (gfloat) * channels; + spec->latency_time = gst_util_uint64_scale (spec->segsize, + (GST_SECOND / GST_USECOND), rate * bpf); + /* segtotal based on buffer-time latency */ + spec->segtotal = spec->buffer_time / spec->latency_time; + if (spec->segtotal < 2) { + spec->segtotal = 2; + spec->buffer_time = spec->latency_time * spec->segtotal; + } + + GST_DEBUG_OBJECT (sink, "buffer time: %" G_GINT64_FORMAT " usec", + spec->buffer_time); + GST_DEBUG_OBJECT (sink, "latency time: %" G_GINT64_FORMAT " usec", + spec->latency_time); + GST_DEBUG_OBJECT (sink, "buffer_size %d, segsize %d, segtotal %d", + buffer_size, spec->segsize, spec->segtotal); + + /* allocate the ringbuffer memory now */ + buf->size = spec->segtotal * spec->segsize; + buf->memory = g_malloc0 (buf->size); + + if ((res = gst_jack_audio_client_set_active (sink->client, TRUE))) + goto could_not_activate; + + /* if we need to automatically connect the ports, do so now. We must do this + * after activating the client. */ + if (sink->connect == GST_JACK_CONNECT_AUTO + || sink->connect == GST_JACK_CONNECT_AUTO_FORCED) { + /* find all the physical input ports. A physical input port is a port + * associated with a hardware device. Someone needs connect to a physical + * port in order to hear something. */ + ports = jack_get_ports (client, NULL, NULL, + JackPortIsPhysical | JackPortIsInput); + if (ports == NULL) { + /* no ports? fine then we don't do anything except for posting a warning + * message. */ + GST_ELEMENT_WARNING (sink, RESOURCE, NOT_FOUND, (NULL), + ("No physical input ports found, leaving ports unconnected")); + goto done; + } + + for (i = 0; i < channels; i++) { + /* stop when all input ports are exhausted */ + if (ports[i] == NULL) { + /* post a warning that we could not connect all ports */ + GST_ELEMENT_WARNING (sink, RESOURCE, NOT_FOUND, (NULL), + ("No more physical ports, leaving some ports unconnected")); + break; + } + GST_DEBUG_OBJECT (sink, "try connecting to %s", + jack_port_name (sink->ports[i])); + /* connect the port to a physical port */ + res = jack_connect (client, jack_port_name (sink->ports[i]), ports[i]); + if (res != 0 && res != EEXIST) + goto cannot_connect; + } + free (ports); + } +done: + + abuf->sample_rate = sample_rate; + abuf->buffer_size = buffer_size; + abuf->channels = channels; + + return TRUE; + + /* ERRORS */ +wrong_samplerate: + { + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL), + ("Wrong samplerate, server is running at %d and we received %d", + sample_rate, rate)); + return FALSE; + } +out_of_ports: + { + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL), + ("Cannot allocate more Jack ports")); + return FALSE; + } +could_not_activate: + { + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL), + ("Could not activate client (%d:%s)", res, g_strerror (res))); + return FALSE; + } +cannot_connect: + { + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL), + ("Could not connect output ports to physical ports (%d:%s)", + res, g_strerror (res))); + free (ports); + return FALSE; + } +} + +/* function is called with LOCK */ +static gboolean +gst_jack_ring_buffer_release (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + GstJackRingBuffer *abuf; + gint res; + + abuf = GST_JACK_RING_BUFFER_CAST (buf); + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (sink, "release"); + + if ((res = gst_jack_audio_client_set_active (sink->client, FALSE))) { + /* we only warn, this means the server is probably shut down and the client + * is gone anyway. */ + GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL), + ("Could not deactivate Jack client (%d)", res)); + } + + abuf->channels = -1; + abuf->buffer_size = -1; + abuf->sample_rate = -1; + + /* free the buffer */ + g_free (buf->memory); + buf->memory = NULL; + + return TRUE; +} + +static gboolean +gst_jack_ring_buffer_start (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (sink, "start"); + + if (sink->transport & GST_JACK_TRANSPORT_MASTER) { + jack_client_t *client; + + client = gst_jack_audio_client_get_client (sink->client); + jack_transport_start (client); + } + + return TRUE; +} + +static gboolean +gst_jack_ring_buffer_pause (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (sink, "pause"); + + if (sink->transport & GST_JACK_TRANSPORT_MASTER) { + jack_client_t *client; + + client = gst_jack_audio_client_get_client (sink->client); + jack_transport_stop (client); + } + + return TRUE; +} + +static gboolean +gst_jack_ring_buffer_stop (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (sink, "stop"); + + if (sink->transport & GST_JACK_TRANSPORT_MASTER) { + jack_client_t *client; + + client = gst_jack_audio_client_get_client (sink->client); + jack_transport_stop (client); + } + + return TRUE; +} + +#if defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7) +static guint +gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + guint i, res = 0; + jack_latency_range_t range; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + + for (i = 0; i < sink->port_count; i++) { + jack_port_get_latency_range (sink->ports[i], JackPlaybackLatency, &range); + if (range.max > res) + res = range.max; + } + + GST_LOG_OBJECT (sink, "delay %u", res); + + return res; +} +#else /* !(defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)) */ +static guint +gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf) +{ + GstJackAudioSink *sink; + guint i, res = 0; + guint latency; + jack_client_t *client; + + sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf)); + client = gst_jack_audio_client_get_client (sink->client); + + for (i = 0; i < sink->port_count; i++) { + latency = jack_port_get_total_latency (client, sink->ports[i]); + if (latency > res) + res = latency; + } + + GST_LOG_OBJECT (sink, "delay %u", res); + + return res; +} +#endif + +static GstStaticPadTemplate jackaudiosink_sink_factory = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " GST_JACK_FORMAT_STR ", " + "layout = (string) interleaved, " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]") + ); + +/* AudioSink signals and args */ +enum +{ + /* FILL ME */ + SIGNAL_LAST +}; + +#define DEFAULT_PROP_CONNECT GST_JACK_CONNECT_AUTO +#define DEFAULT_PROP_SERVER NULL +#define DEFAULT_PROP_CLIENT_NAME NULL +#define DEFAULT_PROP_TRANSPORT GST_JACK_TRANSPORT_AUTONOMOUS + +enum +{ + PROP_0, + PROP_CONNECT, + PROP_SERVER, + PROP_CLIENT, + PROP_CLIENT_NAME, + PROP_TRANSPORT, + PROP_LAST +}; + +#define gst_jack_audio_sink_parent_class parent_class +G_DEFINE_TYPE (GstJackAudioSink, gst_jack_audio_sink, GST_TYPE_AUDIO_BASE_SINK); + +static void gst_jack_audio_sink_dispose (GObject * object); +static void gst_jack_audio_sink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_jack_audio_sink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static GstCaps *gst_jack_audio_sink_getcaps (GstBaseSink * bsink, + GstCaps * filter); +static GstAudioRingBuffer + * gst_jack_audio_sink_create_ringbuffer (GstAudioBaseSink * sink); + +static void +gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + GstBaseSinkClass *gstbasesink_class; + GstAudioBaseSinkClass *gstaudiobasesink_class; + + GST_DEBUG_CATEGORY_INIT (gst_jack_audio_sink_debug, "jacksink", 0, + "jacksink element"); + + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + gstbasesink_class = (GstBaseSinkClass *) klass; + gstaudiobasesink_class = (GstAudioBaseSinkClass *) klass; + + gobject_class->dispose = gst_jack_audio_sink_dispose; + gobject_class->get_property = gst_jack_audio_sink_get_property; + gobject_class->set_property = gst_jack_audio_sink_set_property; + + g_object_class_install_property (gobject_class, PROP_CONNECT, + g_param_spec_enum ("connect", "Connect", + "Specify how the output ports will be connected", + GST_TYPE_JACK_CONNECT, DEFAULT_PROP_CONNECT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, PROP_SERVER, + g_param_spec_string ("server", "Server", + "The Jack server to connect to (NULL = default)", + DEFAULT_PROP_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** + * GstJackAudioSink:client-name: + * + * The client name to use. + */ + g_object_class_install_property (gobject_class, PROP_CLIENT_NAME, + g_param_spec_string ("client-name", "Client name", + "The client name of the Jack instance (NULL = default)", + DEFAULT_PROP_CLIENT_NAME, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, PROP_CLIENT, + g_param_spec_boxed ("client", "JackClient", "Handle for jack client", + GST_TYPE_JACK_CLIENT, + GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + /** + * GstJackAudioSink:transport: + * + * The jack transport behaviour for the client. + */ + g_object_class_install_property (gobject_class, PROP_TRANSPORT, + g_param_spec_flags ("transport", "Transport mode", + "Jack transport behaviour of the client", + GST_TYPE_JACK_TRANSPORT, DEFAULT_PROP_TRANSPORT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + gst_element_class_set_static_metadata (gstelement_class, "Audio Sink (Jack)", + "Sink/Audio", "Output audio to a JACK server", + "Wim Taymans <wim.taymans@gmail.com>"); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&jackaudiosink_sink_factory)); + + gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_sink_getcaps); + + gstaudiobasesink_class->create_ringbuffer = + GST_DEBUG_FUNCPTR (gst_jack_audio_sink_create_ringbuffer); + + /* ref class from a thread-safe context to work around missing bit of + * thread-safety in GObject */ + g_type_class_ref (GST_TYPE_JACK_RING_BUFFER); + + gst_jack_audio_client_init (); +} + +static void +gst_jack_audio_sink_init (GstJackAudioSink * sink) +{ + sink->connect = DEFAULT_PROP_CONNECT; + sink->server = g_strdup (DEFAULT_PROP_SERVER); + sink->jclient = NULL; + sink->ports = NULL; + sink->port_count = 0; + sink->buffers = NULL; + sink->client_name = g_strdup (DEFAULT_PROP_CLIENT_NAME); + sink->transport = DEFAULT_PROP_TRANSPORT; +} + +static void +gst_jack_audio_sink_dispose (GObject * object) +{ + GstJackAudioSink *sink = GST_JACK_AUDIO_SINK (object); + + gst_caps_replace (&sink->caps, NULL); + + if (sink->client_name != NULL) { + g_free (sink->client_name); + sink->client_name = NULL; + } + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +gst_jack_audio_sink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstJackAudioSink *sink; + + sink = GST_JACK_AUDIO_SINK (object); + + switch (prop_id) { + case PROP_CLIENT_NAME: + g_free (sink->client_name); + sink->client_name = g_value_dup_string (value); + break; + case PROP_CONNECT: + sink->connect = g_value_get_enum (value); + break; + case PROP_SERVER: + g_free (sink->server); + sink->server = g_value_dup_string (value); + break; + case PROP_CLIENT: + if (GST_STATE (sink) == GST_STATE_NULL || + GST_STATE (sink) == GST_STATE_READY) { + sink->jclient = g_value_get_boxed (value); + } + break; + case PROP_TRANSPORT: + sink->transport = g_value_get_flags (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_jack_audio_sink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstJackAudioSink *sink; + + sink = GST_JACK_AUDIO_SINK (object); + + switch (prop_id) { + case PROP_CLIENT_NAME: + g_value_set_string (value, sink->client_name); + break; + case PROP_CONNECT: + g_value_set_enum (value, sink->connect); + break; + case PROP_SERVER: + g_value_set_string (value, sink->server); + break; + case PROP_CLIENT: + g_value_set_boxed (value, sink->jclient); + break; + case PROP_TRANSPORT: + g_value_set_flags (value, sink->transport); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GstCaps * +gst_jack_audio_sink_getcaps (GstBaseSink * bsink, GstCaps * filter) +{ + GstJackAudioSink *sink = GST_JACK_AUDIO_SINK (bsink); + const char **ports; + gint min, max; + gint rate; + jack_client_t *client; + + if (sink->client == NULL) + goto no_client; + + client = gst_jack_audio_client_get_client (sink->client); + + if (sink->connect == GST_JACK_CONNECT_AUTO) { + /* get a port count, this is the number of channels we can automatically + * connect. */ + ports = jack_get_ports (client, NULL, NULL, + JackPortIsPhysical | JackPortIsInput); + max = 0; + if (ports != NULL) { + for (; ports[max]; max++); + free (ports); + } else + max = 0; + } else { + /* we allow any number of pads, something else is going to connect the + * pads. */ + max = G_MAXINT; + } + min = MIN (1, max); + + rate = jack_get_sample_rate (client); + + GST_DEBUG_OBJECT (sink, "got %d-%d ports, samplerate: %d", min, max, rate); + + if (!sink->caps) { + sink->caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, GST_JACK_FORMAT_STR, + "layout", G_TYPE_STRING, "interleaved", + "rate", G_TYPE_INT, rate, + "channels", GST_TYPE_INT_RANGE, min, max, NULL); + } + GST_INFO_OBJECT (sink, "returning caps %" GST_PTR_FORMAT, sink->caps); + + return gst_caps_ref (sink->caps); + + /* ERRORS */ +no_client: + { + GST_DEBUG_OBJECT (sink, "device not open, using template caps"); + /* base class will get template caps for us when we return NULL */ + return NULL; + } +} + +static GstAudioRingBuffer * +gst_jack_audio_sink_create_ringbuffer (GstAudioBaseSink * sink) +{ + GstAudioRingBuffer *buffer; + + buffer = g_object_new (GST_TYPE_JACK_RING_BUFFER, NULL); + GST_DEBUG_OBJECT (sink, "created ringbuffer @%p", buffer); + + return buffer; +} diff --git a/ext/jack/gstjackaudiosink.h b/ext/jack/gstjackaudiosink.h new file mode 100644 index 0000000..b2377c4 --- /dev/null +++ b/ext/jack/gstjackaudiosink.h @@ -0,0 +1,81 @@ +/* GStreamer + * Copyright (C) 2006 Wim Taymans <wim@fluendo.com> + * + * gstjacksink.h: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_JACK_AUDIO_SINK_H__ +#define __GST_JACK_AUDIO_SINK_H__ + +#include <jack/jack.h> + +#include <gst/gst.h> +#include <gst/audio/gstaudiobasesink.h> + +#include "gstjack.h" +#include "gstjackaudioclient.h" + +G_BEGIN_DECLS + +#define GST_TYPE_JACK_AUDIO_SINK (gst_jack_audio_sink_get_type()) +#define GST_JACK_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JACK_AUDIO_SINK,GstJackAudioSink)) +#define GST_JACK_AUDIO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JACK_AUDIO_SINK,GstJackAudioSinkClass)) +#define GST_JACK_AUDIO_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_JACK_AUDIO_SINK,GstJackAudioSinkClass)) +#define GST_IS_JACK_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JACK_AUDIO_SINK)) +#define GST_IS_JACK_AUDIO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JACK_AUDIO_SINK)) + +typedef struct _GstJackAudioSink GstJackAudioSink; +typedef struct _GstJackAudioSinkClass GstJackAudioSinkClass; + +/** + * GstJackAudioSink: + * + * Opaque #GstJackAudioSink. + */ +struct _GstJackAudioSink { + GstAudioBaseSink element; + + /*< private >*/ + /* cached caps */ + GstCaps *caps; + + /* properties */ + GstJackConnect connect; + gchar *server; + jack_client_t *jclient; + gchar *client_name; + guint transport; + + /* our client */ + GstJackAudioClient *client; + + /* our ports */ + jack_port_t **ports; + int port_count; + sample_t **buffers; +}; + +struct _GstJackAudioSinkClass { + GstAudioBaseSinkClass parent_class; +}; + +GType gst_jack_audio_sink_get_type (void); + +G_END_DECLS + +#endif /* __GST_JACK_AUDIO_SINK_H__ */ diff --git a/ext/jack/gstjackaudiosrc.c b/ext/jack/gstjackaudiosrc.c new file mode 100755 index 0000000..5a3bfb5 --- /dev/null +++ b/ext/jack/gstjackaudiosrc.c @@ -0,0 +1,961 @@ +/* GStreamer + * Copyright (C) 2008 Tristan Matthews <tristan@sat.qc.ca> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Alternatively, the contents of this file may be used under the + * GNU Lesser General Public License Version 2.1 (the "LGPL"), in + * which case the following provisions apply instead of the ones + * mentioned above: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * SECTION:element-jackaudiosrc + * @see_also: #GstAudioBaseSrc, #GstAudioRingBuffer + * + * A Src that inputs data from Jack ports. + * + * It will create N Jack ports named in_<name>_<num> where + * <name> is the element name and <num> is starting from 1. + * Each port corresponds to a gstreamer channel. + * + * The samplerate as exposed on the caps is always the same as the samplerate of + * the jack server. + * + * When the #GstJackAudioSrc:connect property is set to auto, this element + * will try to connect each input port to a random physical jack output pin. + * + * When the #GstJackAudioSrc:connect property is set to none, the element will + * accept any number of output channels and will create (but not connect) an + * input port for each channel. + * + * The element will generate an error when the Jack server is shut down when it + * was PAUSED or PLAYING. This element does not support dynamic rate and buffer + * size changes at runtime. + * + * <refsect2> + * <title>Example launch line</title> + * |[ + * gst-launch-1.0 jackaudiosrc connect=0 ! jackaudiosink connect=0 + * ]| Get audio input into gstreamer from jack. + * </refsect2> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gst/gst-i18n-plugin.h> +#include <stdlib.h> +#include <string.h> + +#include <gst/audio/audio.h> + +#include "gstjackaudiosrc.h" +#include "gstjackringbuffer.h" +#include "gstjackutil.h" + +GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_src_debug); +#define GST_CAT_DEFAULT gst_jack_audio_src_debug + +static gboolean +gst_jack_audio_src_allocate_channels (GstJackAudioSrc * src, gint channels) +{ + jack_client_t *client; + + client = gst_jack_audio_client_get_client (src->client); + + /* remove ports we don't need */ + while (src->port_count > channels) + jack_port_unregister (client, src->ports[--src->port_count]); + + /* alloc enough input ports */ + src->ports = g_realloc (src->ports, sizeof (jack_port_t *) * channels); + src->buffers = g_realloc (src->buffers, sizeof (sample_t *) * channels); + + /* create an input port for each channel */ + while (src->port_count < channels) { + gchar *name; + + /* port names start from 1 and are local to the element */ + name = + g_strdup_printf ("in_%s_%d", GST_ELEMENT_NAME (src), + src->port_count + 1); + src->ports[src->port_count] = + jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE, + JackPortIsInput, 0); + if (src->ports[src->port_count] == NULL) + return FALSE; + + src->port_count++; + + g_free (name); + } + return TRUE; +} + +static void +gst_jack_audio_src_free_channels (GstJackAudioSrc * src) +{ + gint res, i = 0; + jack_client_t *client; + + client = gst_jack_audio_client_get_client (src->client); + + /* get rid of all ports */ + while (src->port_count) { + GST_LOG_OBJECT (src, "unregister port %d", i); + if ((res = jack_port_unregister (client, src->ports[i++]))) + GST_DEBUG_OBJECT (src, "unregister of port failed (%d)", res); + + src->port_count--; + } + g_free (src->ports); + src->ports = NULL; + g_free (src->buffers); + src->buffers = NULL; +} + +/* ringbuffer abstract base class */ +static GType +gst_jack_ring_buffer_get_type (void) +{ + static volatile gsize ringbuffer_type = 0; + + if (g_once_init_enter (&ringbuffer_type)) { + static const GTypeInfo ringbuffer_info = { sizeof (GstJackRingBufferClass), + NULL, + NULL, + (GClassInitFunc) gst_jack_ring_buffer_class_init, + NULL, + NULL, + sizeof (GstJackRingBuffer), + 0, + (GInstanceInitFunc) gst_jack_ring_buffer_init, + NULL + }; + GType tmp = g_type_register_static (GST_TYPE_AUDIO_RING_BUFFER, + "GstJackAudioSrcRingBuffer", &ringbuffer_info, 0); + g_once_init_leave (&ringbuffer_type, tmp); + } + + return (GType) ringbuffer_type; +} + +static void +gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass) +{ + GstAudioRingBufferClass *gstringbuffer_class; + + gstringbuffer_class = (GstAudioRingBufferClass *) klass; + + ring_parent_class = g_type_class_peek_parent (klass); + + gstringbuffer_class->open_device = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_open_device); + gstringbuffer_class->close_device = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_close_device); + gstringbuffer_class->acquire = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_acquire); + gstringbuffer_class->release = + GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_release); + gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start); + gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_pause); + gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start); + gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_stop); + + gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_delay); +} + +/* this is the callback of jack. This should be RT-safe. + * Writes samples from the jack input port's buffer to the gst ring buffer. + */ +static int +jack_process_cb (jack_nframes_t nframes, void *arg) +{ + GstJackAudioSrc *src; + GstAudioRingBuffer *buf; + gint len; + guint8 *writeptr; + gint writeseg; + gint channels, i, j, flen; + sample_t *data; + + buf = GST_AUDIO_RING_BUFFER_CAST (arg); + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info); + + /* get input buffers */ + for (i = 0; i < channels; i++) + src->buffers[i] = + (sample_t *) jack_port_get_buffer (src->ports[i], nframes); + + if (gst_audio_ring_buffer_prepare_read (buf, &writeseg, &writeptr, &len)) { + flen = len / channels; + + /* the number of samples must be exactly the segment size */ + if (nframes * sizeof (sample_t) != flen) + goto wrong_size; + + /* the samples in the jack input buffers have to be interleaved into the + * ringbuffer */ + data = (sample_t *) writeptr; + for (i = 0; i < nframes; ++i) + for (j = 0; j < channels; ++j) + *data++ = src->buffers[j][i]; + + GST_DEBUG ("copy %d frames: %p, %d bytes, %d channels", nframes, writeptr, + len / channels, channels); + + /* we wrote one segment */ + gst_audio_ring_buffer_advance (buf, 1); + } + return 0; + + /* ERRORS */ +wrong_size: + { + GST_ERROR_OBJECT (src, "nbytes (%d) != flen (%d)", + (gint) (nframes * sizeof (sample_t)), flen); + return 1; + } +} + +/* we error out */ +static int +jack_sample_rate_cb (jack_nframes_t nframes, void *arg) +{ + GstJackAudioSrc *src; + GstJackRingBuffer *abuf; + + abuf = GST_JACK_RING_BUFFER_CAST (arg); + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg)); + + if (abuf->sample_rate != -1 && abuf->sample_rate != nframes) + goto not_supported; + + return 0; + + /* ERRORS */ +not_supported: + { + GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, + (NULL), ("Jack changed the sample rate, which is not supported")); + return 1; + } +} + +/* we error out */ +static int +jack_buffer_size_cb (jack_nframes_t nframes, void *arg) +{ + GstJackAudioSrc *src; + GstJackRingBuffer *abuf; + + abuf = GST_JACK_RING_BUFFER_CAST (arg); + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg)); + + if (abuf->buffer_size != -1 && abuf->buffer_size != nframes) + goto not_supported; + + return 0; + + /* ERRORS */ +not_supported: + { + GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, + (NULL), ("Jack changed the buffer size, which is not supported")); + return 1; + } +} + +static void +jack_shutdown_cb (void *arg) +{ + GstJackAudioSrc *src; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg)); + + GST_DEBUG_OBJECT (src, "shutdown"); + + GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, + (NULL), ("Jack server shutdown")); +} + +static void +gst_jack_ring_buffer_init (GstJackRingBuffer * buf, + GstJackRingBufferClass * g_class) +{ + buf->channels = -1; + buf->buffer_size = -1; + buf->sample_rate = -1; +} + +/* the _open_device method should make a connection with the server +*/ +static gboolean +gst_jack_ring_buffer_open_device (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + jack_status_t status = 0; + const gchar *name; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (src, "open"); + + if (src->client_name) { + name = src->client_name; + } else { + name = g_get_application_name (); + } + if (!name) + name = "GStreamer"; + + src->client = gst_jack_audio_client_new (name, src->server, + src->jclient, + GST_JACK_CLIENT_SOURCE, + jack_shutdown_cb, + jack_process_cb, jack_buffer_size_cb, jack_sample_rate_cb, buf, &status); + if (src->client == NULL) + goto could_not_open; + + GST_DEBUG_OBJECT (src, "opened"); + + return TRUE; + + /* ERRORS */ +could_not_open: + { + if (status & (JackServerFailed | JackFailure)) { + GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, + (_("Jack server not found")), + ("Cannot connect to the Jack server (status %d)", status)); + } else { + GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, + (NULL), ("Jack client open error (status %d)", status)); + } + return FALSE; + } +} + +/* close the connection with the server +*/ +static gboolean +gst_jack_ring_buffer_close_device (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (src, "close"); + + gst_jack_audio_src_free_channels (src); + gst_jack_audio_client_free (src->client); + src->client = NULL; + + return TRUE; +} + + +/* allocate a buffer and setup resources to process the audio samples of + * the format as specified in @spec. + * + * We allocate N jack ports, one for each channel. If we are asked to + * automatically make a connection with physical ports, we connect as many + * ports as there are physical ports, leaving leftover ports unconnected. + * + * It is assumed that samplerate and number of channels are acceptable since our + * getcaps method will always provide correct values. If unacceptable caps are + * received for some reason, we fail here. + */ +static gboolean +gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf, + GstAudioRingBufferSpec * spec) +{ + GstJackAudioSrc *src; + GstJackRingBuffer *abuf; + const char **ports; + gint sample_rate, buffer_size; + gint i, bpf, rate, channels, res; + jack_client_t *client; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + abuf = GST_JACK_RING_BUFFER_CAST (buf); + + GST_DEBUG_OBJECT (src, "acquire"); + + client = gst_jack_audio_client_get_client (src->client); + + rate = GST_AUDIO_INFO_RATE (&spec->info); + + /* sample rate must be that of the server */ + sample_rate = jack_get_sample_rate (client); + if (sample_rate != rate) + goto wrong_samplerate; + + bpf = GST_AUDIO_INFO_BPF (&spec->info); + channels = GST_AUDIO_INFO_CHANNELS (&spec->info); + + if (!gst_jack_audio_src_allocate_channels (src, channels)) + goto out_of_ports; + + gst_jack_set_layout (buf, spec); + + buffer_size = jack_get_buffer_size (client); + + /* the segment size in bytes, this is large enough to hold a buffer of 32bit floats + * for all channels */ + spec->segsize = buffer_size * sizeof (gfloat) * channels; + spec->latency_time = gst_util_uint64_scale (spec->segsize, + (GST_SECOND / GST_USECOND), rate * bpf); + /* segtotal based on buffer-time latency */ + spec->segtotal = spec->buffer_time / spec->latency_time; + if (spec->segtotal < 2) { + spec->segtotal = 2; + spec->buffer_time = spec->latency_time * spec->segtotal; + } + + GST_DEBUG_OBJECT (src, "buffer time: %" G_GINT64_FORMAT " usec", + spec->buffer_time); + GST_DEBUG_OBJECT (src, "latency time: %" G_GINT64_FORMAT " usec", + spec->latency_time); + GST_DEBUG_OBJECT (src, "buffer_size %d, segsize %d, segtotal %d", + buffer_size, spec->segsize, spec->segtotal); + + /* allocate the ringbuffer memory now */ + buf->size = spec->segtotal * spec->segsize; + buf->memory = g_malloc0 (buf->size); + + if ((res = gst_jack_audio_client_set_active (src->client, TRUE))) + goto could_not_activate; + + /* if we need to automatically connect the ports, do so now. We must do this + * after activating the client. */ + if (src->connect == GST_JACK_CONNECT_AUTO + || src->connect == GST_JACK_CONNECT_AUTO_FORCED) { + /* find all the physical output ports. A physical output port is a port + * associated with a hardware device. Someone needs connect to a physical + * port in order to capture something. */ + ports = + jack_get_ports (client, NULL, NULL, + JackPortIsPhysical | JackPortIsOutput); + if (ports == NULL) { + /* no ports? fine then we don't do anything except for posting a warning + * message. */ + GST_ELEMENT_WARNING (src, RESOURCE, NOT_FOUND, (NULL), + ("No physical output ports found, leaving ports unconnected")); + goto done; + } + + for (i = 0; i < channels; i++) { + /* stop when all output ports are exhausted */ + if (ports[i] == NULL) { + /* post a warning that we could not connect all ports */ + GST_ELEMENT_WARNING (src, RESOURCE, NOT_FOUND, (NULL), + ("No more physical ports, leaving some ports unconnected")); + break; + } + GST_DEBUG_OBJECT (src, "try connecting to %s", + jack_port_name (src->ports[i])); + + /* connect the physical port to a port */ + res = jack_connect (client, ports[i], jack_port_name (src->ports[i])); + if (res != 0 && res != EEXIST) + goto cannot_connect; + } + free (ports); + } +done: + + abuf->sample_rate = sample_rate; + abuf->buffer_size = buffer_size; + abuf->channels = channels; + + return TRUE; + + /* ERRORS */ +wrong_samplerate: + { + GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL), + ("Wrong samplerate, server is running at %d and we received %d", + sample_rate, rate)); + return FALSE; + } +out_of_ports: + { + GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL), + ("Cannot allocate more Jack ports")); + return FALSE; + } +could_not_activate: + { + GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL), + ("Could not activate client (%d:%s)", res, g_strerror (res))); + return FALSE; + } +cannot_connect: + { + GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL), + ("Could not connect input ports to physical ports (%d:%s)", + res, g_strerror (res))); + free (ports); + return FALSE; + } +} + +/* function is called with LOCK */ +static gboolean +gst_jack_ring_buffer_release (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + GstJackRingBuffer *abuf; + gint res; + + abuf = GST_JACK_RING_BUFFER_CAST (buf); + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (src, "release"); + + if ((res = gst_jack_audio_client_set_active (src->client, FALSE))) { + /* we only warn, this means the server is probably shut down and the client + * is gone anyway. */ + GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL), + ("Could not deactivate Jack client (%d)", res)); + } + + abuf->channels = -1; + abuf->buffer_size = -1; + abuf->sample_rate = -1; + + /* free the buffer */ + g_free (buf->memory); + buf->memory = NULL; + + return TRUE; +} + +static gboolean +gst_jack_ring_buffer_start (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (src, "start"); + + if (src->transport & GST_JACK_TRANSPORT_MASTER) { + jack_client_t *client; + + client = gst_jack_audio_client_get_client (src->client); + jack_transport_start (client); + } + + return TRUE; +} + +static gboolean +gst_jack_ring_buffer_pause (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (src, "pause"); + + if (src->transport & GST_JACK_TRANSPORT_MASTER) { + jack_client_t *client; + + client = gst_jack_audio_client_get_client (src->client); + jack_transport_stop (client); + } + + return TRUE; +} + +static gboolean +gst_jack_ring_buffer_stop (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + GST_DEBUG_OBJECT (src, "stop"); + + if (src->transport & GST_JACK_TRANSPORT_MASTER) { + jack_client_t *client; + + client = gst_jack_audio_client_get_client (src->client); + jack_transport_stop (client); + } + + return TRUE; +} + +#if defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7) +static guint +gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + guint i, res = 0; + jack_latency_range_t range; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + for (i = 0; i < src->port_count; i++) { + jack_port_get_latency_range (src->ports[i], JackCaptureLatency, &range); + if (range.max > res) + res = range.max; + } + + GST_DEBUG_OBJECT (src, "delay %u", res); + + return res; +} +#else /* !(defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)) */ +static guint +gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf) +{ + GstJackAudioSrc *src; + guint i, res = 0; + guint latency; + jack_client_t *client; + + src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf)); + + client = gst_jack_audio_client_get_client (src->client); + + for (i = 0; i < src->port_count; i++) { + latency = jack_port_get_total_latency (client, src->ports[i]); + if (latency > res) + res = latency; + } + + GST_DEBUG_OBJECT (src, "delay %u", res); + + return res; +} +#endif + +/* Audiosrc signals and args */ +enum +{ + /* FILL ME */ + LAST_SIGNAL +}; + +#define DEFAULT_PROP_CONNECT GST_JACK_CONNECT_AUTO +#define DEFAULT_PROP_SERVER NULL +#define DEFAULT_PROP_CLIENT_NAME NULL +#define DEFAULT_PROP_TRANSPORT GST_JACK_TRANSPORT_AUTONOMOUS + +enum +{ + PROP_0, + PROP_CONNECT, + PROP_SERVER, + PROP_CLIENT, + PROP_CLIENT_NAME, + PROP_TRANSPORT, + PROP_LAST +}; + + +/* the capabilities of the inputs and outputs. + * + * describe the real formats here. + */ + +static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " GST_JACK_FORMAT_STR ", " + "layout = (string) interleaved, " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]") + ); + +#define gst_jack_audio_src_parent_class parent_class +G_DEFINE_TYPE (GstJackAudioSrc, gst_jack_audio_src, GST_TYPE_AUDIO_BASE_SRC); + +static void gst_jack_audio_src_dispose (GObject * object); +static void gst_jack_audio_src_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_jack_audio_src_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static GstCaps *gst_jack_audio_src_getcaps (GstBaseSrc * bsrc, + GstCaps * filter); +static GstAudioRingBuffer *gst_jack_audio_src_create_ringbuffer (GstAudioBaseSrc + * src); + +/* GObject vmethod implementations */ + +/* initialize the jack_audio_src's class */ +static void +gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + GstBaseSrcClass *gstbasesrc_class; + GstAudioBaseSrcClass *gstaudiobasesrc_class; + + GST_DEBUG_CATEGORY_INIT (gst_jack_audio_src_debug, "jacksrc", 0, + "jacksrc element"); + + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + gstbasesrc_class = (GstBaseSrcClass *) klass; + gstaudiobasesrc_class = (GstAudioBaseSrcClass *) klass; + + gobject_class->dispose = gst_jack_audio_src_dispose; + gobject_class->set_property = gst_jack_audio_src_set_property; + gobject_class->get_property = gst_jack_audio_src_get_property; + + g_object_class_install_property (gobject_class, PROP_CONNECT, + g_param_spec_enum ("connect", "Connect", + "Specify how the input ports will be connected", + GST_TYPE_JACK_CONNECT, DEFAULT_PROP_CONNECT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, PROP_SERVER, + g_param_spec_string ("server", "Server", + "The Jack server to connect to (NULL = default)", + DEFAULT_PROP_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** + * GstJackAudioSrc:client-name: + * + * The client name to use. + */ + g_object_class_install_property (gobject_class, PROP_CLIENT_NAME, + g_param_spec_string ("client-name", "Client name", + "The client name of the Jack instance (NULL = default)", + DEFAULT_PROP_CLIENT_NAME, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, PROP_CLIENT, + g_param_spec_boxed ("client", "JackClient", "Handle for jack client", + GST_TYPE_JACK_CLIENT, + GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + /** + * GstJackAudioSink:transport: + * + * The jack transport behaviour for the client. + */ + g_object_class_install_property (gobject_class, PROP_TRANSPORT, + g_param_spec_flags ("transport", "Transport mode", + "Jack transport behaviour of the client", + GST_TYPE_JACK_TRANSPORT, DEFAULT_PROP_TRANSPORT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&src_factory)); + + gst_element_class_set_static_metadata (gstelement_class, + "Audio Source (Jack)", "Source/Audio", + "Captures audio from a JACK server", + "Tristan Matthews <tristan@sat.qc.ca>"); + + gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_src_getcaps); + gstaudiobasesrc_class->create_ringbuffer = + GST_DEBUG_FUNCPTR (gst_jack_audio_src_create_ringbuffer); + + /* ref class from a thread-safe context to work around missing bit of + * thread-safety in GObject */ + g_type_class_ref (GST_TYPE_JACK_RING_BUFFER); + + gst_jack_audio_client_init (); +} + +static void +gst_jack_audio_src_init (GstJackAudioSrc * src) +{ + //gst_base_src_set_live(GST_BASE_SRC (src), TRUE); + src->connect = DEFAULT_PROP_CONNECT; + src->server = g_strdup (DEFAULT_PROP_SERVER); + src->jclient = NULL; + src->ports = NULL; + src->port_count = 0; + src->buffers = NULL; + src->client_name = g_strdup (DEFAULT_PROP_CLIENT_NAME); + src->transport = DEFAULT_PROP_TRANSPORT; +} + +static void +gst_jack_audio_src_dispose (GObject * object) +{ + GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object); + + gst_caps_replace (&src->caps, NULL); + + if (src->client_name != NULL) { + g_free (src->client_name); + src->client_name = NULL; + } + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +gst_jack_audio_src_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object); + + switch (prop_id) { + case PROP_CLIENT_NAME: + g_free (src->client_name); + src->client_name = g_value_dup_string (value); + break; + case PROP_CONNECT: + src->connect = g_value_get_enum (value); + break; + case PROP_SERVER: + g_free (src->server); + src->server = g_value_dup_string (value); + break; + case PROP_CLIENT: + if (GST_STATE (src) == GST_STATE_NULL || + GST_STATE (src) == GST_STATE_READY) { + src->jclient = g_value_get_boxed (value); + } + break; + case PROP_TRANSPORT: + src->transport = g_value_get_flags (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_jack_audio_src_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object); + + switch (prop_id) { + case PROP_CLIENT_NAME: + g_value_set_string (value, src->client_name); + break; + case PROP_CONNECT: + g_value_set_enum (value, src->connect); + break; + case PROP_SERVER: + g_value_set_string (value, src->server); + break; + case PROP_CLIENT: + g_value_set_boxed (value, src->jclient); + break; + case PROP_TRANSPORT: + g_value_set_flags (value, src->transport); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GstCaps * +gst_jack_audio_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter) +{ + GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (bsrc); + const char **ports; + gint min, max; + gint rate; + jack_client_t *client; + + if (src->client == NULL) + goto no_client; + + client = gst_jack_audio_client_get_client (src->client); + + if (src->connect == GST_JACK_CONNECT_AUTO) { + /* get a port count, this is the number of channels we can automatically + * connect. */ + ports = jack_get_ports (client, NULL, NULL, + JackPortIsPhysical | JackPortIsOutput); + max = 0; + if (ports != NULL) { + for (; ports[max]; max++); + + free (ports); + } else + max = 0; + } else { + /* we allow any number of pads, something else is going to connect the + * pads. */ + max = G_MAXINT; + } + min = MIN (1, max); + + rate = jack_get_sample_rate (client); + + GST_DEBUG_OBJECT (src, "got %d-%d ports, samplerate: %d", min, max, rate); + + if (!src->caps) { + src->caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, GST_JACK_FORMAT_STR, + "layout", G_TYPE_STRING, "interleaved", + "rate", G_TYPE_INT, rate, + "channels", GST_TYPE_INT_RANGE, min, max, NULL); + } + GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, src->caps); + + return gst_caps_ref (src->caps); + + /* ERRORS */ +no_client: + { + GST_DEBUG_OBJECT (src, "device not open, using template caps"); + /* base class will get template caps for us when we return NULL */ + return NULL; + } +} + +static GstAudioRingBuffer * +gst_jack_audio_src_create_ringbuffer (GstAudioBaseSrc * src) +{ + GstAudioRingBuffer *buffer; + + buffer = g_object_new (GST_TYPE_JACK_RING_BUFFER, NULL); + GST_DEBUG_OBJECT (src, "created ringbuffer @%p", buffer); + + return buffer; +} diff --git a/ext/jack/gstjackaudiosrc.h b/ext/jack/gstjackaudiosrc.h new file mode 100644 index 0000000..97c2891 --- /dev/null +++ b/ext/jack/gstjackaudiosrc.h @@ -0,0 +1,99 @@ +/* GStreamer + * Copyright (C) 2008 Tristan Matthews <tristan@sat.qc.ca> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Alternatively, the contents of this file may be used under the + * GNU Lesser General Public License Version 2.1 (the "LGPL"), in + * which case the following provisions apply instead of the ones + * mentioned above: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_JACK_AUDIO_SRC_H__ +#define __GST_JACK_AUDIO_SRC_H__ + +#include <jack/jack.h> + +#include <gst/gst.h> +#include <gst/audio/gstaudiosrc.h> + +#include "gstjackaudioclient.h" +#include "gstjack.h" + +G_BEGIN_DECLS + +#define GST_TYPE_JACK_AUDIO_SRC (gst_jack_audio_src_get_type()) +#define GST_JACK_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JACK_AUDIO_SRC,GstJackAudioSrc)) +#define GST_JACK_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JACK_AUDIO_SRC,GstJackAudioSrcClass)) +#define GST_JACK_AUDIO_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_JACK_AUDIO_SRC,GstJackAudioSrcClass)) +#define GST_IS_JACK_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JACK_AUDIO_SRC)) +#define GST_IS_JACK_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JACK_AUDIO_SRC)) + +typedef struct _GstJackAudioSrc GstJackAudioSrc; +typedef struct _GstJackAudioSrcClass GstJackAudioSrcClass; + +struct _GstJackAudioSrc +{ + GstAudioBaseSrc src; + + /*< private >*/ + /* cached caps */ + GstCaps *caps; + + /* properties */ + GstJackConnect connect; + gchar *server; + jack_client_t *jclient; + gchar *client_name; + guint transport; + + /* our client */ + GstJackAudioClient *client; + + /* our ports */ + jack_port_t **ports; + int port_count; + sample_t **buffers; +}; + +struct _GstJackAudioSrcClass +{ + GstAudioBaseSrcClass parent_class; +}; + +GType gst_jack_audio_src_get_type (void); + +G_END_DECLS + +#endif /* __GST_JACK_AUDIO_SRC_H__ */ diff --git a/ext/jack/gstjackringbuffer.h b/ext/jack/gstjackringbuffer.h new file mode 100644 index 0000000..94de4b8 --- /dev/null +++ b/ext/jack/gstjackringbuffer.h @@ -0,0 +1,88 @@ +/* + * GStreamer + * Copyright (C) 2006 Wim Taymans <wim@fluendo.com> + * Copyright (C) 2008 Tristan Matthews <tristan@sat.qc.ca> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Alternatively, the contents of this file may be used under the + * GNU Lesser General Public License Version 2.1 (the "LGPL"), in + * which case the following provisions apply instead of the ones + * mentioned above: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_JACK_RING_BUFFER_H__ +#define __GST_JACK_RING_BUFFER_H__ + +#define GST_TYPE_JACK_RING_BUFFER (gst_jack_ring_buffer_get_type()) +#define GST_JACK_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JACK_RING_BUFFER,GstJackRingBuffer)) +#define GST_JACK_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JACK_RING_BUFFER,GstJackRingBufferClass)) +#define GST_JACK_RING_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_JACK_RING_BUFFER,GstJackRingBufferClass)) +#define GST_JACK_RING_BUFFER_CAST(obj) ((GstJackRingBuffer *)obj) +#define GST_IS_JACK_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JACK_RING_BUFFER)) +#define GST_IS_JACK_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JACK_RING_BUFFER)) + +typedef struct _GstJackRingBuffer GstJackRingBuffer; +typedef struct _GstJackRingBufferClass GstJackRingBufferClass; + +struct _GstJackRingBuffer +{ + GstAudioRingBuffer object; + + gint sample_rate; + gint buffer_size; + gint channels; +}; + +struct _GstJackRingBufferClass +{ + GstAudioRingBufferClass parent_class; +}; + +static void gst_jack_ring_buffer_class_init(GstJackRingBufferClass * klass); +static void gst_jack_ring_buffer_init(GstJackRingBuffer * ringbuffer, + GstJackRingBufferClass * klass); + +static GstAudioRingBufferClass *ring_parent_class = NULL; + +static gboolean gst_jack_ring_buffer_open_device(GstAudioRingBuffer * buf); +static gboolean gst_jack_ring_buffer_close_device(GstAudioRingBuffer * buf); +static gboolean gst_jack_ring_buffer_acquire(GstAudioRingBuffer * buf,GstAudioRingBufferSpec * spec); +static gboolean gst_jack_ring_buffer_release(GstAudioRingBuffer * buf); +static gboolean gst_jack_ring_buffer_start(GstAudioRingBuffer * buf); +static gboolean gst_jack_ring_buffer_pause(GstAudioRingBuffer * buf); +static gboolean gst_jack_ring_buffer_stop(GstAudioRingBuffer * buf); +static guint gst_jack_ring_buffer_delay(GstAudioRingBuffer * buf); + +#endif diff --git a/ext/jack/gstjackutil.c b/ext/jack/gstjackutil.c new file mode 100644 index 0000000..490e14a --- /dev/null +++ b/ext/jack/gstjackutil.c @@ -0,0 +1,110 @@ +/* GStreamer Jack utility functions + * Copyright (C) 2010 Tristan Matthews <tristan@sat.qc.ca> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "gstjackutil.h" +#include <gst/audio/audio.h> + +static const GstAudioChannelPosition default_positions[8][8] = { + /* 1 channel */ + { + GST_AUDIO_CHANNEL_POSITION_MONO, + }, + /* 2 channels */ + { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + }, + /* 3 channels (2.1) */ + { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, /* or FRONT_CENTER for 3.0? */ + }, + /* 4 channels (4.0 or 3.1?) */ + { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + }, + /* 5 channels */ + { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + }, + /* 6 channels */ + { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }, + /* 7 channels */ + { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_LFE1, + GST_AUDIO_CHANNEL_POSITION_REAR_CENTER, + }, + /* 8 channels */ + { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_LFE1, + GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, + GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, + } +}; + + +/* if channels are less than or equal to 8, we set a default layout, + * otherwise set layout to an array of GST_AUDIO_CHANNEL_POSITION_NONE */ +void +gst_jack_set_layout (GstAudioRingBuffer * buffer, GstAudioRingBufferSpec * spec) +{ + gint i; + + if (spec->info.channels <= 8) { + for (i = 0; i < spec->info.channels; i++) + spec->info.position[i] = default_positions[spec->info.channels - 1][i]; + gst_audio_channel_positions_to_valid_order (spec->info.position, + spec->info.channels); + gst_audio_ring_buffer_set_channel_positions (buffer, + default_positions[spec->info.channels - 1]); + } else { + spec->info.flags |= GST_AUDIO_FLAG_UNPOSITIONED; + for (i = 0; i < G_N_ELEMENTS (spec->info.position); i++) + spec->info.position[i] = GST_AUDIO_CHANNEL_POSITION_NONE; + gst_audio_ring_buffer_set_channel_positions (buffer, spec->info.position); + } + + gst_caps_unref (spec->caps); + spec->caps = gst_audio_info_to_caps (&spec->info); +} diff --git a/ext/jack/gstjackutil.h b/ext/jack/gstjackutil.h new file mode 100644 index 0000000..7a4bcc5 --- /dev/null +++ b/ext/jack/gstjackutil.h @@ -0,0 +1,31 @@ +/* GStreamer + * Copyright (C) 2010 Tristan Matthews <tristan@sat.qc.ca> + * + * gstjackutil.h: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_JACK_UTIL_H_ +#define _GST_JACK_UTIL_H_ + +#include <gst/gst.h> +#include <gst/audio/audio.h> + +void +gst_jack_set_layout (GstAudioRingBuffer * buffer, GstAudioRingBufferSpec *spec); + +#endif // _GST_JACK_UTIL_H_ |