diff options
105 files changed, 1 insertions, 11252 deletions
diff --git a/config/Makefile.am b/config/Makefile.am index 68ff3c78c..535844507 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -51,12 +51,7 @@ m4macros = \ grc_gnuradio_examples.m4 \ grc_grc.m4 \ grc_gr_atsc.m4 \ - grc_gr_audio_alsa.m4 \ - grc_gr_audio_jack.m4 \ - grc_gr_audio_oss.m4 \ - grc_gr_audio_osx.m4 \ - grc_gr_audio_portaudio.m4 \ - grc_gr_audio_windows.m4 \ + grc_gr_audio.m4 \ grc_gr_comedi.m4 \ grc_gr_gcell.m4 \ grc_gr_gpio.m4 \ diff --git a/config/grc_gr_audio_alsa.m4 b/config/grc_gr_audio_alsa.m4 deleted file mode 100644 index 35389d81d..000000000 --- a/config/grc_gr_audio_alsa.m4 +++ /dev/null @@ -1,49 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_AUDIO_ALSA],[ - GRC_ENABLE(gr-audio-alsa) - - dnl Don't do gr-audio-alsa if gnuradio-core skipped - GRC_CHECK_DEPENDENCY(gr-audio-alsa, gnuradio-core) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - dnl Don't do gr-audio-alsa if the 'alsa' package is not installed. - PKG_CHECK_MODULES(ALSA, alsa >= 0.9,[], - [passed=no;AC_MSG_RESULT([gr-audio-alsa requires package alsa, not found.])]) - fi - - AC_CONFIG_FILES([ \ - gr-audio-alsa/Makefile \ - gr-audio-alsa/gnuradio-audio-alsa.pc \ - gr-audio-alsa/src/Makefile \ - gr-audio-alsa/src/run_guile_tests \ - gr-audio-alsa/src/run_tests \ - ]) - - GRC_BUILD_CONDITIONAL(gr-audio-alsa,[ - dnl run_tests is created from run_tests.in. Make it executable. - AC_CONFIG_COMMANDS([run_tests_alsa], - [chmod +x gr-audio-alsa/src/run_tests gr-audio-alsa/src/run_guile_tests]) - ]) -]) diff --git a/config/grc_gr_audio_jack.m4 b/config/grc_gr_audio_jack.m4 deleted file mode 100644 index d1853588b..000000000 --- a/config/grc_gr_audio_jack.m4 +++ /dev/null @@ -1,47 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_AUDIO_JACK],[ - GRC_ENABLE(gr-audio-jack) - - dnl Don't do gr-audio-jack if gnuradio-core skipped - GRC_CHECK_DEPENDENCY(gr-audio-jack, gnuradio-core) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - dnl Don't do gr-audio-jack if in 'jack' isn't installed - PKG_CHECK_MODULES(JACK, jack >= 0.8, [], - [passed=no;AC_MSG_RESULT([gr-audio-jack requires package jack, not found.])]) - fi - - AC_CONFIG_FILES([ \ - gr-audio-jack/Makefile \ - gr-audio-jack/gnuradio-audio-jack.pc \ - gr-audio-jack/src/Makefile \ - gr-audio-jack/src/run_tests \ - ]) - - GRC_BUILD_CONDITIONAL(gr-audio-jack,[ - dnl run_tests is created from run_tests.in. Make it executable. - AC_CONFIG_COMMANDS([run_tests_jack], [chmod +x gr-audio-jack/src/run_tests]) - ]) -]) diff --git a/config/grc_gr_audio_oss.m4 b/config/grc_gr_audio_oss.m4 deleted file mode 100644 index 13c83bba9..000000000 --- a/config/grc_gr_audio_oss.m4 +++ /dev/null @@ -1,63 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_AUDIO_OSS],[ - GRC_ENABLE(gr-audio-oss) - - dnl Don't do gr-audio-oss if gnuradio-core skipped - GRC_CHECK_DEPENDENCY(gr-audio-oss, gnuradio-core) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - dnl Make sure the correct library and/or headers are available. - case $host_os in - netbsd*) - AC_HAVE_LIBRARY(ossaudio,[], - [passed=no;AC_MSG_RESULT([gr-audio-oss requires library ossaudio, not found.])]) - if test $passed != no; then - OSS_LIBS=-lossaudio - AC_SUBST(OSS_LIBS) - AC_MSG_RESULT([Using OSS library $OSS_LIBS]) - fi - ;; - darwin*) - dnl OSX / Darwin can't use OSS - passed=no - ;; - *) - AC_CHECK_HEADER(sys/soundcard.h,[], - [passed=no;AC_MSG_RESULT([gr-audio-oss requires sys/soundcard.h, not found.])]) - esac - fi - - AC_CONFIG_FILES([ \ - gr-audio-oss/Makefile \ - gr-audio-oss/gnuradio-audio-oss.pc \ - gr-audio-oss/src/Makefile \ - gr-audio-oss/src/run_tests \ - ]) - - GRC_BUILD_CONDITIONAL(gr-audio-oss,[ - dnl run_tests is created from run_tests.in. Make it executable. - AC_CONFIG_COMMANDS([run_tests_oss], [chmod +x gr-audio-oss/src/run_tests]) - ]) -]) diff --git a/config/grc_gr_audio_osx.m4 b/config/grc_gr_audio_osx.m4 deleted file mode 100644 index df8634ff6..000000000 --- a/config/grc_gr_audio_osx.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008,2010 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_AUDIO_OSX],[ - GRC_ENABLE(gr-audio-osx) - - dnl Don't do gr-audio-osx if gnuradio-core skipped - GRC_CHECK_DEPENDENCY(gr-audio-osx, gnuradio-core) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - case "$host_os" in - darwin*) - MACOSX_AUDIOUNIT([], - [passed=no;AC_MSG_RESULT([gr-audio-osx requires AudioUnit, not found.])]) - ;; - *) - AC_MSG_RESULT([gr-audio-osx will build on Mac OS X and Darwin only.]) - passed=no - ;; - esac - fi - - AC_CONFIG_FILES([ \ - gr-audio-osx/Makefile \ - gr-audio-osx/src/Makefile \ - gr-audio-osx/src/run_tests \ - ]) - - GRC_BUILD_CONDITIONAL(gr-audio-osx,[ - dnl run_tests is created from run_tests.in. Make it executable. - AC_CONFIG_COMMANDS([run_tests_osx], [chmod +x gr-audio-osx/src/run_tests]) - ]) -]) diff --git a/config/grc_gr_audio_portaudio.m4 b/config/grc_gr_audio_portaudio.m4 deleted file mode 100644 index ff551b38a..000000000 --- a/config/grc_gr_audio_portaudio.m4 +++ /dev/null @@ -1,47 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_AUDIO_PORTAUDIO],[ - GRC_ENABLE(gr-audio-portaudio) - - dnl Don't do gr-audio-portaudio if gnuradio-core skipped - GRC_CHECK_DEPENDENCY(gr-audio-portaudio, gnuradio-core) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - dnl Don't do gr-audio-portaudio if the 'portaudio' library is unavailable. - PKG_CHECK_MODULES(PORTAUDIO, portaudio-2.0 >= 19,[], - [passed=no;AC_MSG_RESULT([gr-audio-portaudio requires package portaudio, not found.])]) - fi - - AC_CONFIG_FILES([ \ - gr-audio-portaudio/Makefile \ - gr-audio-portaudio/gnuradio-audio-portaudio.pc \ - gr-audio-portaudio/src/Makefile \ - gr-audio-portaudio/src/run_tests \ - ]) - - GRC_BUILD_CONDITIONAL(gr-audio-portaudio,[ - dnl run_tests is created from run_tests.in. Make it executable. - AC_CONFIG_COMMANDS([run_tests_portaudio], [chmod +x gr-audio-portaudio/src/run_tests]) - ]) -]) diff --git a/config/grc_gr_audio_windows.m4 b/config/grc_gr_audio_windows.m4 deleted file mode 100644 index bb6244163..000000000 --- a/config/grc_gr_audio_windows.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_AUDIO_WINDOWS],[ - GRC_ENABLE(gr-audio-windows) - - dnl Don't do gr-audio-windows if gnuradio-core skipped - GRC_CHECK_DEPENDENCY(gr-audio-windows, gnuradio-core) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - case "$host_os" in - cygwin*|win*|mingw*) - dnl Don't do gr-audio-windows if the 'winmm' library isn't available. - AC_HAVE_LIBRARY(winmm, [], - [passed=no;AC_MSG_RESULT([gr-audio-windows requires library winmm, not found.])]) - ;; - *) - AC_MSG_RESULT([gr-audio-windows will build on a Windows Unix environment only.]) - passed=no - ;; - esac - fi - - AC_CONFIG_FILES([ \ - gr-audio-windows/Makefile \ - gr-audio-windows/src/Makefile \ - gr-audio-windows/src/run_tests \ - ]) - - GRC_BUILD_CONDITIONAL(gr-audio-windows,[ - WINAUDIO_LIBS=-lwinmm - AC_SUBST(WINAUDIO_LIBS) - dnl run_tests is created from run_tests.in. Make it executable. - AC_CONFIG_COMMANDS([run_tests_audio_windows], [chmod +x gr-audio-windows/src/run_tests]) - ]) -]) diff --git a/configure.ac b/configure.ac index c99344285..e707ed777 100644 --- a/configure.ac +++ b/configure.ac @@ -368,12 +368,6 @@ GRC_GR_USRP2 GRC_GR_GCELL dnl this must come after GRC_GCELL and GRC_GNURADIO_CORE GRC_GR_MSDD6000 GRC_GR_AUDIO -GRC_GR_AUDIO_ALSA -GRC_GR_AUDIO_JACK -GRC_GR_AUDIO_OSS -GRC_GR_AUDIO_OSX -GRC_GR_AUDIO_PORTAUDIO -GRC_GR_AUDIO_WINDOWS GRC_GR_ATSC GRC_GR_COMEDI GRC_GR_CVSD_VOCODER diff --git a/gr-audio-alsa/.gitignore b/gr-audio-alsa/.gitignore deleted file mode 100644 index cdcf41b15..000000000 --- a/gr-audio-alsa/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/config.cache -/config.h -/config.h.in -/config.log -/config.status -/configure -/depcomp -/install-sh -/libtool -/ltmain.sh -/make.log -/missing -/missing -/mkinstalldirs -/py-compile -/stamp-h -/stamp-h.in -/stamp-h1 diff --git a/gr-audio-alsa/Makefile.am b/gr-audio-alsa/Makefile.am deleted file mode 100644 index 5bd92b0ff..000000000 --- a/gr-audio-alsa/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2004,2006,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -dist_pkgconfig_DATA = gnuradio-audio-alsa.pc - -etcdir = $(gr_prefsdir) -dist_etc_DATA = gr-audio-alsa.conf diff --git a/gr-audio-alsa/build-stamp b/gr-audio-alsa/build-stamp deleted file mode 100644 index e69de29bb..000000000 --- a/gr-audio-alsa/build-stamp +++ /dev/null diff --git a/gr-audio-alsa/gnuradio-audio-alsa.pc.in b/gr-audio-alsa/gnuradio-audio-alsa.pc.in deleted file mode 100644 index d5147e6af..000000000 --- a/gr-audio-alsa/gnuradio-audio-alsa.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: gnuradio-audio-alsa -Description: The GNU Radio block for the ALSA sound system -Requires: gnuradio-core alsa -Version: @LIBVER@ -Libs: -L${libdir} -lgnuradio-audio-alsa -Cflags: -I${includedir} diff --git a/gr-audio-alsa/gr-audio-alsa.conf b/gr-audio-alsa/gr-audio-alsa.conf deleted file mode 100644 index 5cec63e7a..000000000 --- a/gr-audio-alsa/gr-audio-alsa.conf +++ /dev/null @@ -1,11 +0,0 @@ -# This file contains system wide configuration data for GNU Radio. -# You may override any setting on a per-user basis by editing -# ~/.gnuradio/config.conf - -[audio_alsa] - -default_input_device = hw:0,0 -default_output_device = hw:0,0 -period_time = 0.010 # in seconds -nperiods = 4 # total buffering = period_time * nperiods -verbose = false diff --git a/gr-audio-alsa/src/.gitignore b/gr-audio-alsa/src/.gitignore deleted file mode 100644 index 8de8fe39c..000000000 --- a/gr-audio-alsa/src/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/usrp.py -/usrp.cc -/audio_oss.cc -/audio_oss.py -/audio_alsa.py -/audio_alsa.cc -/run_tests -/run_guile_tests -/*.pyc -/gnuradio -/guile -/python diff --git a/gr-audio-alsa/src/Makefile.am b/gr-audio-alsa/src/Makefile.am deleted file mode 100644 index 330158aa5..000000000 --- a/gr-audio-alsa/src/Makefile.am +++ /dev/null @@ -1,88 +0,0 @@ -# -# Copyright 2004,2008,2009,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -TESTS = -EXTRA_DIST += run_tests.in run_guile_tests.in -DISTCLEANFILES += run_tests run_guile_tests - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - audio_alsa_sink.h \ - audio_alsa_source.h - -noinst_HEADERS = \ - gri_alsa.h - -noinst_PYTHON = \ - qa_audio_alsa.py - -noinst_GUILE = \ - audio_alsa.test - - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) - -# ------------------------------------------------------------------------ -# ALSA C++ library, including OS interface, sink, and source - -lib_LTLIBRARIES = libgnuradio-audio-alsa.la - -libgnuradio_audio_alsa_la_SOURCES = \ - audio_alsa_sink.cc \ - audio_alsa_source.cc \ - gri_alsa.cc - -libgnuradio_audio_alsa_la_LIBADD = \ - $(GNURADIO_CORE_LA) \ - $(ALSA_LIBS) - -libgnuradio_audio_alsa_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) - - -# ------------------------------------------------------------------------ -# SWIG generated bindings - -TOP_SWIG_IFILES = \ - audio_alsa.i - -# Install so that they end up available as: -# import gnuradio.audio_alsa -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -audio_alsa_pythondir_category = \ - gnuradio - -# additional libraries for linking with the SWIG-generated library -audio_alsa_la_swig_libadd = \ - libgnuradio-audio-alsa.la - -if PYTHON -TESTS += run_tests -endif - -if GUILE -TESTS += run_guile_tests -endif - - diff --git a/gr-audio-alsa/src/Makefile.swig.gen b/gr-audio-alsa/src/Makefile.swig.gen deleted file mode 100644 index c231a4784..000000000 --- a/gr-audio-alsa/src/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for audio_alsa.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/audio_alsa -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/audio_alsa -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -audio_alsa_pythondir_category ?= gnuradio/audio_alsa -audio_alsa_pylibdir_category ?= $(audio_alsa_pythondir_category) -audio_alsa_pythondir = $(pythondir)/$(audio_alsa_pythondir_category) -audio_alsa_pylibdir = $(pyexecdir)/$(audio_alsa_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -audio_alsa_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/audio_alsa -# FIXME: determince whether these should be installed with gnuradio. -audio_alsa_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -audio_alsa_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -audio_alsa_swiginclude_HEADERS = \ - audio_alsa.i \ - $(audio_alsa_swiginclude_headers) - -if PYTHON -audio_alsa_pylib_LTLIBRARIES = \ - _audio_alsa.la - -_audio_alsa_la_SOURCES = \ - python/audio_alsa.cc \ - $(audio_alsa_la_swig_sources) - -audio_alsa_python_PYTHON = \ - audio_alsa.py \ - $(audio_alsa_python) - -_audio_alsa_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_alsa_la_swig_libadd) - -_audio_alsa_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_alsa_la_swig_ldflags) - -_audio_alsa_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_alsa_la_swig_cxxflags) - -python/audio_alsa.cc: audio_alsa.py -audio_alsa.py: audio_alsa.i - -# Include the python dependencies for this file --include python/audio_alsa.d - -endif # end of if python - -if GUILE - -audio_alsa_scmlib_LTLIBRARIES = \ - libguile-gnuradio-audio_alsa.la -libguile_gnuradio_audio_alsa_la_SOURCES = \ - guile/audio_alsa.cc \ - $(audio_alsa_la_swig_sources) -nobase_audio_alsa_scm_DATA = \ - gnuradio/audio_alsa.scm \ - gnuradio/audio_alsa-primitive.scm -libguile_gnuradio_audio_alsa_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_alsa_la_swig_libadd) -libguile_gnuradio_audio_alsa_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_alsa_la_swig_ldflags) -libguile_gnuradio_audio_alsa_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_alsa_la_swig_cxxflags) - -guile/audio_alsa.cc: gnuradio/audio_alsa.scm -gnuradio/audio_alsa.scm: audio_alsa.i -gnuradio/audio_alsa-primitive.scm: gnuradio/audio_alsa.scm - -# Include the guile dependencies for this file --include guile/audio_alsa.d - -endif # end of GUILE - - diff --git a/gr-audio-alsa/src/audio_alsa.i b/gr-audio-alsa/src/audio_alsa.i deleted file mode 100644 index 215acf33d..000000000 --- a/gr-audio-alsa/src/audio_alsa.i +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "audio_alsa_sink.h" -#include "audio_alsa_source.h" -%} - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_alsa,source) - -audio_alsa_source_sptr -audio_alsa_make_source (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - -class audio_alsa_source : public gr_sync_block { - - protected: - audio_alsa_source (int sampling_rate, - const std::string device_name, - bool ok_to_block = true - ) throw (std::runtime_error); - - public: - ~audio_alsa_source (); - - bool start(); - bool stop(); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_alsa,sink) - -audio_alsa_sink_sptr -audio_alsa_make_sink (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - -class audio_alsa_sink : public gr_sync_block { - - protected: - audio_alsa_sink (int sampling_rate, - const std::string device_name, - bool ok_to_block - ) throw (std::runtime_error); - - public: - ~audio_alsa_sink (); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-audio_alsa" "scm_init_gnuradio_audio_alsa_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-audio-alsa/src/audio_alsa.test b/gr-audio-alsa/src/audio_alsa.test deleted file mode 100644 index 7997b9283..000000000 --- a/gr-audio-alsa/src/audio_alsa.test +++ /dev/null @@ -1,37 +0,0 @@ -;;; -*- Scheme -*- -;;; -;;; Copyright 2010 Free Software Foundation, Inc. -;;; -;;; This file is part of GNU Radio -;;; -;;; GNU Radio is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 3, or (at your option) -;;; any later version. -;;; -;;; GNU Radio 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 General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program. If not, see <http://www.gnu.org/licenses/>. -;;; - -;;; If you're using Emacs's Scheme mode: -;;; (put 'with-test-prefix 'scheme-indent-function 1) - -;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. -;;; See also the very end of the file, where the test-equal, test-eqv -;;; and test-eq macros are defined. - -(define-module (test-module) - #:use-module (oop goops) - #:use-module (gnuradio core) - #:use-module (gnuradio test-suite lib) - #:duplicates (merge-generics replace check)) - -;;; Just see if we can import the module... -;;; They may not have ALSA drivers, etc. - -(use-modules (gnuradio audio_alsa)) diff --git a/gr-audio-alsa/src/audio_alsa_sink.cc b/gr-audio-alsa/src/audio_alsa_sink.cc deleted file mode 100644 index d44a93b3f..000000000 --- a/gr-audio-alsa/src/audio_alsa_sink.cc +++ /dev/null @@ -1,551 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_alsa_sink.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> -#include <gri_alsa.h> - - -static bool CHATTY_DEBUG = false; - - -static snd_pcm_format_t acceptable_formats[] = { - // these are in our preferred order... - SND_PCM_FORMAT_S32, - SND_PCM_FORMAT_S16 -}; - -#define NELEMS(x) (sizeof(x)/sizeof(x[0])) - - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_alsa", "default_output_device", "hw:0,0"); -} - -static double -default_period_time () -{ - return std::max(0.001, gr_prefs::singleton()->get_double("audio_alsa", "period_time", 0.010)); -} - -static int -default_nperiods () -{ - return std::max(2L, gr_prefs::singleton()->get_long("audio_alsa", "nperiods", 4)); -} - -// ---------------------------------------------------------------- - -audio_alsa_sink_sptr -audio_alsa_make_sink (int sampling_rate, - const std::string dev, - bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_alsa_sink (sampling_rate, dev, - ok_to_block)); -} - -audio_alsa_sink::audio_alsa_sink (int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_alsa_sink", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), - d_device_name (device_name.empty() ? default_device_name() : device_name), - d_pcm_handle (0), - d_hw_params ((snd_pcm_hw_params_t *)(new char[snd_pcm_hw_params_sizeof()])), - d_sw_params ((snd_pcm_sw_params_t *)(new char[snd_pcm_sw_params_sizeof()])), - d_nperiods (default_nperiods()), - d_period_time_us ((unsigned int) (default_period_time() * 1e6)), - d_period_size (0), - d_buffer_size_bytes (0), d_buffer (0), - d_worker (0), d_special_case_mono_to_stereo (false), - d_nunderuns (0), d_nsuspends (0), d_ok_to_block(ok_to_block) -{ - CHATTY_DEBUG = gr_prefs::singleton()->get_bool("audio_alsa", "verbose", false); - - int error; - int dir; - - // open the device for playback - error = snd_pcm_open(&d_pcm_handle, d_device_name.c_str (), - SND_PCM_STREAM_PLAYBACK, 0); - if (ok_to_block == false) - snd_pcm_nonblock(d_pcm_handle, !ok_to_block); - if (error < 0){ - fprintf (stderr, "audio_alsa_sink[%s]: %s\n", - d_device_name.c_str(), snd_strerror(error)); - throw std::runtime_error ("audio_alsa_sink"); - } - - // Fill params with a full configuration space for a PCM. - error = snd_pcm_hw_params_any(d_pcm_handle, d_hw_params); - if (error < 0) - bail ("broken configuration for playback", error); - - - if (CHATTY_DEBUG) - gri_alsa_dump_hw_params (d_pcm_handle, d_hw_params, stdout); - - - // now that we know how many channels the h/w can handle, set input signature - unsigned int umin_chan, umax_chan; - snd_pcm_hw_params_get_channels_min (d_hw_params, &umin_chan); - snd_pcm_hw_params_get_channels_max (d_hw_params, &umax_chan); - int min_chan = std::min (umin_chan, 1000U); - int max_chan = std::min (umax_chan, 1000U); - - // As a special case, if the hw's min_chan is two, we'll accept - // a single input and handle the duplication ourselves. - - if (min_chan == 2){ - min_chan = 1; - d_special_case_mono_to_stereo = true; - } - set_input_signature (gr_make_io_signature (min_chan, max_chan, - sizeof (float))); - - // fill in portions of the d_hw_params that we know now... - - // Specify the access methods we implement - // For now, we only handle RW_INTERLEAVED... - snd_pcm_access_mask_t *access_mask; - snd_pcm_access_mask_t **access_mask_ptr = &access_mask; // FIXME: workaround for compiler warning - snd_pcm_access_mask_alloca (access_mask_ptr); - snd_pcm_access_mask_none (access_mask); - snd_pcm_access_mask_set (access_mask, SND_PCM_ACCESS_RW_INTERLEAVED); - // snd_pcm_access_mask_set (access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED); - - if ((error = snd_pcm_hw_params_set_access_mask (d_pcm_handle, - d_hw_params, access_mask)) < 0) - bail ("failed to set access mask", error); - - - // set sample format - if (!gri_alsa_pick_acceptable_format (d_pcm_handle, d_hw_params, - acceptable_formats, - NELEMS (acceptable_formats), - &d_format, - "audio_alsa_sink", - CHATTY_DEBUG)) - throw std::runtime_error ("audio_alsa_sink"); - - - // sampling rate - unsigned int orig_sampling_rate = d_sampling_rate; - if ((error = snd_pcm_hw_params_set_rate_near (d_pcm_handle, d_hw_params, - &d_sampling_rate, 0)) < 0) - bail ("failed to set rate near", error); - - if (orig_sampling_rate != d_sampling_rate){ - fprintf (stderr, "audio_alsa_sink[%s]: unable to support sampling rate %d\n", - snd_pcm_name (d_pcm_handle), orig_sampling_rate); - fprintf (stderr, " card requested %d instead.\n", d_sampling_rate); - } - - /* - * ALSA transfers data in units of "periods". - * We indirectly determine the underlying buffersize by specifying - * the number of periods we want (typically 4) and the length of each - * period in units of time (typically 1ms). - */ - unsigned int min_nperiods, max_nperiods; - snd_pcm_hw_params_get_periods_min (d_hw_params, &min_nperiods, &dir); - snd_pcm_hw_params_get_periods_max (d_hw_params, &max_nperiods, &dir); - //fprintf (stderr, "alsa_sink: min_nperiods = %d, max_nperiods = %d\n", - // min_nperiods, max_nperiods); - - unsigned int orig_nperiods = d_nperiods; - d_nperiods = std::min (std::max (min_nperiods, d_nperiods), max_nperiods); - - // adjust period time so that total buffering remains more-or-less constant - d_period_time_us = (d_period_time_us * orig_nperiods) / d_nperiods; - - error = snd_pcm_hw_params_set_periods (d_pcm_handle, d_hw_params, - d_nperiods, 0); - if (error < 0) - bail ("set_periods failed", error); - - dir = 0; - error = snd_pcm_hw_params_set_period_time_near (d_pcm_handle, d_hw_params, - &d_period_time_us, &dir); - if (error < 0) - bail ("set_period_time_near failed", error); - - dir = 0; - error = snd_pcm_hw_params_get_period_size (d_hw_params, - &d_period_size, &dir); - if (error < 0) - bail ("get_period_size failed", error); - - set_output_multiple (d_period_size); -} - - -bool -audio_alsa_sink::check_topology (int ninputs, int noutputs) -{ - // ninputs is how many channels the user has connected. - // Now we can finish up setting up the hw params... - - int nchan = ninputs; - int err; - - // Check the state of the stream - // Ensure that the pcm is in a state where we can still mess with the hw_params - snd_pcm_state_t state; - state=snd_pcm_state(d_pcm_handle); - if ( state== SND_PCM_STATE_RUNNING) - return true; // If stream is running, don't change any parameters - else if(state == SND_PCM_STATE_XRUN ) - snd_pcm_prepare ( d_pcm_handle ); // Prepare stream on underrun, and we can set parameters; - - bool special_case = nchan == 1 && d_special_case_mono_to_stereo; - if (special_case) - nchan = 2; - - err = snd_pcm_hw_params_set_channels (d_pcm_handle, d_hw_params, nchan); - - if (err < 0){ - output_error_msg ("set_channels failed", err); - return false; - } - - // set the parameters into the driver... - err = snd_pcm_hw_params(d_pcm_handle, d_hw_params); - if (err < 0){ - output_error_msg ("snd_pcm_hw_params failed", err); - return false; - } - - // get current s/w params - err = snd_pcm_sw_params_current (d_pcm_handle, d_sw_params); - if (err < 0) - bail ("snd_pcm_sw_params_current", err); - - // Tell the PCM device to wait to start until we've filled - // it's buffers half way full. This helps avoid audio underruns. - - err = snd_pcm_sw_params_set_start_threshold(d_pcm_handle, - d_sw_params, - d_nperiods * d_period_size / 2); - if (err < 0) - bail ("snd_pcm_sw_params_set_start_threshold", err); - - // store the s/w params - err = snd_pcm_sw_params (d_pcm_handle, d_sw_params); - if (err < 0) - bail ("snd_pcm_sw_params", err); - - d_buffer_size_bytes = - d_period_size * nchan * snd_pcm_format_size (d_format, 1); - - d_buffer = new char [d_buffer_size_bytes]; - - if (CHATTY_DEBUG) - fprintf (stdout, "audio_alsa_sink[%s]: sample resolution = %d bits\n", - snd_pcm_name (d_pcm_handle), - snd_pcm_hw_params_get_sbits (d_hw_params)); - - switch (d_format){ - case SND_PCM_FORMAT_S16: - if (special_case) - d_worker = &audio_alsa_sink::work_s16_1x2; - else - d_worker = &audio_alsa_sink::work_s16; - break; - - case SND_PCM_FORMAT_S32: - if (special_case) - d_worker = &audio_alsa_sink::work_s32_1x2; - else - d_worker = &audio_alsa_sink::work_s32; - break; - - default: - assert (0); - } - return true; -} - -audio_alsa_sink::~audio_alsa_sink () -{ - if (snd_pcm_state (d_pcm_handle) == SND_PCM_STATE_RUNNING) - snd_pcm_drop (d_pcm_handle); - - snd_pcm_close(d_pcm_handle); - delete [] ((char *) d_hw_params); - delete [] ((char *) d_sw_params); - delete [] d_buffer; -} - -int -audio_alsa_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert ((noutput_items % d_period_size) == 0); - - // this is a call through a pointer to a method... - return (this->*d_worker)(noutput_items, input_items, output_items); -} - -/* - * Work function that deals with float to S16 conversion - */ -int -audio_alsa_sink::work_s16 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int16 sample_t; // the type of samples we're creating - static const int NBITS = 16; // # of bits in a sample - - unsigned int nchan = input_items.size (); - const float **in = (const float **) &input_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - int n; - - unsigned int sizeof_frame = nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - for (n = 0; n < noutput_items; n += d_period_size){ - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - for (unsigned int chan = 0; chan < nchan; chan++){ - buf[bi++] = (sample_t) (in[chan][i] * (float) ((1L << (NBITS-1)) - 1)); - } - } - - // update src pointers - for (unsigned int chan = 0; chan < nchan; chan++) - in[chan] += d_period_size; - - if (!write_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - } - - return n; -} - - -/* - * Work function that deals with float to S32 conversion - */ -int -audio_alsa_sink::work_s32 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int32 sample_t; // the type of samples we're creating - static const int NBITS = 32; // # of bits in a sample - - unsigned int nchan = input_items.size (); - const float **in = (const float **) &input_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - int n; - - unsigned int sizeof_frame = nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - for (n = 0; n < noutput_items; n += d_period_size){ - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - for (unsigned int chan = 0; chan < nchan; chan++){ - buf[bi++] = (sample_t) (in[chan][i] * (float) ((1L << (NBITS-1)) - 1)); - } - } - - // update src pointers - for (unsigned int chan = 0; chan < nchan; chan++) - in[chan] += d_period_size; - - if (!write_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - } - - return n; -} - -/* - * Work function that deals with float to S16 conversion and - * mono to stereo kludge. - */ -int -audio_alsa_sink::work_s16_1x2 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int16 sample_t; // the type of samples we're creating - static const int NBITS = 16; // # of bits in a sample - - assert (input_items.size () == 1); - static const unsigned int nchan = 2; - const float **in = (const float **) &input_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - int n; - - unsigned int sizeof_frame = nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - for (n = 0; n < noutput_items; n += d_period_size){ - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - sample_t t = (sample_t) (in[0][i] * (float) ((1L << (NBITS-1)) - 1)); - buf[bi++] = t; - buf[bi++] = t; - } - - // update src pointers - in[0] += d_period_size; - - if (!write_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - } - - return n; -} - -/* - * Work function that deals with float to S32 conversion and - * mono to stereo kludge. - */ -int -audio_alsa_sink::work_s32_1x2 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int32 sample_t; // the type of samples we're creating - static const int NBITS = 32; // # of bits in a sample - - assert (input_items.size () == 1); - static unsigned int nchan = 2; - const float **in = (const float **) &input_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - int n; - - unsigned int sizeof_frame = nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - for (n = 0; n < noutput_items; n += d_period_size){ - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - sample_t t = (sample_t) (in[0][i] * (float) ((1L << (NBITS-1)) - 1)); - buf[bi++] = t; - buf[bi++] = t; - } - - // update src pointers - in[0] += d_period_size; - - if (!write_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - } - - return n; -} - -bool -audio_alsa_sink::write_buffer (const void *vbuffer, - unsigned nframes, unsigned sizeof_frame) -{ - const unsigned char *buffer = (const unsigned char *) vbuffer; - - while (nframes > 0){ - int r = snd_pcm_writei (d_pcm_handle, buffer, nframes); - if (r == -EAGAIN) - { - if (d_ok_to_block == true) - continue; // try again - - break; - } - - else if (r == -EPIPE){ // underrun - d_nunderuns++; - fputs ("aU", stderr); - if ((r = snd_pcm_prepare (d_pcm_handle)) < 0){ - output_error_msg ("snd_pcm_prepare failed. Can't recover from underrun", r); - return false; - } - continue; // try again - } - - else if (r == -ESTRPIPE){ // h/w is suspended (whatever that means) - // This is apparently related to power management - d_nsuspends++; - if ((r = snd_pcm_resume (d_pcm_handle)) < 0){ - output_error_msg ("failed to resume from suspend", r); - return false; - } - continue; // try again - } - - else if (r < 0){ - output_error_msg ("snd_pcm_writei failed", r); - return false; - } - - nframes -= r; - buffer += r * sizeof_frame; - } - - return true; -} - - -void -audio_alsa_sink::output_error_msg (const char *msg, int err) -{ - fprintf (stderr, "audio_alsa_sink[%s]: %s: %s\n", - snd_pcm_name (d_pcm_handle), msg, snd_strerror (err)); -} - -void -audio_alsa_sink::bail (const char *msg, int err) throw (std::runtime_error) -{ - output_error_msg (msg, err); - throw std::runtime_error ("audio_alsa_sink"); -} diff --git a/gr-audio-alsa/src/audio_alsa_sink.h b/gr-audio-alsa/src/audio_alsa_sink.h deleted file mode 100644 index f3007f60f..000000000 --- a/gr-audio-alsa/src/audio_alsa_sink.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_ALSA_SINK_H -#define INCLUDED_AUDIO_ALSA_SINK_H - -// use new ALSA API -#define ALSA_PCM_NEW_HW_PARAMS_API -#define ALSA_PCM_NEW_SW_PARAMS_API - -#include <gr_sync_block.h> -#include <string> -#include <alsa/asoundlib.h> -#include <stdexcept> - - -class audio_alsa_sink; -typedef boost::shared_ptr<audio_alsa_sink> audio_alsa_sink_sptr; - -/*! - * \brief make an alsa audio sink. - * - * \param sampling_rate sampling rate in Hz - * \param device_name ALSA pcm device name, e.g., "hw:0,0" - * \param ok_to_block (currently ignored) - */ -audio_alsa_sink_sptr -audio_alsa_make_sink (int sampling_rate, - const std::string device_name = "", - bool ok_to_block = true); - -/*! - * \brief audio sink using ALSA - * - * The sink has N input streams of floats, where N depends - * on the hardware characteristics of the selected device. - * - * Input samples must be in the range [-1,1]. - */ -class audio_alsa_sink : public gr_sync_block { - friend audio_alsa_sink_sptr - audio_alsa_make_sink (int sampling_rate, const std::string device_name, - bool ok_to_block); - - // typedef for pointer to class work method - typedef int (audio_alsa_sink::*work_t)(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int d_sampling_rate; - std::string d_device_name; - snd_pcm_t *d_pcm_handle; - snd_pcm_hw_params_t *d_hw_params; - snd_pcm_sw_params_t *d_sw_params; - snd_pcm_format_t d_format; - unsigned int d_nperiods; - unsigned int d_period_time_us; // microseconds - snd_pcm_uframes_t d_period_size; // in frames - unsigned int d_buffer_size_bytes; // sizeof of d_buffer - char *d_buffer; - work_t d_worker; // the work method to use - bool d_special_case_mono_to_stereo; - - // random stats - int d_nunderuns; // count of underruns - int d_nsuspends; // count of suspends - bool d_ok_to_block; // defaults to "true", controls blocking/non-block I/O - - void output_error_msg (const char *msg, int err); - void bail (const char *msg, int err) throw (std::runtime_error); - - protected: - audio_alsa_sink (int sampling_rate, const std::string device_name, - bool ok_to_block); - - public: - ~audio_alsa_sink (); - - bool check_topology (int ninputs, int noutputs); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - -protected: - bool write_buffer (const void *buffer, unsigned nframes, unsigned sizeof_frame); - - int work_s16 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int work_s16_1x2 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int work_s32 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int work_s32_1x2 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_AUDIO_ALSA_SINK_H */ diff --git a/gr-audio-alsa/src/audio_alsa_source.cc b/gr-audio-alsa/src/audio_alsa_source.cc deleted file mode 100644 index 7b3d91b9d..000000000 --- a/gr-audio-alsa/src/audio_alsa_source.cc +++ /dev/null @@ -1,507 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_alsa_source.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> -#include <gri_alsa.h> - - -static bool CHATTY_DEBUG = false; - -static snd_pcm_format_t acceptable_formats[] = { - // these are in our preferred order... - SND_PCM_FORMAT_S32, - SND_PCM_FORMAT_S16 -}; - -#define NELEMS(x) (sizeof(x)/sizeof(x[0])) - - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_alsa", "default_input_device", "hw:0,0"); -} - -static double -default_period_time () -{ - return std::max(0.001, gr_prefs::singleton()->get_double("audio_alsa", "period_time", 0.010)); -} - -static int -default_nperiods () -{ - return std::max(2L, gr_prefs::singleton()->get_long("audio_alsa", "nperiods", 4)); -} - -// ---------------------------------------------------------------- - -audio_alsa_source_sptr -audio_alsa_make_source (int sampling_rate, const std::string dev, - bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_alsa_source (sampling_rate, dev, - ok_to_block)); -} - -audio_alsa_source::audio_alsa_source (int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_alsa_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), - d_device_name (device_name.empty() ? default_device_name() : device_name), - d_pcm_handle (0), - d_hw_params ((snd_pcm_hw_params_t *)(new char[snd_pcm_hw_params_sizeof()])), - d_sw_params ((snd_pcm_sw_params_t *)(new char[snd_pcm_sw_params_sizeof()])), - d_nperiods (default_nperiods()), - d_period_time_us ((unsigned int) (default_period_time() * 1e6)), - d_period_size (0), - d_buffer_size_bytes (0), d_buffer (0), - d_worker (0), d_hw_nchan (0), - d_special_case_stereo_to_mono (false), - d_noverruns (0), d_nsuspends (0) -{ - - CHATTY_DEBUG = gr_prefs::singleton()->get_bool("audio_alsa", "verbose", false); - - int error; - int dir; - - // open the device for capture - error = snd_pcm_open(&d_pcm_handle, d_device_name.c_str (), - SND_PCM_STREAM_CAPTURE, 0); - if (error < 0){ - fprintf (stderr, "audio_alsa_source[%s]: %s\n", - d_device_name.c_str(), snd_strerror(error)); - throw std::runtime_error ("audio_alsa_source"); - } - - // Fill params with a full configuration space for a PCM. - error = snd_pcm_hw_params_any(d_pcm_handle, d_hw_params); - if (error < 0) - bail ("broken configuration for playback", error); - - if (CHATTY_DEBUG) - gri_alsa_dump_hw_params (d_pcm_handle, d_hw_params, stdout); - - // now that we know how many channels the h/w can handle, set output signature - unsigned int umax_chan; - unsigned int umin_chan; - snd_pcm_hw_params_get_channels_min (d_hw_params, &umin_chan); - snd_pcm_hw_params_get_channels_max (d_hw_params, &umax_chan); - int min_chan = std::min (umin_chan, 1000U); - int max_chan = std::min (umax_chan, 1000U); - - // As a special case, if the hw's min_chan is two, we'll accept - // a single output and handle the demux ourselves. - - if (min_chan == 2){ - min_chan = 1; - d_special_case_stereo_to_mono = true; - } - - set_output_signature (gr_make_io_signature (min_chan, max_chan, - sizeof (float))); - - // fill in portions of the d_hw_params that we know now... - - // Specify the access methods we implement - // For now, we only handle RW_INTERLEAVED... - snd_pcm_access_mask_t *access_mask; - snd_pcm_access_mask_t **access_mask_ptr = &access_mask; // FIXME: workaround for compiler warning - snd_pcm_access_mask_alloca (access_mask_ptr); - snd_pcm_access_mask_none (access_mask); - snd_pcm_access_mask_set (access_mask, SND_PCM_ACCESS_RW_INTERLEAVED); - // snd_pcm_access_mask_set (access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED); - - if ((error = snd_pcm_hw_params_set_access_mask (d_pcm_handle, - d_hw_params, access_mask)) < 0) - bail ("failed to set access mask", error); - - - // set sample format - if (!gri_alsa_pick_acceptable_format (d_pcm_handle, d_hw_params, - acceptable_formats, - NELEMS (acceptable_formats), - &d_format, - "audio_alsa_source", - CHATTY_DEBUG)) - throw std::runtime_error ("audio_alsa_source"); - - - // sampling rate - unsigned int orig_sampling_rate = d_sampling_rate; - if ((error = snd_pcm_hw_params_set_rate_near (d_pcm_handle, d_hw_params, - &d_sampling_rate, 0)) < 0) - bail ("failed to set rate near", error); - - if (orig_sampling_rate != d_sampling_rate){ - fprintf (stderr, "audio_alsa_source[%s]: unable to support sampling rate %d\n", - snd_pcm_name (d_pcm_handle), orig_sampling_rate); - fprintf (stderr, " card requested %d instead.\n", d_sampling_rate); - } - - /* - * ALSA transfers data in units of "periods". - * We indirectly determine the underlying buffersize by specifying - * the number of periods we want (typically 4) and the length of each - * period in units of time (typically 1ms). - */ - unsigned int min_nperiods, max_nperiods; - snd_pcm_hw_params_get_periods_min (d_hw_params, &min_nperiods, &dir); - snd_pcm_hw_params_get_periods_max (d_hw_params, &max_nperiods, &dir); - //fprintf (stderr, "alsa_source: min_nperiods = %d, max_nperiods = %d\n", - // min_nperiods, max_nperiods); - - - unsigned int orig_nperiods = d_nperiods; - d_nperiods = std::min (std::max (min_nperiods, d_nperiods), max_nperiods); - - // adjust period time so that total buffering remains more-or-less constant - d_period_time_us = (d_period_time_us * orig_nperiods) / d_nperiods; - - error = snd_pcm_hw_params_set_periods (d_pcm_handle, d_hw_params, - d_nperiods, 0); - if (error < 0) - bail ("set_periods failed", error); - - dir = 0; - error = snd_pcm_hw_params_set_period_time_near (d_pcm_handle, d_hw_params, - &d_period_time_us, &dir); - if (error < 0) - bail ("set_period_time_near failed", error); - - dir = 0; - error = snd_pcm_hw_params_get_period_size (d_hw_params, - &d_period_size, &dir); - if (error < 0) - bail ("get_period_size failed", error); - - set_output_multiple (d_period_size); -} - -bool -audio_alsa_source::check_topology (int ninputs, int noutputs) -{ - // noutputs is how many channels the user has connected. - // Now we can finish up setting up the hw params... - - unsigned int nchan = noutputs; - int err; - - // FIXME check_topology may be called more than once. - // Ensure that the pcm is in a state where we can still mess with the hw_params - - bool special_case = nchan == 1 && d_special_case_stereo_to_mono; - if (special_case) - nchan = 2; - - d_hw_nchan = nchan; - err = snd_pcm_hw_params_set_channels (d_pcm_handle, d_hw_params, d_hw_nchan); - if (err < 0){ - output_error_msg ("set_channels failed", err); - return false; - } - - // set the parameters into the driver... - err = snd_pcm_hw_params(d_pcm_handle, d_hw_params); - if (err < 0){ - output_error_msg ("snd_pcm_hw_params failed", err); - return false; - } - - d_buffer_size_bytes = - d_period_size * d_hw_nchan * snd_pcm_format_size (d_format, 1); - - d_buffer = new char [d_buffer_size_bytes]; - - if (CHATTY_DEBUG) - fprintf (stdout, "audio_alsa_source[%s]: sample resolution = %d bits\n", - snd_pcm_name (d_pcm_handle), - snd_pcm_hw_params_get_sbits (d_hw_params)); - - switch (d_format){ - case SND_PCM_FORMAT_S16: - if (special_case) - d_worker = &audio_alsa_source::work_s16_2x1; - else - d_worker = &audio_alsa_source::work_s16; - break; - - case SND_PCM_FORMAT_S32: - if (special_case) - d_worker = &audio_alsa_source::work_s32_2x1; - else - d_worker = &audio_alsa_source::work_s32; - break; - - default: - assert (0); - } - - return true; -} - -audio_alsa_source::~audio_alsa_source () -{ - if (snd_pcm_state (d_pcm_handle) == SND_PCM_STATE_RUNNING) - snd_pcm_drop (d_pcm_handle); - - snd_pcm_close(d_pcm_handle); - delete [] ((char *) d_hw_params); - delete [] ((char *) d_sw_params); - delete [] d_buffer; -} - -int -audio_alsa_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert ((noutput_items % d_period_size) == 0); - assert (noutput_items != 0); - - // this is a call through a pointer to a method... - return (this->*d_worker)(noutput_items, input_items, output_items); -} - -/* - * Work function that deals with float to S16 conversion - */ -int -audio_alsa_source::work_s16 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int16 sample_t; // the type of samples we're creating - static const int NBITS = 16; // # of bits in a sample - - unsigned int nchan = output_items.size (); - float **out = (float **) &output_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - - unsigned int sizeof_frame = d_hw_nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - // To minimize latency, return at most a single period's worth of samples. - // [We could also read the first one in a blocking mode and subsequent - // ones in non-blocking mode, but we'll leave that for later (or never).] - - if (!read_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - for (unsigned int chan = 0; chan < nchan; chan++){ - out[chan][i] = (float) buf[bi++] * (1.0 / (float) ((1L << (NBITS-1)) - 1)); - } - } - - return d_period_size; -} - -/* - * Work function that deals with float to S16 conversion - * and stereo to mono kludge... - */ -int -audio_alsa_source::work_s16_2x1 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int16 sample_t; // the type of samples we're creating - static const int NBITS = 16; // # of bits in a sample - - unsigned int nchan = output_items.size (); - float **out = (float **) &output_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - - assert (nchan == 1); - - unsigned int sizeof_frame = d_hw_nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - // To minimize latency, return at most a single period's worth of samples. - // [We could also read the first one in a blocking mode and subsequent - // ones in non-blocking mode, but we'll leave that for later (or never).] - - if (!read_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - int t = (buf[bi] + buf[bi+1]) / 2; - bi += 2; - out[0][i] = (float) t * (1.0 / (float) ((1L << (NBITS-1)) - 1)); - } - - return d_period_size; -} - -/* - * Work function that deals with float to S32 conversion - */ -int -audio_alsa_source::work_s32 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int32 sample_t; // the type of samples we're creating - static const int NBITS = 32; // # of bits in a sample - - unsigned int nchan = output_items.size (); - float **out = (float **) &output_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - - unsigned int sizeof_frame = d_hw_nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - // To minimize latency, return at most a single period's worth of samples. - // [We could also read the first one in a blocking mode and subsequent - // ones in non-blocking mode, but we'll leave that for later (or never).] - - if (!read_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - for (unsigned int chan = 0; chan < nchan; chan++){ - out[chan][i] = (float) buf[bi++] * (1.0 / (float) ((1L << (NBITS-1)) - 1)); - } - } - - return d_period_size; -} - -/* - * Work function that deals with float to S32 conversion - * and stereo to mono kludge... - */ -int -audio_alsa_source::work_s32_2x1 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - typedef gr_int32 sample_t; // the type of samples we're creating - static const int NBITS = 32; // # of bits in a sample - - unsigned int nchan = output_items.size (); - float **out = (float **) &output_items[0]; - sample_t *buf = (sample_t *) d_buffer; - int bi; - - assert (nchan == 1); - - unsigned int sizeof_frame = d_hw_nchan * sizeof (sample_t); - assert (d_buffer_size_bytes == d_period_size * sizeof_frame); - - // To minimize latency, return at most a single period's worth of samples. - // [We could also read the first one in a blocking mode and subsequent - // ones in non-blocking mode, but we'll leave that for later (or never).] - - if (!read_buffer (buf, d_period_size, sizeof_frame)) - return -1; // No fixing this problem. Say we're done. - - // process one period of data - bi = 0; - for (unsigned int i = 0; i < d_period_size; i++){ - int t = (buf[bi] + buf[bi+1]) / 2; - bi += 2; - out[0][i] = (float) t * (1.0 / (float) ((1L << (NBITS-1)) - 1)); - } - - return d_period_size; -} - -bool -audio_alsa_source::read_buffer (void *vbuffer, unsigned nframes, unsigned sizeof_frame) -{ - unsigned char *buffer = (unsigned char *) vbuffer; - - while (nframes > 0){ - int r = snd_pcm_readi (d_pcm_handle, buffer, nframes); - if (r == -EAGAIN) - continue; // try again - - else if (r == -EPIPE){ // overrun - d_noverruns++; - fputs ("aO", stderr); - if ((r = snd_pcm_prepare (d_pcm_handle)) < 0){ - output_error_msg ("snd_pcm_prepare failed. Can't recover from overrun", r); - return false; - } - continue; // try again - } - - else if (r == -ESTRPIPE){ // h/w is suspended (whatever that means) - // This is apparently related to power management - d_nsuspends++; - if ((r = snd_pcm_resume (d_pcm_handle)) < 0){ - output_error_msg ("failed to resume from suspend", r); - return false; - } - continue; // try again - } - - else if (r < 0){ - output_error_msg ("snd_pcm_readi failed", r); - return false; - } - - nframes -= r; - buffer += r * sizeof_frame; - } - - return true; -} - - -void -audio_alsa_source::output_error_msg (const char *msg, int err) -{ - fprintf (stderr, "audio_alsa_source[%s]: %s: %s\n", - snd_pcm_name (d_pcm_handle), msg, snd_strerror (err)); -} - -void -audio_alsa_source::bail (const char *msg, int err) throw (std::runtime_error) -{ - output_error_msg (msg, err); - throw std::runtime_error ("audio_alsa_source"); -} diff --git a/gr-audio-alsa/src/audio_alsa_source.h b/gr-audio-alsa/src/audio_alsa_source.h deleted file mode 100644 index db6c45683..000000000 --- a/gr-audio-alsa/src/audio_alsa_source.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_ALSA_SOURCE_H -#define INCLUDED_AUDIO_ALSA_SOURCE_H - -// use new ALSA API -#define ALSA_PCM_NEW_HW_PARAMS_API -#define ALSA_PCM_NEW_SW_PARAMS_API - -#include <gr_sync_block.h> -#include <string> -#include <alsa/asoundlib.h> -#include <stdexcept> - -class audio_alsa_source; -typedef boost::shared_ptr<audio_alsa_source> audio_alsa_source_sptr; - -/*! - * \brief Make an ALSA audio source. - * - * \param sampling_rate sampling rate - * \param device_name ALSA pcm device name, e.g., "hw:0,0" - * \param ok_to_block (currently ignored) - */ -audio_alsa_source_sptr -audio_alsa_make_source (int sampling_rate, - const std::string device_name = "", - bool ok_to_block = true); - -/*! - * \brief audio source using ALSA - * - * The source has between 1 and N input streams of floats, where N is - * depends on the hardware characteristics of the selected device. - * - * Output samples will be in the range [-1,1]. - */ -class audio_alsa_source : public gr_sync_block { - friend audio_alsa_source_sptr - audio_alsa_make_source (int sampling_rate, - const std::string device_name, - bool ok_to_block); - - // typedef for pointer to class work method - typedef int (audio_alsa_source::*work_t)(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int d_sampling_rate; - std::string d_device_name; - snd_pcm_t *d_pcm_handle; - snd_pcm_hw_params_t *d_hw_params; - snd_pcm_sw_params_t *d_sw_params; - snd_pcm_format_t d_format; - unsigned int d_nperiods; - unsigned int d_period_time_us; // microseconds - snd_pcm_uframes_t d_period_size; // in frames - unsigned int d_buffer_size_bytes; // sizeof of d_buffer - char *d_buffer; - work_t d_worker; // the work method to use - unsigned int d_hw_nchan; // # of configured h/w channels - bool d_special_case_stereo_to_mono; - - // random stats - int d_noverruns; // count of overruns - int d_nsuspends; // count of suspends - - void output_error_msg (const char *msg, int err); - void bail (const char *msg, int err) throw (std::runtime_error); - - protected: - audio_alsa_source (int sampling_rate, const std::string device_name, - bool ok_to_block); - - public: - ~audio_alsa_source (); - - bool check_topology (int ninputs, int noutputs); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -protected: - bool read_buffer (void *buffer, unsigned nframes, unsigned sizeof_frame); - - int work_s16 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int work_s16_2x1 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int work_s32 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - int work_s32_2x1 (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_AUDIO_ALSA_SOURCE_H */ diff --git a/gr-audio-alsa/src/gri_alsa.cc b/gr-audio-alsa/src/gri_alsa.cc deleted file mode 100644 index d9fda0f7d..000000000 --- a/gr-audio-alsa/src/gri_alsa.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_alsa.h> -#include <algorithm> - -static snd_pcm_access_t access_types[] = { - SND_PCM_ACCESS_MMAP_INTERLEAVED, - SND_PCM_ACCESS_MMAP_NONINTERLEAVED, - SND_PCM_ACCESS_MMAP_COMPLEX, - SND_PCM_ACCESS_RW_INTERLEAVED, - SND_PCM_ACCESS_RW_NONINTERLEAVED -}; - -static snd_pcm_format_t format_types[] = { - // SND_PCM_FORMAT_UNKNOWN, - SND_PCM_FORMAT_S8, - SND_PCM_FORMAT_U8, - SND_PCM_FORMAT_S16_LE, - SND_PCM_FORMAT_S16_BE, - SND_PCM_FORMAT_U16_LE, - SND_PCM_FORMAT_U16_BE, - SND_PCM_FORMAT_S24_LE, - SND_PCM_FORMAT_S24_BE, - SND_PCM_FORMAT_U24_LE, - SND_PCM_FORMAT_U24_BE, - SND_PCM_FORMAT_S32_LE, - SND_PCM_FORMAT_S32_BE, - SND_PCM_FORMAT_U32_LE, - SND_PCM_FORMAT_U32_BE, - SND_PCM_FORMAT_FLOAT_LE, - SND_PCM_FORMAT_FLOAT_BE, - SND_PCM_FORMAT_FLOAT64_LE, - SND_PCM_FORMAT_FLOAT64_BE, - SND_PCM_FORMAT_IEC958_SUBFRAME_LE, - SND_PCM_FORMAT_IEC958_SUBFRAME_BE, - SND_PCM_FORMAT_MU_LAW, - SND_PCM_FORMAT_A_LAW, - SND_PCM_FORMAT_IMA_ADPCM, - SND_PCM_FORMAT_MPEG, - SND_PCM_FORMAT_GSM, - SND_PCM_FORMAT_SPECIAL, - SND_PCM_FORMAT_S24_3LE, - SND_PCM_FORMAT_S24_3BE, - SND_PCM_FORMAT_U24_3LE, - SND_PCM_FORMAT_U24_3BE, - SND_PCM_FORMAT_S20_3LE, - SND_PCM_FORMAT_S20_3BE, - SND_PCM_FORMAT_U20_3LE, - SND_PCM_FORMAT_U20_3BE, - SND_PCM_FORMAT_S18_3LE, - SND_PCM_FORMAT_S18_3BE, - SND_PCM_FORMAT_U18_3LE, - SND_PCM_FORMAT_U18_3BE -}; - -static unsigned int test_rates[] = { - 8000, 16000, 22050, 32000, 44100, 48000, 96000, 192000 -}; - -#define NELEMS(x) (sizeof(x)/sizeof(x[0])) - -void -gri_alsa_dump_hw_params (snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams, FILE *fp) -{ - fprintf (fp, "PCM name: %s\n", snd_pcm_name (pcm)); - - fprintf (fp, "Access types:\n"); - for (unsigned i = 0; i < NELEMS (access_types); i++){ - snd_pcm_access_t at = access_types[i]; - fprintf (fp, " %-20s %s\n", - snd_pcm_access_name (at), - snd_pcm_hw_params_test_access (pcm, hwparams, at) == 0 ? "YES" : "NO"); - } - - fprintf (fp, "Formats:\n"); - for (unsigned i = 0; i < NELEMS (format_types); i++){ - snd_pcm_format_t ft = format_types[i]; - if (0) - fprintf (fp, " %-20s %s\n", - snd_pcm_format_name (ft), - snd_pcm_hw_params_test_format (pcm, hwparams, ft) == 0 ? "YES" : "NO"); - else { - if (snd_pcm_hw_params_test_format (pcm, hwparams, ft) == 0) - fprintf (fp, " %-20s YES\n", snd_pcm_format_name (ft)); - } - } - - fprintf (fp, "Number of channels\n"); - unsigned int min_chan, max_chan; - snd_pcm_hw_params_get_channels_min (hwparams, &min_chan); - snd_pcm_hw_params_get_channels_max (hwparams, &max_chan); - fprintf (fp, " min channels: %d\n", min_chan); - fprintf (fp, " max channels: %d\n", max_chan); - unsigned int chan; - max_chan = std::min (max_chan, 16U); // truncate display... - for (chan = min_chan; chan <= max_chan; chan++){ - fprintf (fp, " %d channels\t%s\n", chan, - snd_pcm_hw_params_test_channels (pcm, hwparams, chan) == 0 ? "YES" : "NO"); - } - - fprintf (fp, "Sample Rates:\n"); - unsigned int min_rate, max_rate; - int min_dir, max_dir; - - snd_pcm_hw_params_get_rate_min (hwparams, &min_rate, &min_dir); - snd_pcm_hw_params_get_rate_max (hwparams, &max_rate, &max_dir); - fprintf (fp, " min rate: %7d (dir = %d)\n", min_rate, min_dir); - fprintf (fp, " max rate: %7d (dir = %d)\n", max_rate, max_dir); - for (unsigned i = 0; i < NELEMS (test_rates); i++){ - unsigned int rate = test_rates[i]; - fprintf (fp, " %6u %s\n", rate, - snd_pcm_hw_params_test_rate (pcm, hwparams, rate, 0) == 0 ? "YES" : "NO"); - } - - fflush (fp); -} - -bool -gri_alsa_pick_acceptable_format (snd_pcm_t *pcm, - snd_pcm_hw_params_t *hwparams, - snd_pcm_format_t acceptable_formats[], - unsigned nacceptable_formats, - snd_pcm_format_t *selected_format, - const char *error_msg_tag, - bool verbose) -{ - int err; - - // pick a format that we like... - for (unsigned i = 0; i < nacceptable_formats; i++){ - if (snd_pcm_hw_params_test_format (pcm, hwparams, - acceptable_formats[i]) == 0){ - err = snd_pcm_hw_params_set_format (pcm, hwparams, acceptable_formats[i]); - if (err < 0){ - fprintf (stderr, "%s[%s]: failed to set format: %s\n", - error_msg_tag, snd_pcm_name (pcm), snd_strerror (err)); - return false; - } - if (verbose) - fprintf (stdout, "%s[%s]: using %s\n", - error_msg_tag, snd_pcm_name (pcm), - snd_pcm_format_name (acceptable_formats[i])); - *selected_format = acceptable_formats[i]; - return true; - } - } - - fprintf (stderr, "%s[%s]: failed to find acceptable format", - error_msg_tag, snd_pcm_name (pcm)); - return false; -} diff --git a/gr-audio-alsa/src/gri_alsa.h b/gr-audio-alsa/src/gri_alsa.h deleted file mode 100644 index 3d72fd950..000000000 --- a/gr-audio-alsa/src/gri_alsa.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_ALSA_H -#define INCLUDED_GRI_ALSA_H - -#include <stdio.h> -#include <alsa/asoundlib.h> - -void -gri_alsa_dump_hw_params (snd_pcm_t *pcm, - snd_pcm_hw_params_t *hwparams, - FILE *fp); - -bool -gri_alsa_pick_acceptable_format (snd_pcm_t *pcm, - snd_pcm_hw_params_t *hwparams, - snd_pcm_format_t acceptable_formats[], - unsigned nacceptable_formats, - snd_pcm_format_t *selected_format, - const char *error_msg_tag, - bool verbose); - - -#endif /* INCLUDED_GRI_ALSA_H */ diff --git a/gr-audio-alsa/src/qa_audio_alsa.py b/gr-audio-alsa/src/qa_audio_alsa.py deleted file mode 100755 index 52dbfdc7a..000000000 --- a/gr-audio-alsa/src/qa_audio_alsa.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import audio_alsa - -class test_audio_alsa (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have ALSA drivers, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.run(test_audio_alsa, "test_audio_alsa.xml") diff --git a/gr-audio-alsa/src/run_guile_tests.in b/gr-audio-alsa/src/run_guile_tests.in deleted file mode 100644 index 5d08b0dd5..000000000 --- a/gr-audio-alsa/src/run_guile_tests.in +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -. @top_builddir@/setup_guile_test_env - -# 1st argument is absolute path to hand coded guile source directory -# 2nd argument is absolute path to component C++ shared library build directory -# 3nd argument is absolute path to component SWIG build directory - -add_local_paths \ - @srcdir@ \ - @abs_builddir@ \ - @abs_builddir@ - -@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@ diff --git a/gr-audio-alsa/src/run_tests.in b/gr-audio-alsa/src/run_tests.in deleted file mode 100644 index fd3963068..000000000 --- a/gr-audio-alsa/src/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-audio-alsa \ - @abs_top_builddir@/gr-audio-alsa \ - @srcdir@ diff --git a/gr-audio-jack/.gitignore b/gr-audio-jack/.gitignore deleted file mode 100644 index cdcf41b15..000000000 --- a/gr-audio-jack/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/config.cache -/config.h -/config.h.in -/config.log -/config.status -/configure -/depcomp -/install-sh -/libtool -/ltmain.sh -/make.log -/missing -/missing -/mkinstalldirs -/py-compile -/stamp-h -/stamp-h.in -/stamp-h1 diff --git a/gr-audio-jack/Makefile.am b/gr-audio-jack/Makefile.am deleted file mode 100644 index cdc1433db..000000000 --- a/gr-audio-jack/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2004,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -dist_pkgconfig_DATA = gnuradio-audio-jack.pc - -etcdir = $(gr_prefsdir) -dist_etc_DATA = gr-audio-jack.conf diff --git a/gr-audio-jack/gnuradio-audio-jack.pc.in b/gr-audio-jack/gnuradio-audio-jack.pc.in deleted file mode 100644 index 8fb4a2e0d..000000000 --- a/gr-audio-jack/gnuradio-audio-jack.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: gnuradio-audio-jack -Description: GNU Radio blocks for the JACK sound system -Requires: gnuradio-core jack -Version: @LIBVER@ -Libs: -L${libdir} -lgnuradio-audio-jack -Cflags: -I${includedir} diff --git a/gr-audio-jack/gr-audio-jack.conf b/gr-audio-jack/gr-audio-jack.conf deleted file mode 100644 index bdbc1fd1d..000000000 --- a/gr-audio-jack/gr-audio-jack.conf +++ /dev/null @@ -1,8 +0,0 @@ -# This file contains system wide configuration data for GNU Radio. -# You may override any setting on a per-user basis by editing -# ~/.gnuradio/config.conf - -[audio_jack] - -default_input_device = gr_source -default_output_device = gr_sink diff --git a/gr-audio-jack/src/.gitignore b/gr-audio-jack/src/.gitignore deleted file mode 100644 index 347796beb..000000000 --- a/gr-audio-jack/src/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.pyc -/audio_jack.cc -/audio_jack.py -/run_tests -/gnuradio -/guile -/python diff --git a/gr-audio-jack/src/Makefile.am b/gr-audio-jack/src/Makefile.am deleted file mode 100644 index 9a0c8b9be..000000000 --- a/gr-audio-jack/src/Makefile.am +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright 2005,2008,2009,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -TESTS = -EXTRA_DIST += run_tests.in -DISTCLEANFILES += run_tests - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - audio_jack_sink.h \ - audio_jack_source.h - -noinst_HEADERS = \ - gri_jack.h - -lib_LTLIBRARIES = libgnuradio-audio-jack.la - -libgnuradio_audio_jack_la_SOURCES = \ - audio_jack_sink.cc \ - audio_jack_source.cc \ - gri_jack.cc - -libgnuradio_audio_jack_la_LIBADD = \ - $(GNURADIO_CORE_LA) \ - $(JACK_LIBS) - -libgnuradio_audio_jack_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) - -noinst_PYTHON = \ - qa_jack.py - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) - -################################### -# SWIG interfaces and libraries - -TOP_SWIG_IFILES = \ - audio_jack.i - -# Install so that they end up available as: -# import gnuradio.audio_jack -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -audio_jack_pythondir_category = \ - gnuradio - -# additional libraries for linking with the SWIG-generated library -audio_jack_la_swig_libadd = \ - libgnuradio-audio-jack.la - - -if PYTHON -TESTS += run_tests -endif diff --git a/gr-audio-jack/src/Makefile.swig.gen b/gr-audio-jack/src/Makefile.swig.gen deleted file mode 100644 index 9ca8140d4..000000000 --- a/gr-audio-jack/src/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for audio_jack.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/audio_jack -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/audio_jack -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -audio_jack_pythondir_category ?= gnuradio/audio_jack -audio_jack_pylibdir_category ?= $(audio_jack_pythondir_category) -audio_jack_pythondir = $(pythondir)/$(audio_jack_pythondir_category) -audio_jack_pylibdir = $(pyexecdir)/$(audio_jack_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -audio_jack_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/audio_jack -# FIXME: determince whether these should be installed with gnuradio. -audio_jack_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -audio_jack_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -audio_jack_swiginclude_HEADERS = \ - audio_jack.i \ - $(audio_jack_swiginclude_headers) - -if PYTHON -audio_jack_pylib_LTLIBRARIES = \ - _audio_jack.la - -_audio_jack_la_SOURCES = \ - python/audio_jack.cc \ - $(audio_jack_la_swig_sources) - -audio_jack_python_PYTHON = \ - audio_jack.py \ - $(audio_jack_python) - -_audio_jack_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_jack_la_swig_libadd) - -_audio_jack_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_jack_la_swig_ldflags) - -_audio_jack_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_jack_la_swig_cxxflags) - -python/audio_jack.cc: audio_jack.py -audio_jack.py: audio_jack.i - -# Include the python dependencies for this file --include python/audio_jack.d - -endif # end of if python - -if GUILE - -audio_jack_scmlib_LTLIBRARIES = \ - libguile-gnuradio-audio_jack.la -libguile_gnuradio_audio_jack_la_SOURCES = \ - guile/audio_jack.cc \ - $(audio_jack_la_swig_sources) -nobase_audio_jack_scm_DATA = \ - gnuradio/audio_jack.scm \ - gnuradio/audio_jack-primitive.scm -libguile_gnuradio_audio_jack_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_jack_la_swig_libadd) -libguile_gnuradio_audio_jack_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_jack_la_swig_ldflags) -libguile_gnuradio_audio_jack_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_jack_la_swig_cxxflags) - -guile/audio_jack.cc: gnuradio/audio_jack.scm -gnuradio/audio_jack.scm: audio_jack.i -gnuradio/audio_jack-primitive.scm: gnuradio/audio_jack.scm - -# Include the guile dependencies for this file --include guile/audio_jack.d - -endif # end of GUILE - - diff --git a/gr-audio-jack/src/audio_jack.i b/gr-audio-jack/src/audio_jack.i deleted file mode 100644 index 67747cb16..000000000 --- a/gr-audio-jack/src/audio_jack.i +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "audio_jack_sink.h" -#include "audio_jack_source.h" -%} - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_jack,source) - -audio_jack_source_sptr -audio_jack_make_source (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - -class audio_jack_source : public gr_sync_block { - - protected: - audio_jack_source (int sampling_rate, - const std::string device_name, - bool ok_to_block - ) throw (std::runtime_error); - - public: - ~audio_jack_source (); - - bool start(); - bool stop(); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_jack,sink) - -audio_jack_sink_sptr -audio_jack_make_sink (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - -class audio_jack_sink : public gr_sync_block { - - protected: - audio_jack_sink (int sampling_rate, - const std::string device_name, - bool ok_to_block - ) throw (std::runtime_error); - - public: - ~audio_jack_sink (); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-audio_jack" "scm_init_gnuradio_audio_jack_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-audio-jack/src/audio_jack_sink.cc b/gr-audio-jack/src/audio_jack_sink.cc deleted file mode 100644 index f28fddc34..000000000 --- a/gr-audio-jack/src/audio_jack_sink.cc +++ /dev/null @@ -1,236 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_jack_sink.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> -#include <gri_jack.h> - -#ifndef NO_PTHREAD -#include <pthread.h> -#endif - -typedef jack_default_audio_sample_t sample_t; - - -// Number of jack buffers in the ringbuffer -// TODO: make it to match at least the quantity of items passed by work() -static const unsigned int N_BUFFERS = 16; - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_jack", "default_output_device", "gr_sink"); -} - -int -jack_sink_process (jack_nframes_t nframes, void *arg) -{ - audio_jack_sink *self = (audio_jack_sink *)arg; - unsigned int read_size = nframes*sizeof(sample_t); - - if (jack_ringbuffer_read_space (self->d_ringbuffer) < read_size) { - self->d_nunderuns++; - // FIXME: move this fputs out, we shouldn't use blocking calls in process() - fputs ("jU", stderr); - return 0; - } - - char *buffer = (char *) jack_port_get_buffer (self->d_jack_output_port, nframes); - - jack_ringbuffer_read (self->d_ringbuffer, buffer, read_size); - -#ifndef NO_PTHREAD - // Tell the sink thread there is room in the ringbuffer. - // If it is already running, the lock will not be available. - // We can't wait here in the process() thread, but we don't - // need to signal in that case, because the sink thread will - // check for room availability. - - if (pthread_mutex_trylock (&self->d_jack_process_lock) == 0) { - pthread_cond_signal (&self->d_ringbuffer_ready); - pthread_mutex_unlock (&self->d_jack_process_lock); - } -#endif - - return 0; -} - -// ---------------------------------------------------------------- - -audio_jack_sink_sptr -audio_jack_make_sink(int sampling_rate, const std::string dev, bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_jack_sink (sampling_rate, dev, - ok_to_block)); -} - -audio_jack_sink::audio_jack_sink (int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_jack_sink", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), - d_device_name (device_name.empty() ? default_device_name() : device_name), - d_ok_to_block (ok_to_block), - d_jack_client (0), - d_ringbuffer (0), - d_nunderuns (0) -{ -#ifndef NO_PTHREAD - pthread_cond_init(&d_ringbuffer_ready, NULL);; - pthread_mutex_init(&d_jack_process_lock, NULL); -#endif - - // try to become a client of the JACK server - jack_options_t options = JackNullOption; - jack_status_t status; - const char *server_name = NULL; - if ((d_jack_client = jack_client_open (d_device_name.c_str (), - options, &status, - server_name)) == NULL) { - fprintf (stderr, "audio_jack_sink[%s]: jack server not running?\n", - d_device_name.c_str()); - throw std::runtime_error ("audio_jack_sink"); - } - - // tell the JACK server to call `jack_sink_process()' whenever - // there is work to be done. - jack_set_process_callback (d_jack_client, &jack_sink_process, (void*)this); - - // tell the JACK server to call `jack_shutdown()' if - // it ever shuts down, either entirely, or if it - // just decides to stop calling us. - - //jack_on_shutdown (d_jack_client, &jack_shutdown, (void*)this); - - d_jack_output_port = - jack_port_register (d_jack_client, "out", - JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); - - - d_jack_buffer_size = jack_get_buffer_size (d_jack_client); - - set_output_multiple (d_jack_buffer_size); - - d_ringbuffer = - jack_ringbuffer_create (N_BUFFERS*d_jack_buffer_size*sizeof(sample_t)); - if (d_ringbuffer == NULL) - bail ("jack_ringbuffer_create failed", 0); - - assert(sizeof(float)==sizeof(sample_t)); - set_input_signature (gr_make_io_signature (1, 1, sizeof (sample_t))); - - - jack_nframes_t sample_rate = jack_get_sample_rate (d_jack_client); - - if ((jack_nframes_t)sampling_rate != sample_rate){ - fprintf (stderr, "audio_jack_sink[%s]: unable to support sampling rate %d\n", - d_device_name.c_str (), sampling_rate); - fprintf (stderr, " card requested %d instead.\n", sample_rate); - } -} - - -bool -audio_jack_sink::check_topology (int ninputs, int noutputs) -{ - if (ninputs != 1) - return false; - - // tell the JACK server that we are ready to roll - if (jack_activate (d_jack_client)) - throw std::runtime_error ("audio_jack_sink"); - - return true; -} - -audio_jack_sink::~audio_jack_sink () -{ - jack_client_close (d_jack_client); - jack_ringbuffer_free (d_ringbuffer); -} - -int -audio_jack_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // write_size and work_size are in bytes - int work_size = noutput_items*sizeof(sample_t); - unsigned int write_size; - - while (work_size > 0) { - unsigned int write_space; // bytes - -#ifdef NO_PTHREAD - while ((write_space=jack_ringbuffer_write_space (d_ringbuffer)) < - d_jack_buffer_size*sizeof(sample_t)) { - usleep(1000000*((d_jack_buffer_size-write_space/sizeof(sample_t))/d_sampling_rate)); - } -#else - // JACK actually requires POSIX - - pthread_mutex_lock (&d_jack_process_lock); - while ((write_space=jack_ringbuffer_write_space (d_ringbuffer)) < - d_jack_buffer_size*sizeof(sample_t)) { - - // wait until jack_sink_process() signals more room - pthread_cond_wait (&d_ringbuffer_ready, &d_jack_process_lock); - } - pthread_mutex_unlock (&d_jack_process_lock); -#endif - - write_space -= write_space%(d_jack_buffer_size*sizeof(sample_t)); - write_size = std::min(write_space, (unsigned int)work_size); - - if (jack_ringbuffer_write (d_ringbuffer, (char *) input_items[0], - write_size) < write_size) { - bail ("jack_ringbuffer_write failed", 0); - } - work_size -= write_size; - } - - return noutput_items; -} - -void -audio_jack_sink::output_error_msg (const char *msg, int err) -{ - fprintf (stderr, "audio_jack_sink[%s]: %s: %d\n", - d_device_name.c_str (), msg, err); -} - -void -audio_jack_sink::bail (const char *msg, int err) throw (std::runtime_error) -{ - output_error_msg (msg, err); - throw std::runtime_error ("audio_jack_sink"); -} diff --git a/gr-audio-jack/src/audio_jack_sink.h b/gr-audio-jack/src/audio_jack_sink.h deleted file mode 100644 index ac74cfc37..000000000 --- a/gr-audio-jack/src/audio_jack_sink.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_AUDIO_JACK_SINK_H -#define INCLUDED_AUDIO_JACK_SINK_H - -#include <gr_sync_block.h> -#include <string> -#include <jack/jack.h> -#include <jack/ringbuffer.h> -#include <stdexcept> - -class audio_jack_sink; -typedef boost::shared_ptr<audio_jack_sink> audio_jack_sink_sptr; - -/*! - * \brief make an JACK audio sink. - * - * \param sampling_rate sampling rate in Hz - * \param device_name JACK device name, e.g., "gr_sink" - * \param ok_to_block - */ -audio_jack_sink_sptr -audio_jack_make_sink (int sampling_rate, - const std::string device_name = "", - bool ok_to_block = true); - -int jack_sink_process (jack_nframes_t nframes, void *arg); - -/*! - * \brief audio sink using JACK - * - * The sink has one input stream of floats. - * - * Input samples must be in the range [-1,1]. - */ -class audio_jack_sink : public gr_sync_block { - friend audio_jack_sink_sptr - audio_jack_make_sink (int sampling_rate, const std::string device_name, bool ok_to_block); - - friend int jack_sink_process (jack_nframes_t nframes, void *arg); - - // typedef for pointer to class work method - typedef int (audio_jack_sink::*work_t)(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int d_sampling_rate; - std::string d_device_name; - bool d_ok_to_block; - - jack_client_t *d_jack_client; - jack_port_t *d_jack_output_port; - jack_ringbuffer_t *d_ringbuffer; - jack_nframes_t d_jack_buffer_size; - pthread_cond_t d_ringbuffer_ready; - pthread_mutex_t d_jack_process_lock; - - // random stats - int d_nunderuns; // count of underruns - - void output_error_msg (const char *msg, int err); - void bail (const char *msg, int err) throw (std::runtime_error); - - - protected: - audio_jack_sink (int sampling_rate, const std::string device_name, bool ok_to_block); - - public: - ~audio_jack_sink (); - - bool check_topology (int ninputs, int noutputs); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_AUDIO_JACK_SINK_H */ diff --git a/gr-audio-jack/src/audio_jack_source.cc b/gr-audio-jack/src/audio_jack_source.cc deleted file mode 100644 index a92e970f5..000000000 --- a/gr-audio-jack/src/audio_jack_source.cc +++ /dev/null @@ -1,236 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_jack_source.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> -#include <gri_jack.h> - -#ifndef NO_PTHREAD -#include <pthread.h> -#endif - -typedef jack_default_audio_sample_t sample_t; - - -// Number of jack buffers in the ringbuffer -// TODO: make it to match at least the quantity of items passed to work() -static const unsigned int N_BUFFERS = 16; - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_jack", "default_input_device", "gr_source"); -} - - -int -jack_source_process (jack_nframes_t nframes, void *arg) -{ - audio_jack_source *self = (audio_jack_source *)arg; - unsigned int write_size = nframes*sizeof(sample_t); - - if (jack_ringbuffer_write_space (self->d_ringbuffer) < write_size) { - self->d_noverruns++; - // FIXME: move this fputs out, we shouldn't use blocking calls in process() - fputs ("jO", stderr); - return 0; - } - - char *buffer = (char *) jack_port_get_buffer (self->d_jack_input_port, nframes); - - jack_ringbuffer_write (self->d_ringbuffer, buffer, write_size); - -#ifndef NO_PTHREAD - // Tell the source thread there is data in the ringbuffer. - // If it is already running, the lock will not be available. - // We can't wait here in the process() thread, but we don't - // need to signal in that case, because the source thread will - // check for data availability. - - if (pthread_mutex_trylock (&self->d_jack_process_lock) == 0) { - pthread_cond_signal (&self->d_ringbuffer_ready); - pthread_mutex_unlock (&self->d_jack_process_lock); - } -#endif - - return 0; -} - -// ---------------------------------------------------------------- - -audio_jack_source_sptr -audio_jack_make_source (int sampling_rate, const std::string dev, bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_jack_source (sampling_rate, dev, ok_to_block)); -} - -audio_jack_source::audio_jack_source (int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_jack_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), - d_device_name (device_name.empty() ? default_device_name() : device_name), - d_ok_to_block(ok_to_block), - d_jack_client (0), - d_ringbuffer (0), - d_noverruns (0) -{ -#ifndef NO_PTHREAD - pthread_cond_init(&d_ringbuffer_ready, NULL);; - pthread_mutex_init(&d_jack_process_lock, NULL); -#endif - - // try to become a client of the JACK server - jack_options_t options = JackNullOption; - jack_status_t status; - const char *server_name = NULL; - if ((d_jack_client = jack_client_open (d_device_name.c_str (), - options, &status, - server_name)) == NULL) { - fprintf (stderr, "audio_jack_source[%s]: jack server not running?\n", - d_device_name.c_str()); - throw std::runtime_error ("audio_jack_source"); - } - - // tell the JACK server to call `jack_source_process()' whenever - // there is work to be done. - jack_set_process_callback (d_jack_client, &jack_source_process, (void*)this); - - // tell the JACK server to call `jack_shutdown()' if - // it ever shuts down, either entirely, or if it - // just decides to stop calling us. - - //jack_on_shutdown (d_jack_client, &jack_shutdown, (void*)this); - - d_jack_input_port = jack_port_register (d_jack_client, "in", - JACK_DEFAULT_AUDIO_TYPE, - JackPortIsInput, 0); - - - d_jack_buffer_size = jack_get_buffer_size (d_jack_client); - - set_output_multiple (d_jack_buffer_size); - - d_ringbuffer = jack_ringbuffer_create (N_BUFFERS*d_jack_buffer_size*sizeof(sample_t)); - if (d_ringbuffer == NULL) - bail ("jack_ringbuffer_create failed", 0); - - assert(sizeof(float)==sizeof(sample_t)); - set_output_signature (gr_make_io_signature (1, 1, sizeof (sample_t))); - - - jack_nframes_t sample_rate = jack_get_sample_rate (d_jack_client); - - if ((jack_nframes_t)sampling_rate != sample_rate){ - fprintf (stderr, "audio_jack_source[%s]: unable to support sampling rate %d\n", - d_device_name.c_str (), sampling_rate); - fprintf (stderr, " card requested %d instead.\n", sample_rate); - } -} - - -bool -audio_jack_source::check_topology (int ninputs, int noutputs) -{ - // tell the JACK server that we are ready to roll - if (jack_activate (d_jack_client)) - throw std::runtime_error ("audio_jack_source"); - - return true; -} - -audio_jack_source::~audio_jack_source () -{ - jack_client_close (d_jack_client); - jack_ringbuffer_free (d_ringbuffer); -} - -int -audio_jack_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // read_size and work_size are in bytes - unsigned int read_size; - - // Minimize latency - noutput_items = std::min (noutput_items, (int)d_jack_buffer_size); - - int work_size = noutput_items*sizeof(sample_t); - - while (work_size > 0) { - unsigned int read_space; // bytes - -#ifdef NO_PTHREAD - while ((read_space=jack_ringbuffer_read_space (d_ringbuffer)) < - d_jack_buffer_size*sizeof(sample_t)) { - usleep(1000000*((d_jack_buffer_size-read_space/sizeof(sample_t))/d_sampling_rate)); - } -#else - // JACK actually requires POSIX - - pthread_mutex_lock (&d_jack_process_lock); - while ((read_space=jack_ringbuffer_read_space (d_ringbuffer)) < - d_jack_buffer_size*sizeof(sample_t)) { - - // wait until jack_source_process() signals more data - pthread_cond_wait (&d_ringbuffer_ready, &d_jack_process_lock); - } - pthread_mutex_unlock (&d_jack_process_lock); -#endif - - read_space -= read_space%(d_jack_buffer_size*sizeof(sample_t)); - read_size = std::min(read_space, (unsigned int)work_size); - - if (jack_ringbuffer_read (d_ringbuffer, (char *) output_items[0], - read_size) < read_size) { - bail ("jack_ringbuffer_read failed", 0); - } - work_size -= read_size; - } - - return noutput_items; -} - -void -audio_jack_source::output_error_msg (const char *msg, int err) -{ - fprintf (stderr, "audio_jack_source[%s]: %s: %d\n", - d_device_name.c_str (), msg, err); -} - -void -audio_jack_source::bail (const char *msg, int err) throw (std::runtime_error) -{ - output_error_msg (msg, err); - throw std::runtime_error ("audio_jack_source"); -} diff --git a/gr-audio-jack/src/audio_jack_source.h b/gr-audio-jack/src/audio_jack_source.h deleted file mode 100644 index 8831a7363..000000000 --- a/gr-audio-jack/src/audio_jack_source.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_AUDIO_JACK_SOURCE_H -#define INCLUDED_AUDIO_JACK_SOURCE_H - -#include <gr_sync_block.h> -#include <string> -#include <jack/jack.h> -#include <jack/ringbuffer.h> -#include <stdexcept> - -class audio_jack_source; -typedef boost::shared_ptr<audio_jack_source> audio_jack_source_sptr; - -/*! - * \brief make a JACK audio source. - * - * \param sampling_rate sampling rate in Hz - * \param device_name JACK device name, e.g., "gr_source" - * \param ok_to_block - */ -audio_jack_source_sptr -audio_jack_make_source (int sampling_rate, - const std::string device_name = "", - bool ok_to_block = true); - -int jack_source_process (jack_nframes_t nframes, void *arg); - -/*! - * \brief audio source using JACK - * - * The source has one input stream of floats. - * - * Output samples will be in the range [-1,1]. - */ -class audio_jack_source : public gr_sync_block { - friend audio_jack_source_sptr - audio_jack_make_source (int sampling_rate, const std::string device_name, bool ok_to_block); - - friend int jack_source_process (jack_nframes_t nframes, void *arg); - - // typedef for pointer to class work method - typedef int (audio_jack_source::*work_t)(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int d_sampling_rate; - std::string d_device_name; - bool d_ok_to_block; - - jack_client_t *d_jack_client; - jack_port_t *d_jack_input_port; - jack_ringbuffer_t *d_ringbuffer; - jack_nframes_t d_jack_buffer_size; - pthread_cond_t d_ringbuffer_ready; - pthread_mutex_t d_jack_process_lock; - - // random stats - int d_noverruns; // count of overruns - - void output_error_msg (const char *msg, int err); - void bail (const char *msg, int err) throw (std::runtime_error); - - - protected: - audio_jack_source (int sampling_rate, const std::string device_name, bool ok_to_block); - - public: - ~audio_jack_source (); - - bool check_topology (int ninputs, int noutputs); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_AUDIO_JACK_SOURCE_H */ diff --git a/gr-audio-jack/src/gri_jack.cc b/gr-audio-jack/src/gri_jack.cc deleted file mode 100644 index fef1c58a6..000000000 --- a/gr-audio-jack/src/gri_jack.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_jack.h> -#include <algorithm> - - diff --git a/gr-audio-jack/src/gri_jack.h b/gr-audio-jack/src/gri_jack.h deleted file mode 100644 index ddc0b744d..000000000 --- a/gr-audio-jack/src/gri_jack.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_JACK_H -#define INCLUDED_GRI_JACK_H - -#include <stdio.h> - -#endif /* INCLUDED_GRI_JACK_H */ diff --git a/gr-audio-jack/src/qa_jack.py b/gr-audio-jack/src/qa_jack.py deleted file mode 100755 index ad6bee27b..000000000 --- a/gr-audio-jack/src/qa_jack.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import audio_jack - -class test_audio_jack (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have JACK library, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.run(test_audio_jack, "test_audio_jack.xml") diff --git a/gr-audio-jack/src/run_tests.in b/gr-audio-jack/src/run_tests.in deleted file mode 100644 index 77af85641..000000000 --- a/gr-audio-jack/src/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-audio-jack \ - @abs_top_builddir@/gr-audio-jack \ - @srcdir@ diff --git a/gr-audio-oss/.gitignore b/gr-audio-oss/.gitignore deleted file mode 100644 index cdcf41b15..000000000 --- a/gr-audio-oss/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/config.cache -/config.h -/config.h.in -/config.log -/config.status -/configure -/depcomp -/install-sh -/libtool -/ltmain.sh -/make.log -/missing -/missing -/mkinstalldirs -/py-compile -/stamp-h -/stamp-h.in -/stamp-h1 diff --git a/gr-audio-oss/Makefile.am b/gr-audio-oss/Makefile.am deleted file mode 100644 index c55d3ecb7..000000000 --- a/gr-audio-oss/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2004,2006 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -dist_pkgconfig_DATA = gnuradio-audio-oss.pc - -etcdir = $(gr_prefsdir) -dist_etc_DATA = gr-audio-oss.conf diff --git a/gr-audio-oss/gnuradio-audio-oss.pc.in b/gr-audio-oss/gnuradio-audio-oss.pc.in deleted file mode 100644 index 4a215bdab..000000000 --- a/gr-audio-oss/gnuradio-audio-oss.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: gnuradio-audio-oss -Description: The GNU Radio block for the OSS sound system -Requires: gnuradio-core -Version: @LIBVER@ -Libs: -L${libdir} -lgnuradio-audio-oss -Cflags: -I${includedir} diff --git a/gr-audio-oss/gr-audio-oss.conf b/gr-audio-oss/gr-audio-oss.conf deleted file mode 100644 index 6ea14d67e..000000000 --- a/gr-audio-oss/gr-audio-oss.conf +++ /dev/null @@ -1,9 +0,0 @@ -# This file contains system wide configuration data for GNU Radio. -# You may override any setting on a per-user basis by editing -# ~/.gnuradio/config.conf - -[audio_oss] - -default_input_device = /dev/dsp -default_output_device = /dev/dsp -latency = 0.005 # in seconds diff --git a/gr-audio-oss/src/.gitignore b/gr-audio-oss/src/.gitignore deleted file mode 100644 index c082252f9..000000000 --- a/gr-audio-oss/src/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/usrp.py -/usrp.cc -/audio_oss.cc -/audio_oss.py -/run_tests -/*.pyc -/gnuradio -/guile -/python diff --git a/gr-audio-oss/src/Makefile.am b/gr-audio-oss/src/Makefile.am deleted file mode 100644 index 2468958b2..000000000 --- a/gr-audio-oss/src/Makefile.am +++ /dev/null @@ -1,70 +0,0 @@ -# -# Copyright 2004,2005,2006,2008,2009,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -TESTS = -EXTRA_DIST += run_tests.in -DISTCLEANFILES += run_tests - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) - - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - audio_oss_sink.h \ - audio_oss_source.h - -noinst_PYTHON = qa_oss.py - -lib_LTLIBRARIES = libgnuradio-audio-oss.la - -libgnuradio_audio_oss_la_SOURCES = \ - audio_oss_sink.cc \ - audio_oss_source.cc - -libgnuradio_audio_oss_la_LIBADD = \ - $(GNURADIO_CORE_LA) \ - $(OSS_LIBS) - -libgnuradio_audio_oss_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) - -################################### -# SWIG interface and library -TOP_SWIG_IFILES = \ - audio_oss.i - -# Install so that they end up available as: -# import gnuradio.audio_oss -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -audio_oss_pythondir_category = \ - gnuradio - -# additional libraries for linking with the SWIG-generated library -audio_oss_la_swig_libadd = \ - libgnuradio-audio-oss.la - - -if PYTHON -TESTS += run_tests -endif diff --git a/gr-audio-oss/src/Makefile.swig.gen b/gr-audio-oss/src/Makefile.swig.gen deleted file mode 100644 index ecb03acce..000000000 --- a/gr-audio-oss/src/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for audio_oss.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/audio_oss -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/audio_oss -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -audio_oss_pythondir_category ?= gnuradio/audio_oss -audio_oss_pylibdir_category ?= $(audio_oss_pythondir_category) -audio_oss_pythondir = $(pythondir)/$(audio_oss_pythondir_category) -audio_oss_pylibdir = $(pyexecdir)/$(audio_oss_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -audio_oss_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/audio_oss -# FIXME: determince whether these should be installed with gnuradio. -audio_oss_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -audio_oss_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -audio_oss_swiginclude_HEADERS = \ - audio_oss.i \ - $(audio_oss_swiginclude_headers) - -if PYTHON -audio_oss_pylib_LTLIBRARIES = \ - _audio_oss.la - -_audio_oss_la_SOURCES = \ - python/audio_oss.cc \ - $(audio_oss_la_swig_sources) - -audio_oss_python_PYTHON = \ - audio_oss.py \ - $(audio_oss_python) - -_audio_oss_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_oss_la_swig_libadd) - -_audio_oss_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_oss_la_swig_ldflags) - -_audio_oss_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_oss_la_swig_cxxflags) - -python/audio_oss.cc: audio_oss.py -audio_oss.py: audio_oss.i - -# Include the python dependencies for this file --include python/audio_oss.d - -endif # end of if python - -if GUILE - -audio_oss_scmlib_LTLIBRARIES = \ - libguile-gnuradio-audio_oss.la -libguile_gnuradio_audio_oss_la_SOURCES = \ - guile/audio_oss.cc \ - $(audio_oss_la_swig_sources) -nobase_audio_oss_scm_DATA = \ - gnuradio/audio_oss.scm \ - gnuradio/audio_oss-primitive.scm -libguile_gnuradio_audio_oss_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_oss_la_swig_libadd) -libguile_gnuradio_audio_oss_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_oss_la_swig_ldflags) -libguile_gnuradio_audio_oss_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_oss_la_swig_cxxflags) - -guile/audio_oss.cc: gnuradio/audio_oss.scm -gnuradio/audio_oss.scm: audio_oss.i -gnuradio/audio_oss-primitive.scm: gnuradio/audio_oss.scm - -# Include the guile dependencies for this file --include guile/audio_oss.d - -endif # end of GUILE - - diff --git a/gr-audio-oss/src/audio_oss.i b/gr-audio-oss/src/audio_oss.i deleted file mode 100644 index 2150cba9f..000000000 --- a/gr-audio-oss/src/audio_oss.i +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "audio_oss_sink.h" -#include "audio_oss_source.h" -%} - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_oss,sink) - -audio_oss_sink_sptr -audio_oss_make_sink (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - - -class audio_oss_sink : public gr_sync_block { - protected: - audio_oss_sink (int sampling_rate, const std::string device_name = "", bool ok_to_block = true); - - public: - ~audio_oss_sink (); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_oss,source) - -audio_oss_source_sptr -audio_oss_make_source (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - -class audio_oss_source : public gr_sync_block { - protected: - audio_oss_source (int sampling_rate, const std::string device_name = "", bool ok_to_block = true); - - public: - ~audio_oss_source (); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-audio_oss" "scm_init_gnuradio_audio_oss_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-audio-oss/src/audio_oss_sink.cc b/gr-audio-oss/src/audio_oss_sink.cc deleted file mode 100644 index 8230ab9b6..000000000 --- a/gr-audio-oss/src/audio_oss_sink.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_oss_sink.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <sys/soundcard.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> - - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_oss", "default_output_device", "/dev/dsp"); -} - -audio_oss_sink_sptr -audio_oss_make_sink (int sampling_rate, const std::string dev, bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_oss_sink (sampling_rate, dev, ok_to_block)); -} - -audio_oss_sink::audio_oss_sink (int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_oss_sink", - gr_make_io_signature (1, 2, sizeof (float)), - gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), - d_device_name (device_name.empty() ? default_device_name() : device_name), - d_fd (-1), d_buffer (0), d_chunk_size (0) -{ - if ((d_fd = open (d_device_name.c_str (), O_WRONLY)) < 0){ - fprintf (stderr, "audio_oss_sink: "); - perror (d_device_name.c_str ()); - throw std::runtime_error ("audio_oss_sink"); - } - - double CHUNK_TIME = - std::max(0.001, gr_prefs::singleton()->get_double("audio_oss", "latency", 0.005)); - - d_chunk_size = (int) (d_sampling_rate * CHUNK_TIME); - set_output_multiple (d_chunk_size); - - d_buffer = new short [d_chunk_size * 2]; - - int format = AFMT_S16_NE; - int orig_format = format; - if (ioctl (d_fd, SNDCTL_DSP_SETFMT, &format) < 0){ - std::cerr << "audio_oss_sink: " << d_device_name << " ioctl failed\n"; - perror (d_device_name.c_str ()); - throw std::runtime_error ("audio_oss_sink"); - } - - if (format != orig_format){ - fprintf (stderr, "audio_oss_sink: unable to support format %d\n", orig_format); - fprintf (stderr, " card requested %d instead.\n", format); - } - - // set to stereo no matter what. Some hardware only does stereo - int channels = 2; - if (ioctl (d_fd, SNDCTL_DSP_CHANNELS, &channels) < 0 || channels != 2){ - perror ("audio_oss_sink: could not set STEREO mode"); - throw std::runtime_error ("audio_oss_sink"); - } - - // set sampling freq - int sf = sampling_rate; - if (ioctl (d_fd, SNDCTL_DSP_SPEED, &sf) < 0){ - std::cerr << "audio_oss_sink: " - << d_device_name << ": invalid sampling_rate " - << sampling_rate << "\n"; - sampling_rate = 8000; - if (ioctl (d_fd, SNDCTL_DSP_SPEED, &sf) < 0){ - std::cerr << "audio_oss_sink: failed to set sampling_rate to 8000\n"; - throw std::runtime_error ("audio_oss_sink"); - } - } -} - -audio_oss_sink::~audio_oss_sink () -{ - close (d_fd); - delete [] d_buffer; -} - - -int -audio_oss_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *f0, *f1; - - switch (input_items.size ()){ - - case 1: // mono input - - f0 = (const float *) input_items[0]; - - for (int i = 0; i < noutput_items; i += d_chunk_size){ - for (int j = 0; j < d_chunk_size; j++){ - d_buffer[2*j+0] = (short) (f0[j] * 32767); - d_buffer[2*j+1] = (short) (f0[j] * 32767); - } - f0 += d_chunk_size; - if (write (d_fd, d_buffer, 2 * d_chunk_size * sizeof (short)) < 0) - perror ("audio_oss_sink: write"); - } - break; - - case 2: // stereo input - - f0 = (const float *) input_items[0]; - f1 = (const float *) input_items[1]; - - for (int i = 0; i < noutput_items; i += d_chunk_size){ - for (int j = 0; j < d_chunk_size; j++){ - d_buffer[2*j+0] = (short) (f0[j] * 32767); - d_buffer[2*j+1] = (short) (f1[j] * 32767); - } - f0 += d_chunk_size; - f1 += d_chunk_size; - if (write (d_fd, d_buffer, 2 * d_chunk_size * sizeof (short)) < 0) - perror ("audio_oss_sink: write"); - } - break; - } - - return noutput_items; -} diff --git a/gr-audio-oss/src/audio_oss_sink.h b/gr-audio-oss/src/audio_oss_sink.h deleted file mode 100644 index 052faac13..000000000 --- a/gr-audio-oss/src/audio_oss_sink.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_OSS_SINK_H -#define INCLUDED_AUDIO_OSS_SINK_H - -#include <gr_sync_block.h> -#include <string> - - -class audio_oss_sink; -typedef boost::shared_ptr<audio_oss_sink> audio_oss_sink_sptr; - -audio_oss_sink_sptr -audio_oss_make_sink (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true); - -/*! - * \brief audio sink using OSS - * - * input signature is one or two streams of floats. - * Input samples must be in the range [-1,1]. - */ - -class audio_oss_sink : public gr_sync_block { - friend audio_oss_sink_sptr - audio_oss_make_sink (int sampling_rate, const std::string device_name, bool ok_to_block); - - int d_sampling_rate; - std::string d_device_name; - int d_fd; - short *d_buffer; - int d_chunk_size; - - protected: - audio_oss_sink (int sampling_rate, const std::string device_name = "", bool ok_to_block = true); - - public: - ~audio_oss_sink (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_AUDIO_OSS_SINK_H */ diff --git a/gr-audio-oss/src/audio_oss_source.cc b/gr-audio-oss/src/audio_oss_source.cc deleted file mode 100644 index fbb898f8c..000000000 --- a/gr-audio-oss/src/audio_oss_source.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_oss_source.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <sys/soundcard.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> - - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_oss", "default_input_device", "/dev/dsp"); -} - -audio_oss_source_sptr -audio_oss_make_source (int sampling_rate, const std::string dev, bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_oss_source (sampling_rate, dev, ok_to_block)); -} - - -audio_oss_source::audio_oss_source (int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_oss_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 2, sizeof (float))), - d_sampling_rate (sampling_rate), - d_device_name (device_name.empty() ? default_device_name() : device_name), - d_fd (-1), d_buffer (0), d_chunk_size (0) -{ - if ((d_fd = open (d_device_name.c_str (), O_RDONLY)) < 0){ - fprintf (stderr, "audio_oss_source: "); - perror (d_device_name.c_str ()); - throw std::runtime_error ("audio_oss_source"); - } - - double CHUNK_TIME = - std::max(0.001, gr_prefs::singleton()->get_double("audio_oss", "latency", 0.005)); - - d_chunk_size = (int) (d_sampling_rate * CHUNK_TIME); - set_output_multiple (d_chunk_size); - - d_buffer = new short [d_chunk_size * 2]; - - int format = AFMT_S16_NE; - int orig_format = format; - if (ioctl (d_fd, SNDCTL_DSP_SETFMT, &format) < 0){ - std::cerr << "audio_oss_source: " << d_device_name << " ioctl failed\n"; - perror (d_device_name.c_str ()); - throw std::runtime_error ("audio_oss_source"); - } - - if (format != orig_format){ - fprintf (stderr, "audio_oss_source: unable to support format %d\n", orig_format); - fprintf (stderr, " card requested %d instead.\n", format); - } - - // set to stereo no matter what. Some hardware only does stereo - int channels = 2; - if (ioctl (d_fd, SNDCTL_DSP_CHANNELS, &channels) < 0 || channels != 2){ - perror ("audio_oss_source: could not set STEREO mode"); - throw std::runtime_error ("audio_oss_source"); - } - - // set sampling freq - int sf = sampling_rate; - if (ioctl (d_fd, SNDCTL_DSP_SPEED, &sf) < 0){ - std::cerr << "audio_oss_source: " - << d_device_name << ": invalid sampling_rate " - << sampling_rate << "\n"; - sampling_rate = 8000; - if (ioctl (d_fd, SNDCTL_DSP_SPEED, &sf) < 0){ - std::cerr << "audio_oss_source: failed to set sampling_rate to 8000\n"; - throw std::runtime_error ("audio_oss_source"); - } - } -} - -audio_oss_source::~audio_oss_source () -{ - close (d_fd); - delete [] d_buffer; -} - -int -audio_oss_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *f0 = (float *) output_items[0]; - float *f1 = (float *) output_items[1]; // will be invalid if this is mono output - - const int shorts_per_item = 2; // L + R - const int bytes_per_item = shorts_per_item * sizeof (short); - - // To minimize latency, never return more than CHUNK_TIME - // worth of samples per call to work. - - noutput_items = std::min (noutput_items, d_chunk_size); - - int base = 0; - int ntogo = noutput_items; - - while (ntogo > 0){ - int nbytes = std::min (ntogo, d_chunk_size) * bytes_per_item; - int result_nbytes = read (d_fd, d_buffer, nbytes); - - if (result_nbytes < 0){ - perror ("audio_oss_source"); - return -1; // say we're done - } - - if ((result_nbytes & (bytes_per_item - 1)) != 0){ - fprintf (stderr, "audio_oss_source: internal error.\n"); - throw std::runtime_error ("internal error"); - } - - int result_nitems = result_nbytes / bytes_per_item; - - // now unpack samples into output streams - - switch (output_items.size ()){ - case 1: // mono output - for (int i = 0; i < result_nitems; i++){ - f0[base+i] = d_buffer[2*i+0] * (1.0 / 32767); - } - break; - - case 2: // stereo output - for (int i = 0; i < result_nitems; i++){ - f0[base+i] = d_buffer[2*i+0] * (1.0 / 32767); - f1[base+i] = d_buffer[2*i+1] * (1.0 / 32767); - } - break; - - default: - assert (0); - } - - ntogo -= result_nitems; - base += result_nitems; - } - - return noutput_items - ntogo; -} diff --git a/gr-audio-oss/src/audio_oss_source.h b/gr-audio-oss/src/audio_oss_source.h deleted file mode 100644 index 22d4392e2..000000000 --- a/gr-audio-oss/src/audio_oss_source.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_OSS_SOURCE_H -#define INCLUDED_AUDIO_OSS_SOURCE_H - -#include <gr_sync_block.h> -#include <string> - - -class audio_oss_source; -typedef boost::shared_ptr<audio_oss_source> audio_oss_source_sptr; - -audio_oss_source_sptr -audio_oss_make_source (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true); - -/*! - * \brief audio source using OSS - * - * Output signature is one or two streams of floats. - * Output samples will be in the range [-1,1]. - */ - -class audio_oss_source : public gr_sync_block { - friend audio_oss_source_sptr - audio_oss_make_source (int sampling_rate, const std::string device_name, bool ok_to_block); - - int d_sampling_rate; - std::string d_device_name; - int d_fd; - short *d_buffer; - int d_chunk_size; - - protected: - audio_oss_source (int sampling_rate, - const std::string device_name = "", - bool ok_to_block = true); - - public: - ~audio_oss_source (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - - -#endif /* INCLUDED_AUDIO_OSS_SOURCE_H */ diff --git a/gr-audio-oss/src/qa_oss.py b/gr-audio-oss/src/qa_oss.py deleted file mode 100755 index 365dabc25..000000000 --- a/gr-audio-oss/src/qa_oss.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import audio_oss - -class test_audio_oss (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have OSS drivers, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.run(test_audio_oss, "test_audio_oss.xml") diff --git a/gr-audio-oss/src/run_tests.in b/gr-audio-oss/src/run_tests.in deleted file mode 100644 index b1a64c212..000000000 --- a/gr-audio-oss/src/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-audio-oss \ - @abs_top_builddir@/gr-audio-oss \ - @srcdir@ diff --git a/gr-audio-osx/.gitignore b/gr-audio-osx/.gitignore deleted file mode 100644 index cdcf41b15..000000000 --- a/gr-audio-osx/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/config.cache -/config.h -/config.h.in -/config.log -/config.status -/configure -/depcomp -/install-sh -/libtool -/ltmain.sh -/make.log -/missing -/missing -/mkinstalldirs -/py-compile -/stamp-h -/stamp-h.in -/stamp-h1 diff --git a/gr-audio-osx/Makefile.am b/gr-audio-osx/Makefile.am deleted file mode 100644 index 84a4c69b3..000000000 --- a/gr-audio-osx/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright 2004,2006,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -EXTRA_DIST += README_OSX -SUBDIRS = src diff --git a/gr-audio-osx/README_OSX b/gr-audio-osx/README_OSX deleted file mode 100644 index 2a98e96bb..000000000 --- a/gr-audio-osx/README_OSX +++ /dev/null @@ -1,61 +0,0 @@ -Michael Dickens -2006-Apr-30 - -0) This module should compile and install in the same manner as the -other GNURadio modules (e.g. gnuradio-core), with the possible -exception that GNU libtool 1.5.20 or newer should be installed and -used (if not first in the path) via "make LIBTOOL=/..." and so forth. -Version 1.5.10 has failed making, and while picking version 1.5.20 is -somewhat arbitrary, the newer version compiles and installs easily -under OSX. - -1) This module should be automatically loaded by the Python command -"from gr import audio". The audio import script will automatically -select gr.audio_osx if it is available (though it will try to import -ALSA first, then OSS, then OSX, and finally WINDOWS audio modules, in -that order). If that import command doesn't work, try reinstalling -gnuradio-core from scratch followed by gr-audio-osx. - -2) Instantiation arguments for either source or sink are: - -* sample_rate : integer : default == 44100 - OSX converts the integer sample rate to a double internally; it - would be nice to have this input as a double natively, but that - doesn't work with other audio devices. - -* device_name : string : default == "2" - For OSX, the device name should be an integer string. This value is - the maximum number of channels to allocate (for input or output). - In the "source" case (input), the actual number of channels will be - whatever is available on that current system input device. In the - "sink" case (output), OSX will convert the provided channels into - whatever format is required by the current system output device. - For example, "3" would try to setup for 3 input or output channels. - NOTE that this is a very different use than that for other audio - modules (though they can interpret the number of channels from this - argument). - -* do_block : boolean : default == true - If the data transfer buffer between OSX internals and GNURadio gets - full, either block (true) or overwrite (false) depending on this - variable. - -The following are currently non-standard arguments: - -* channel_config : integer : default == -1 - An enum (internally) describing the channel configuration. Not - currently used, but rather reserved for future expansion. - -* max_sample_count : integer : default == -1 - The maximum number of samples to buffer between OSX internals and - GNURadio. The value -1 is mapped to 1 second's worth of data. - -3) When the buffer is full and do_block is false and new data comes -in, the oldest data will be overwritten. The source will print out -"iX" each time this happens; the sink will print out "oX". - -4) In the "src" directory is a python script "test_audio_loop" which -connects the default audio input device to the default audio output -device. This script is very useful in testing that audio is correctly -installed and both the source and sink are functional. This script is -not run by "make check". diff --git a/gr-audio-osx/TODO b/gr-audio-osx/TODO deleted file mode 100644 index e36ed2b25..000000000 --- a/gr-audio-osx/TODO +++ /dev/null @@ -1,51 +0,0 @@ -List as of 2006-Apr-22, by Michael Dickens, primary author - -* Change buffering to use gr_buffer's and necessary related classes. - Currently uses a circular_buffer I wrote myself (in - ./src/circular_buffer.h ), which hides the "circular" part from the - user but otherwise is very fast as well as thread safe. - -* A current limitation of this implementation is that the user cannot - dynamically switch audio devices (input or output) during playback - and use the new device without stopping the current executing GR and - restarting the process. I would like to figure out how to get a - CoreAudio "listener" for when the default hardware input / output - device changes (e.g. when switched by the user in the "Sound" system - preference pane). The code in ./src/audio-osx-source.cc creates - listeners for the AudioUnit being used as well as the Hardware - device, but these for some reason don't do the trick. It's possible - that the Python framework doesn't allow for one to do this. - -* In both the source and sink, move the code which defines the "Audio - Stream Basic Description" (ASBD) to a routine to do this as needed - as start-up as well as in a callback ("listener") if the default - device changes. - -* Tweak the mutex (d_internal) to only where it is truly needed - (around class-specific variables used across all threads) in order - to improve performance. Currently the mutex is used at the - start and end of any function requiring access to the class variables. - -* Change the instantiation arguments ... once those arguments are - finalized. Right now gr.audio.source () takes the sample rate (int - - should be double), the device name (std::string), a boolean for - blocking or not, and 2 completely non-standard ones for channel - configuration and the maximum sample count to buffer. These are - reasonable for OSX, but might not be for other OSs. Nothing to do - right now but wait and discuss. - -* Once the previous issue has been resolved, then the current method - of determining the number of channels needs to be updated. - Currently the "device_name" for OSX should contain a numeric string - for the maximum number of channels to use (e.g. "3" means 3 - channels, generally mapped to 2 channel stereo by OSX). The - "device_name" is generally input via "-O" in Python scripts, so "-O - 3" would allow for 3 incoming output channels (or fewer). In theory - the "channel_config" argument would make more sense for determining - channel usage. Example config strings might be "2.1" for stereo w/ - subwoofer (3 channels), "5.1" or "6.1" for various surround w/ - subwoofer (6 & 7 channels, respectively). OSX can handle all sorts - of channel configurations, but the names for these will be different - than those use for OSS or ALMA or Windows ... thus the need for a - common naming scheme for all cared-about configurations, possibly - with options for other OS-specific options. diff --git a/gr-audio-osx/src/.gitignore b/gr-audio-osx/src/.gitignore deleted file mode 100644 index 7e84b05b3..000000000 --- a/gr-audio-osx/src/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/usrp.py -/usrp.cc -/audio_osx.cc -/audio_osx.py -/run_tests -/gnuradio -/guile -/python diff --git a/gr-audio-osx/src/Makefile.am b/gr-audio-osx/src/Makefile.am deleted file mode 100644 index fce31c9d2..000000000 --- a/gr-audio-osx/src/Makefile.am +++ /dev/null @@ -1,80 +0,0 @@ -# -# Copyright 2006,2008,2009,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio. -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -TESTS = -EXTRA_DIST += run_tests.in -DISTCLEANFILES += run_tests - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - audio_osx_sink.h \ - audio_osx_source.h - -noinst_HEADERS = \ - audio_osx.h \ - circular_buffer.h - -noinst_PYTHON = \ - qa_osx.py \ - test_audio_loop.py - -lib_LTLIBRARIES = libgnuradio-audio-osx.la - -libgnuradio_audio_osx_la_SOURCES = \ - audio_osx_sink.cc \ - audio_osx_source.cc - -libgnuradio_audio_osx_la_LIBADD = \ - $(GNURADIO_CORE_LA) - -libgnuradio_audio_osx_la_LDFLAGS = \ - -framework AudioUnit \ - -framework CoreAudio \ - -framework AudioToolbox \ - $(NO_UNDEFINED) \ - $(LTVERSIONFLAGS) - -################################### -# SWIG interfaces and libraries - -TOP_SWIG_IFILES = \ - audio_osx.i - -# Install so that they end up available as: -# import gnuradio.audio_osx -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -audio_osx_pythondir_category = \ - gnuradio - -# additional libraries for linking with the SWIG-generated library -audio_osx_la_swig_libadd = \ - libgnuradio-audio-osx.la - - -if PYTHON -TESTS += run_tests -endif
\ No newline at end of file diff --git a/gr-audio-osx/src/Makefile.swig.gen b/gr-audio-osx/src/Makefile.swig.gen deleted file mode 100644 index 532433083..000000000 --- a/gr-audio-osx/src/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for audio_osx.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/audio_osx -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/audio_osx -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -audio_osx_pythondir_category ?= gnuradio/audio_osx -audio_osx_pylibdir_category ?= $(audio_osx_pythondir_category) -audio_osx_pythondir = $(pythondir)/$(audio_osx_pythondir_category) -audio_osx_pylibdir = $(pyexecdir)/$(audio_osx_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -audio_osx_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/audio_osx -# FIXME: determince whether these should be installed with gnuradio. -audio_osx_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -audio_osx_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -audio_osx_swiginclude_HEADERS = \ - audio_osx.i \ - $(audio_osx_swiginclude_headers) - -if PYTHON -audio_osx_pylib_LTLIBRARIES = \ - _audio_osx.la - -_audio_osx_la_SOURCES = \ - python/audio_osx.cc \ - $(audio_osx_la_swig_sources) - -audio_osx_python_PYTHON = \ - audio_osx.py \ - $(audio_osx_python) - -_audio_osx_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_osx_la_swig_libadd) - -_audio_osx_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_osx_la_swig_ldflags) - -_audio_osx_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_osx_la_swig_cxxflags) - -python/audio_osx.cc: audio_osx.py -audio_osx.py: audio_osx.i - -# Include the python dependencies for this file --include python/audio_osx.d - -endif # end of if python - -if GUILE - -audio_osx_scmlib_LTLIBRARIES = \ - libguile-gnuradio-audio_osx.la -libguile_gnuradio_audio_osx_la_SOURCES = \ - guile/audio_osx.cc \ - $(audio_osx_la_swig_sources) -nobase_audio_osx_scm_DATA = \ - gnuradio/audio_osx.scm \ - gnuradio/audio_osx-primitive.scm -libguile_gnuradio_audio_osx_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_osx_la_swig_libadd) -libguile_gnuradio_audio_osx_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_osx_la_swig_ldflags) -libguile_gnuradio_audio_osx_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_osx_la_swig_cxxflags) - -guile/audio_osx.cc: gnuradio/audio_osx.scm -gnuradio/audio_osx.scm: audio_osx.i -gnuradio/audio_osx-primitive.scm: gnuradio/audio_osx.scm - -# Include the guile dependencies for this file --include guile/audio_osx.d - -endif # end of GUILE - - diff --git a/gr-audio-osx/src/audio_osx.h b/gr-audio-osx/src/audio_osx.h deleted file mode 100644 index 79e79e36c..000000000 --- a/gr-audio-osx/src/audio_osx.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_OSX_H -#define INCLUDED_AUDIO_OSX_H - -#include <iostream> -#include <string.h> - -#define CheckErrorAndThrow(err,what,throw_str) \ - if (err) { \ - OSStatus error = static_cast<OSStatus>(err); \ - char err_str[4]; \ - strncpy (err_str, (char*)(&err), 4); \ - std::cerr << what << std::endl; \ - std::cerr << " Error# " << error << " ('" << err_str \ - << "')" << std::endl; \ - std::cerr << " " << __FILE__ << ":" << __LINE__ << std::endl; \ - fflush (stderr); \ - throw std::runtime_error (throw_str); \ - } - -#define CheckError(err,what) \ - if (err) { \ - OSStatus error = static_cast<OSStatus>(err); \ - char err_str[4]; \ - strncpy (err_str, (char*)(&err), 4); \ - std::cerr << what << std::endl; \ - std::cerr << " Error# " << error << " ('" << err_str \ - << "')" << std::endl; \ - std::cerr << " " << __FILE__ << ":" << __LINE__ << std::endl; \ - fflush (stderr); \ - } - -#ifdef WORDS_BIGENDIAN -#define GR_PCM_ENDIANNESS kLinearPCMFormatFlagIsBigEndian -#else -#define GR_PCM_ENDIANNESS 0 -#endif - -// Check the version of MacOSX being used -#ifdef __APPLE_CC__ -#include <AvailabilityMacros.h> -#ifndef MAC_OS_X_VERSION_10_6 -#define MAC_OS_X_VERSION_10_6 1060 -#endif -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 -#define GR_USE_OLD_AUDIO_UNIT -#endif -#endif - -#endif /* INCLUDED_AUDIO_OSX_H */ diff --git a/gr-audio-osx/src/audio_osx.i b/gr-audio-osx/src/audio_osx.i deleted file mode 100644 index a51e9bae0..000000000 --- a/gr-audio-osx/src/audio_osx.i +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "audio_osx_sink.h" -#include "audio_osx_source.h" -%} - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_osx,sink) - -audio_osx_sink_sptr -audio_osx_make_sink (int sample_rate = 44100, - const std::string device_name = "2", - bool do_block = TRUE, - int channel_config = -1, - int max_sample_count = -1 - ) throw (std::runtime_error); - -class audio_osx_sink : public gr_sync_block { - protected: - audio_osx_sink (int sample_rate = 44100, - const std::string device_name = "2", - bool do_block = TRUE, - int channel_config = -1, - int max_sample_count = -1); - - public: - ~audio_osx_sink (); - - bool start (); - bool stop (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_osx,source) - -audio_osx_source_sptr -audio_osx_make_source (int sample_rate = 44100, - const std::string device_name = "2", - bool do_block = TRUE, - int channel_config = -1, - int max_sample_count = -1 - ) throw (std::runtime_error); - -class audio_osx_source : public gr_sync_block { - protected: - audio_osx_source (int sample_rate = 44100, - const std::string device_name = "2", - bool do_block = TRUE, - int channel_config = -1, - int max_sample_count = -1); - - public: - ~audio_osx_source (); - - bool start (); - bool stop (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-audio_osx" "scm_init_gnuradio_audio_osx_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-audio-osx/src/audio_osx_sink.cc b/gr-audio-osx/src/audio_osx_sink.cc deleted file mode 100644 index ec9b024e8..000000000 --- a/gr-audio-osx/src/audio_osx_sink.cc +++ /dev/null @@ -1,411 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_osx_sink.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <audio_osx.h> - -#define _OSX_AU_DEBUG_ 0 - -audio_osx_sink::audio_osx_sink (int sample_rate, - const std::string device_name, - bool do_block, - int channel_config, - int max_sample_count) - : gr_sync_block ("audio_osx_sink", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)), - d_sample_rate (0.0), d_channel_config (0), d_n_channels (0), - d_queueSampleCount (0), d_max_sample_count (0), - d_do_block (do_block), d_internal (0), d_cond_data (0), - d_OutputAU (0) -{ - if (sample_rate <= 0) { - std::cerr << "Invalid Sample Rate: " << sample_rate << std::endl; - throw std::invalid_argument ("audio_osx_sink::audio_osx_sink"); - } else - d_sample_rate = (Float64) sample_rate; - - if (channel_config <= 0 & channel_config != -1) { - std::cerr << "Invalid Channel Config: " << channel_config << std::endl; - throw std::invalid_argument ("audio_osx_sink::audio_osx_sink"); - } else if (channel_config == -1) { -// no user input; try "device name" instead - int l_n_channels = (int) strtol (device_name.data(), (char **)NULL, 10); - if (l_n_channels == 0 & errno) { - std::cerr << "Error Converting Device Name: " << errno << std::endl; - throw std::invalid_argument ("audio_osx_sink::audio_osx_sink"); - } - if (l_n_channels <= 0) - channel_config = 2; - else - channel_config = l_n_channels; - } - - d_n_channels = d_channel_config = channel_config; - -// set the input signature - - set_input_signature (gr_make_io_signature (1, d_n_channels, sizeof (float))); - -// check that the max # of samples to store is valid - - if (max_sample_count == -1) - max_sample_count = sample_rate; - else if (max_sample_count <= 0) { - std::cerr << "Invalid Max Sample Count: " << max_sample_count << std::endl; - throw std::invalid_argument ("audio_osx_sink::audio_osx_sink"); - } - - d_max_sample_count = max_sample_count; - -// allocate the output circular buffer(s), one per channel - - d_buffers = (circular_buffer<float>**) new - circular_buffer<float>* [d_n_channels]; - UInt32 n_alloc = (UInt32) ceil ((double) d_max_sample_count); - for (UInt32 n = 0; n < d_n_channels; n++) { - d_buffers[n] = new circular_buffer<float> (n_alloc, false, false); - } - -// create the default AudioUnit for output - OSStatus err = noErr; - -// Open the default output unit -#ifndef GR_USE_OLD_AUDIO_UNIT - AudioComponentDescription desc; -#else - ComponentDescription desc; -#endif - - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_DefaultOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - -#ifndef GR_USE_OLD_AUDIO_UNIT - AudioComponent comp = AudioComponentFindNext(NULL, &desc); - if (comp == NULL) { - std::cerr << "AudioComponentFindNext Error" << std::endl; - throw std::runtime_error ("audio_osx_sink::audio_osx_sink"); - } -#else - Component comp = FindNextComponent (NULL, &desc); - if (comp == NULL) { - std::cerr << "FindNextComponent Error" << std::endl; - throw std::runtime_error ("audio_osx_sink::audio_osx_sink"); - } -#endif - -#ifndef GR_USE_OLD_AUDIO_UNIT - err = AudioComponentInstanceNew (comp, &d_OutputAU); - CheckErrorAndThrow (err, "AudioComponentInstanceNew", "audio_osx_sink::audio_osx_sink"); -#else - err = OpenAComponent (comp, &d_OutputAU); - CheckErrorAndThrow (err, "OpenAComponent", "audio_osx_sink::audio_osx_sink"); -#endif - -// Set up a callback function to generate output to the output unit - - AURenderCallbackStruct input; - input.inputProc = (AURenderCallback)(audio_osx_sink::AUOutputCallback); - input.inputProcRefCon = this; - - err = AudioUnitSetProperty (d_OutputAU, - kAudioUnitProperty_SetRenderCallback, - kAudioUnitScope_Input, - 0, - &input, - sizeof (input)); - CheckErrorAndThrow (err, "AudioUnitSetProperty Render Callback", "audio_osx_sink::audio_osx_sink"); - -// tell the Output Unit what format data will be supplied to it -// so that it handles any format conversions - - AudioStreamBasicDescription streamFormat; - streamFormat.mSampleRate = (Float64)(sample_rate); - streamFormat.mFormatID = kAudioFormatLinearPCM; - streamFormat.mFormatFlags = (kLinearPCMFormatFlagIsFloat | - GR_PCM_ENDIANNESS | - kLinearPCMFormatFlagIsPacked | - kAudioFormatFlagIsNonInterleaved); - streamFormat.mBytesPerPacket = 4; - streamFormat.mFramesPerPacket = 1; - streamFormat.mBytesPerFrame = 4; - streamFormat.mChannelsPerFrame = d_n_channels; - streamFormat.mBitsPerChannel = 32; - - err = AudioUnitSetProperty (d_OutputAU, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &streamFormat, - sizeof (AudioStreamBasicDescription)); - CheckErrorAndThrow (err, "AudioUnitSetProperty StreamFormat", "audio_osx_sink::audio_osx_sink"); - -// create the stuff to regulate I/O - - d_cond_data = new gruel::condition_variable (); - if (d_cond_data == NULL) - CheckErrorAndThrow (errno, "new condition (data)", - "audio_osx_sink::audio_osx_sink"); - - d_internal = new gruel::mutex (); - if (d_internal == NULL) - CheckErrorAndThrow (errno, "new mutex (internal)", - "audio_osx_sink::audio_osx_sink"); - -// initialize the AU for output - - err = AudioUnitInitialize (d_OutputAU); - CheckErrorAndThrow (err, "AudioUnitInitialize", - "audio_osx_sink::audio_osx_sink"); - -#if _OSX_AU_DEBUG_ - std::cerr << "audio_osx_sink Parameters:" << std::endl; - std::cerr << " Sample Rate is " << d_sample_rate << std::endl; - std::cerr << " Number of Channels is " << d_n_channels << std::endl; - std::cerr << " Max # samples to store per channel is " << d_max_sample_count << std::endl; -#endif -} - -bool audio_osx_sink::IsRunning () -{ - UInt32 AURunning = 0, AUSize = sizeof (UInt32); - - OSStatus err = AudioUnitGetProperty (d_OutputAU, - kAudioOutputUnitProperty_IsRunning, - kAudioUnitScope_Global, - 0, - &AURunning, - &AUSize); - CheckErrorAndThrow (err, "AudioUnitGetProperty IsRunning", - "audio_osx_sink::IsRunning"); - - return (AURunning); -} - -bool audio_osx_sink::start () -{ - if (! IsRunning ()) { - OSStatus err = AudioOutputUnitStart (d_OutputAU); - CheckErrorAndThrow (err, "AudioOutputUnitStart", "audio_osx_sink::start"); - } - - return (true); -} - -bool audio_osx_sink::stop () -{ - if (IsRunning ()) { - OSStatus err = AudioOutputUnitStop (d_OutputAU); - CheckErrorAndThrow (err, "AudioOutputUnitStop", "audio_osx_sink::stop"); - - for (UInt32 n = 0; n < d_n_channels; n++) { - d_buffers[n]->abort (); - } - } - - return (true); -} - -audio_osx_sink::~audio_osx_sink () -{ -// stop and close the AudioUnit - stop (); - AudioUnitUninitialize (d_OutputAU); -#ifndef GR_USE_OLD_AUDIO_UNIT - AudioComponentInstanceDispose (d_OutputAU); -#else - CloseComponent (d_OutputAU); -#endif - -// empty and delete the queues - for (UInt32 n = 0; n < d_n_channels; n++) { - delete d_buffers[n]; - d_buffers[n] = 0; - } - delete [] d_buffers; - d_buffers = 0; - -// close and delete control stuff - delete d_cond_data; - d_cond_data = 0; - delete d_internal; - d_internal = 0; -} - -audio_osx_sink_sptr -audio_osx_make_sink (int sampling_freq, - const std::string dev, - bool do_block, - int channel_config, - int max_sample_count) -{ - return gnuradio::get_initial_sptr(new audio_osx_sink (sampling_freq, - dev, - do_block, - channel_config, - max_sample_count)); -} - -int -audio_osx_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock l (*d_internal); - - /* take the input data, copy it, and push it to the bottom of the queue - mono input are pushed onto queue[0]; - stereo input are pushed onto queue[1]. - Start the AudioUnit if necessary. */ - - UInt32 l_max_count; - int diff_count = d_max_sample_count - noutput_items; - if (diff_count < 0) - l_max_count = 0; - else - l_max_count = (UInt32) diff_count; - -#if 0 - if (l_max_count < d_queueItemLength->back()) { -// allow 2 buffers at a time, regardless of length - l_max_count = d_queueItemLength->back(); - } -#endif - -#if _OSX_AU_DEBUG_ - std::cerr << "work1: qSC = " << d_queueSampleCount << ", lMC = "<< l_max_count - << ", dmSC = " << d_max_sample_count << ", nOI = " << noutput_items << std::endl; -#endif - - if (d_queueSampleCount > l_max_count) { -// data coming in too fast; do_block decides what to do - if (d_do_block == true) { -// block until there is data to return - while (d_queueSampleCount > l_max_count) { -// release control so-as to allow data to be retrieved; -// block until there is data to return - d_cond_data->wait (l); -// the condition's 'notify' was called; acquire control -// to keep thread safe - } - } - } -// not blocking case and overflow is handled by the circular buffer - -// add the input frames to the buffers' queue, checking for overflow - - UInt32 l_counter; - int res = 0; - float* inBuffer = (float*) input_items[0]; - const UInt32 l_size = input_items.size(); - for (l_counter = 0; l_counter < l_size; l_counter++) { - inBuffer = (float*) input_items[l_counter]; - int l_res = d_buffers[l_counter]->enqueue (inBuffer, - noutput_items); - if (l_res == -1) - res = -1; - } - while (l_counter < d_n_channels) { -// for extra channels, copy the last input's data - int l_res = d_buffers[l_counter++]->enqueue (inBuffer, - noutput_items); - if (l_res == -1) - res = -1; - } - - if (res == -1) { -// data coming in too fast -// drop oldest buffer - fputs ("aO", stderr); - fflush (stderr); -// set the local number of samples available to the max - d_queueSampleCount = d_buffers[0]->buffer_length_items (); - } else { -// keep up the local sample count - d_queueSampleCount += noutput_items; - } - -#if _OSX_AU_DEBUG_ - std::cerr << "work2: #OI = " << noutput_items << ", #Cnt = " - << d_queueSampleCount << ", mSC = " << d_max_sample_count << std::endl; -#endif - - return (noutput_items); -} - -OSStatus audio_osx_sink::AUOutputCallback -(void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList *ioData) -{ - audio_osx_sink* This = (audio_osx_sink*) inRefCon; - OSStatus err = noErr; - - gruel::scoped_lock l (*This->d_internal); - -#if _OSX_AU_DEBUG_ - std::cerr << "cb_in: SC = " << This->d_queueSampleCount - << ", in#F = " << inNumberFrames << std::endl; -#endif - - if (This->d_queueSampleCount < inNumberFrames) { -// not enough data to fill request - err = -1; - } else { -// enough data; remove data from our buffers into the AU's buffers - int l_counter = This->d_n_channels; - - while (--l_counter >= 0) { - size_t t_n_output_items = inNumberFrames; - float* outBuffer = (float*) ioData->mBuffers[l_counter].mData; - This->d_buffers[l_counter]->dequeue (outBuffer, &t_n_output_items); - if (t_n_output_items != inNumberFrames) { - throw std::runtime_error ("audio_osx_sink::AUOutputCallback(): " - "number of available items changing " - "unexpectedly.\n"); - } - } - - This->d_queueSampleCount -= inNumberFrames; - } - -#if _OSX_AU_DEBUG_ - std::cerr << "cb_out: SC = " << This->d_queueSampleCount << std::endl; -#endif - -// signal that data is available - This->d_cond_data->notify_one (); - - return (err); -} diff --git a/gr-audio-osx/src/audio_osx_sink.h b/gr-audio-osx/src/audio_osx_sink.h deleted file mode 100644 index a1a56502c..000000000 --- a/gr-audio-osx/src/audio_osx_sink.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_OSX_SINK_H -#define INCLUDED_AUDIO_OSX_SINK_H - -#include <gr_sync_block.h> -#include <string> -#include <list> -#include <AudioUnit/AudioUnit.h> -#include <circular_buffer.h> - -class audio_osx_sink; -typedef boost::shared_ptr<audio_osx_sink> audio_osx_sink_sptr; - -audio_osx_sink_sptr -audio_osx_make_sink (int sample_rate = 44100, - const std::string device_name = "2", - bool do_block = true, - int channel_config = -1, - int max_sample_count = -1); - -/*! - * \brief audio sink using OSX - * - * input signature is one or two streams of floats. - * Input samples must be in the range [-1,1]. - */ - -class audio_osx_sink : public gr_sync_block { - friend audio_osx_sink_sptr - audio_osx_make_sink (int sample_rate, - const std::string device_name, - bool do_block, - int channel_config, - int max_sample_count); - - Float64 d_sample_rate; - int d_channel_config; - UInt32 d_n_channels; - UInt32 d_queueSampleCount, d_max_sample_count; - bool d_do_block; - gruel::mutex* d_internal; - gruel::condition_variable* d_cond_data; - circular_buffer<float>** d_buffers; - -// AudioUnits and Such - AudioUnit d_OutputAU; - -protected: - audio_osx_sink (int sample_rate = 44100, - const std::string device_name = "2", - bool do_block = true, - int channel_config = -1, - int max_sample_count = -1); - -public: - ~audio_osx_sink (); - - bool IsRunning (); - bool start (); - bool stop (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - static OSStatus AUOutputCallback (void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList *ioData); -}; - -#endif /* INCLUDED_AUDIO_OSX_SINK_H */ diff --git a/gr-audio-osx/src/audio_osx_source.cc b/gr-audio-osx/src/audio_osx_source.cc deleted file mode 100644 index 757e65a9e..000000000 --- a/gr-audio-osx/src/audio_osx_source.cc +++ /dev/null @@ -1,1023 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_osx_source.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <audio_osx.h> - -#define _OSX_AU_DEBUG_ 0 -#define _OSX_DO_LISTENERS_ 0 - -void PrintStreamDesc (AudioStreamBasicDescription *inDesc) -{ - if (inDesc == NULL) { - std::cerr << "PrintStreamDesc: Can't print a NULL desc!" << std::endl; - return; - } - - std::cerr << " Sample Rate : " << inDesc->mSampleRate << std::endl; - char format_id[4]; - strncpy (format_id, (char*)(&inDesc->mFormatID), 4); - std::cerr << " Format ID : " << format_id << std::endl; - std::cerr << " Format Flags : " << inDesc->mFormatFlags << std::endl; - std::cerr << " Bytes per Packet : " << inDesc->mBytesPerPacket << std::endl; - std::cerr << " Frames per Packet : " << inDesc->mFramesPerPacket << std::endl; - std::cerr << " Bytes per Frame : " << inDesc->mBytesPerFrame << std::endl; - std::cerr << " Channels per Frame : " << inDesc->mChannelsPerFrame << std::endl; - std::cerr << " Bits per Channel : " << inDesc->mBitsPerChannel << std::endl; -} - -// FIXME these should query some kind of user preference - -audio_osx_source::audio_osx_source (int sample_rate, - const std::string device_name, - bool do_block, - int channel_config, - int max_sample_count) - : gr_sync_block ("audio_osx_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (0, 0, 0)), - d_deviceSampleRate (0.0), d_outputSampleRate (0.0), - d_channel_config (0), - d_inputBufferSizeFrames (0), d_inputBufferSizeBytes (0), - d_outputBufferSizeFrames (0), d_outputBufferSizeBytes (0), - d_deviceBufferSizeFrames (0), d_deviceBufferSizeBytes (0), - d_leadSizeFrames (0), d_leadSizeBytes (0), - d_trailSizeFrames (0), d_trailSizeBytes (0), - d_extraBufferSizeFrames (0), d_extraBufferSizeBytes (0), - d_queueSampleCount (0), d_max_sample_count (0), - d_n_AvailableInputFrames (0), d_n_ActualInputFrames (0), - d_n_user_channels (0), d_n_max_channels (0), d_n_deviceChannels (0), - d_do_block (do_block), d_passThrough (false), - d_internal (0), d_cond_data (0), - d_buffers (0), - d_InputAU (0), d_InputBuffer (0), d_OutputBuffer (0), - d_AudioConverter (0) -{ - if (sample_rate <= 0) { - std::cerr << "Invalid Sample Rate: " << sample_rate << std::endl; - throw std::invalid_argument ("audio_osx_source::audio_osx_source"); - } else - d_outputSampleRate = (Float64) sample_rate; - - if (channel_config <= 0 & channel_config != -1) { - std::cerr << "Invalid Channel Config: " << channel_config << std::endl; - throw std::invalid_argument ("audio_osx_source::audio_osx_source"); - } else if (channel_config == -1) { -// no user input; try "device name" instead - int l_n_channels = (int) strtol (device_name.data(), (char **)NULL, 10); - if (l_n_channels == 0 & errno) { - std::cerr << "Error Converting Device Name: " << errno << std::endl; - throw std::invalid_argument ("audio_osx_source::audio_osx_source"); - } - if (l_n_channels <= 0) - channel_config = 2; - else - channel_config = l_n_channels; - } - - d_channel_config = channel_config; - -// check that the max # of samples to store is valid - - if (max_sample_count == -1) - max_sample_count = sample_rate; - else if (max_sample_count <= 0) { - std::cerr << "Invalid Max Sample Count: " << max_sample_count << std::endl; - throw std::invalid_argument ("audio_osx_source::audio_osx_source"); - } - - d_max_sample_count = max_sample_count; - -#if _OSX_AU_DEBUG_ - std::cerr << "source(): max # samples = " << d_max_sample_count << std::endl; -#endif - - OSStatus err = noErr; - -// create the default AudioUnit for input - -// Open the default input unit -#ifndef GR_USE_OLD_AUDIO_UNIT - AudioComponentDescription InputDesc; -#else - ComponentDescription InputDesc; -#endif - - - InputDesc.componentType = kAudioUnitType_Output; - InputDesc.componentSubType = kAudioUnitSubType_HALOutput; - InputDesc.componentManufacturer = kAudioUnitManufacturer_Apple; - InputDesc.componentFlags = 0; - InputDesc.componentFlagsMask = 0; - -#ifndef GR_USE_OLD_AUDIO_UNIT - AudioComponent comp = AudioComponentFindNext (NULL, &InputDesc); -#else - Component comp = FindNextComponent (NULL, &InputDesc); -#endif - - if (comp == NULL) { -#ifndef GR_USE_OLD_AUDIO_UNIT - std::cerr << "AudioComponentFindNext Error" << std::endl; -#else - std::cerr << "FindNextComponent Error" << std::endl; -#endif - throw std::runtime_error ("audio_osx_source::audio_osx_source"); - } - -#ifndef GR_USE_OLD_AUDIO_UNIT - err = AudioComponentInstanceNew (comp, &d_InputAU); - CheckErrorAndThrow (err, "AudioComponentInstanceNew", - "audio_osx_source::audio_osx_source"); -#else - err = OpenAComponent (comp, &d_InputAU); - CheckErrorAndThrow (err, "OpenAComponent", - "audio_osx_source::audio_osx_source"); -#endif - - - UInt32 enableIO; - -// must enable the AUHAL for input and disable output -// before setting the AUHAL's current device - -// Enable input on the AUHAL - enableIO = 1; - err = AudioUnitSetProperty (d_InputAU, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Input, - 1, // input element - &enableIO, - sizeof (UInt32)); - CheckErrorAndThrow (err, "AudioUnitSetProperty Input Enable", - "audio_osx_source::audio_osx_source"); - -// Disable output on the AUHAL - enableIO = 0; - err = AudioUnitSetProperty (d_InputAU, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Output, - 0, // output element - &enableIO, - sizeof (UInt32)); - CheckErrorAndThrow (err, "AudioUnitSetProperty Output Disable", - "audio_osx_source::audio_osx_source"); - -// set the default input device for our input AU - - SetDefaultInputDeviceAsCurrent (); - -#if _OSX_DO_LISTENERS_ -// set up a listener if default hardware input device changes - - err = AudioHardwareAddPropertyListener - (kAudioHardwarePropertyDefaultInputDevice, - (AudioHardwarePropertyListenerProc) HardwareListener, - this); - - CheckErrorAndThrow (err, "AudioHardwareAddPropertyListener", - "audio_osx_source::audio_osx_source"); - -// Add a listener for any changes in the input AU's output stream -// the function "UnitListener" will be called if the stream format -// changes for whatever reason - - err = AudioUnitAddPropertyListener - (d_InputAU, - kAudioUnitProperty_StreamFormat, - (AudioUnitPropertyListenerProc) UnitListener, - this); - CheckErrorAndThrow (err, "Adding Unit Property Listener", - "audio_osx_source::audio_osx_source"); -#endif - -// Now find out if it actually can do input. - - UInt32 hasInput = 0; - UInt32 dataSize = sizeof (hasInput); - err = AudioUnitGetProperty (d_InputAU, - kAudioOutputUnitProperty_HasIO, - kAudioUnitScope_Input, - 1, - &hasInput, - &dataSize); - CheckErrorAndThrow (err, "AudioUnitGetProperty HasIO", - "audio_osx_source::audio_osx_source"); - if (hasInput == 0) { - std::cerr << "Selected Audio Device does not support Input." << std::endl; - throw std::runtime_error ("audio_osx_source::audio_osx_source"); - } - -// Set up a callback function to retrieve input from the Audio Device - - AURenderCallbackStruct AUCallBack; - - AUCallBack.inputProc = (AURenderCallback)(audio_osx_source::AUInputCallback); - AUCallBack.inputProcRefCon = this; - - err = AudioUnitSetProperty (d_InputAU, - kAudioOutputUnitProperty_SetInputCallback, - kAudioUnitScope_Global, - 0, - &AUCallBack, - sizeof (AURenderCallbackStruct)); - CheckErrorAndThrow (err, "AudioUnitSetProperty Input Callback", - "audio_osx_source::audio_osx_source"); - - UInt32 propertySize; - AudioStreamBasicDescription asbd_device, asbd_client, asbd_user; - -// asbd_device: ASBD of the device that is creating the input data stream -// asbd_client: ASBD of the client size (output) of the hardware device -// asbd_user: ASBD of the user's arguments - -// Get the Stream Format (device side) - - propertySize = sizeof (asbd_device); - err = AudioUnitGetProperty (d_InputAU, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 1, - &asbd_device, - &propertySize); - CheckErrorAndThrow (err, "AudioUnitGetProperty Device Input Stream Format", - "audio_osx_source::audio_osx_source"); - -#if _OSX_AU_DEBUG_ - std::cerr << std::endl << "---- Device Stream Format ----" << std::endl; - PrintStreamDesc (&asbd_device); -#endif - -// Get the Stream Format (client side) - propertySize = sizeof (asbd_client); - err = AudioUnitGetProperty (d_InputAU, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, - 1, - &asbd_client, - &propertySize); - CheckErrorAndThrow (err, "AudioUnitGetProperty Device Ouput Stream Format", - "audio_osx_source::audio_osx_source"); - -#if _OSX_AU_DEBUG_ - std::cerr << std::endl << "---- Client Stream Format ----" << std::endl; - PrintStreamDesc (&asbd_client); -#endif - -// Set the format of all the AUs to the input/output devices channel count - -// get the max number of input (& thus output) channels supported by -// this device - d_n_max_channels = asbd_client.mChannelsPerFrame; - -// create the output io signature; -// no input siganture to set (source is hardware) - set_output_signature (gr_make_io_signature (1, - d_n_max_channels, - sizeof (float))); - -// allocate the output circular buffer(s), one per channel - d_buffers = (circular_buffer<float>**) new - circular_buffer<float>* [d_n_max_channels]; - UInt32 n_alloc = (UInt32) ceil ((double) d_max_sample_count); - for (UInt32 n = 0; n < d_n_max_channels; n++) { - d_buffers[n] = new circular_buffer<float> (n_alloc, false, false); - } - - d_deviceSampleRate = asbd_device.mSampleRate; - d_n_deviceChannels = asbd_device.mChannelsPerFrame; - -// create an ASBD for the user's wants - - asbd_user.mSampleRate = d_outputSampleRate; - asbd_user.mFormatID = kAudioFormatLinearPCM; - asbd_user.mFormatFlags = (kLinearPCMFormatFlagIsFloat | - GR_PCM_ENDIANNESS | - kLinearPCMFormatFlagIsPacked | - kAudioFormatFlagIsNonInterleaved); - asbd_user.mBytesPerPacket = 4; - asbd_user.mFramesPerPacket = 1; - asbd_user.mBytesPerFrame = 4; - asbd_user.mChannelsPerFrame = d_n_max_channels; - asbd_user.mBitsPerChannel = 32; - - if (d_deviceSampleRate == d_outputSampleRate) { -// no need to do conversion if asbd_client matches user wants - d_passThrough = true; - d_leadSizeFrames = d_trailSizeFrames = 0L; - } else { - d_passThrough = false; -// Create the audio converter - - err = AudioConverterNew (&asbd_client, &asbd_user, &d_AudioConverter); - CheckErrorAndThrow (err, "AudioConverterNew", - "audio_osx_source::audio_osx_source"); - -// Set the audio converter sample rate quality to "max" ... -// requires more samples, but should sound nicer - - UInt32 ACQuality = kAudioConverterQuality_Max; - propertySize = sizeof (ACQuality); - err = AudioConverterSetProperty (d_AudioConverter, - kAudioConverterSampleRateConverterQuality, - propertySize, - &ACQuality); - CheckErrorAndThrow (err, "AudioConverterSetProperty " - "SampleRateConverterQuality", - "audio_osx_source::audio_osx_source"); - -// set the audio converter's prime method to "pre", -// which uses both leading and trailing frames -// from the "current input". All of this is handled -// internally by the AudioConverter; we just supply -// the frames for conversion. - -// UInt32 ACPrimeMethod = kConverterPrimeMethod_None; - UInt32 ACPrimeMethod = kConverterPrimeMethod_Pre; - propertySize = sizeof (ACPrimeMethod); - err = AudioConverterSetProperty (d_AudioConverter, - kAudioConverterPrimeMethod, - propertySize, - &ACPrimeMethod); - CheckErrorAndThrow (err, "AudioConverterSetProperty PrimeMethod", - "audio_osx_source::audio_osx_source"); - -// Get the size of the I/O buffer(s) to allow for pre-allocated buffers - -// lead frame info (trail frame info is ignored) - - AudioConverterPrimeInfo ACPrimeInfo = {0, 0}; - propertySize = sizeof (ACPrimeInfo); - err = AudioConverterGetProperty (d_AudioConverter, - kAudioConverterPrimeInfo, - &propertySize, - &ACPrimeInfo); - CheckErrorAndThrow (err, "AudioConverterGetProperty PrimeInfo", - "audio_osx_source::audio_osx_source"); - - switch (ACPrimeMethod) { - case (kConverterPrimeMethod_None): - d_leadSizeFrames = - d_trailSizeFrames = 0L; - break; - case (kConverterPrimeMethod_Normal): - d_leadSizeFrames = 0L; - d_trailSizeFrames = ACPrimeInfo.trailingFrames; - break; - default: - d_leadSizeFrames = ACPrimeInfo.leadingFrames; - d_trailSizeFrames = ACPrimeInfo.trailingFrames; - } - } - d_leadSizeBytes = d_leadSizeFrames * sizeof (Float32); - d_trailSizeBytes = d_trailSizeFrames * sizeof (Float32); - - propertySize = sizeof (d_deviceBufferSizeFrames); - err = AudioUnitGetProperty (d_InputAU, - kAudioDevicePropertyBufferFrameSize, - kAudioUnitScope_Global, - 0, - &d_deviceBufferSizeFrames, - &propertySize); - CheckErrorAndThrow (err, "AudioUnitGetProperty Buffer Frame Size", - "audio_osx_source::audio_osx_source"); - - d_deviceBufferSizeBytes = d_deviceBufferSizeFrames * sizeof (Float32); - d_inputBufferSizeBytes = d_deviceBufferSizeBytes + d_leadSizeBytes; - d_inputBufferSizeFrames = d_deviceBufferSizeFrames + d_leadSizeFrames; - -// outBufSizeBytes = floor (inBufSizeBytes * rate_out / rate_in) -// since this is rarely exact, we need another buffer to hold -// "extra" samples not processed at any given sampling period -// this buffer must be at least 4 floats in size, but generally -// follows the rule that -// extraBufSize = ceil (rate_in / rate_out)*sizeof(float) - - d_extraBufferSizeFrames = ((UInt32) ceil (d_deviceSampleRate - / d_outputSampleRate) - * sizeof (float)); - if (d_extraBufferSizeFrames < 4) - d_extraBufferSizeFrames = 4; - d_extraBufferSizeBytes = d_extraBufferSizeFrames * sizeof (float); - - d_outputBufferSizeFrames = (UInt32) ceil (((Float64) d_inputBufferSizeFrames) - * d_outputSampleRate - / d_deviceSampleRate); - d_outputBufferSizeBytes = d_outputBufferSizeFrames * sizeof (float); - d_inputBufferSizeFrames += d_extraBufferSizeFrames; - -// pre-alloc all buffers - - AllocAudioBufferList (&d_InputBuffer, d_n_deviceChannels, - d_inputBufferSizeBytes); - if (d_passThrough == false) { - AllocAudioBufferList (&d_OutputBuffer, d_n_max_channels, - d_outputBufferSizeBytes); - } else { - d_OutputBuffer = d_InputBuffer; - } - -// create the stuff to regulate I/O - - d_cond_data = new gruel::condition_variable (); - if (d_cond_data == NULL) - CheckErrorAndThrow (errno, "new condition (data)", - "audio_osx_source::audio_osx_source"); - - d_internal = new gruel::mutex (); - if (d_internal == NULL) - CheckErrorAndThrow (errno, "new mutex (internal)", - "audio_osx_source::audio_osx_source"); - -// initialize the AU for input - - err = AudioUnitInitialize (d_InputAU); - CheckErrorAndThrow (err, "AudioUnitInitialize", - "audio_osx_source::audio_osx_source"); - -#if _OSX_AU_DEBUG_ - std::cerr << "audio_osx_source Parameters:" << std::endl; - std::cerr << " Device Sample Rate is " << d_deviceSampleRate << std::endl; - std::cerr << " User Sample Rate is " << d_outputSampleRate << std::endl; - std::cerr << " Max Sample Count is " << d_max_sample_count << std::endl; - std::cerr << " # Device Channels is " << d_n_deviceChannels << std::endl; - std::cerr << " # Max Channels is " << d_n_max_channels << std::endl; - std::cerr << " Device Buffer Size is Frames = " << d_deviceBufferSizeFrames << std::endl; - std::cerr << " Lead Size is Frames = " << d_leadSizeFrames << std::endl; - std::cerr << " Trail Size is Frames = " << d_trailSizeFrames << std::endl; - std::cerr << " Input Buffer Size is Frames = " << d_inputBufferSizeFrames << std::endl; - std::cerr << " Output Buffer Size is Frames = " << d_outputBufferSizeFrames << std::endl; -#endif -} - -void -audio_osx_source::AllocAudioBufferList (AudioBufferList** t_ABL, - UInt32 n_channels, - UInt32 bufferSizeBytes) -{ - FreeAudioBufferList (t_ABL); - UInt32 propertySize = (offsetof (AudioBufferList, mBuffers[0]) + - (sizeof (AudioBuffer) * n_channels)); - *t_ABL = (AudioBufferList*) calloc (1, propertySize); - (*t_ABL)->mNumberBuffers = n_channels; - - int counter = n_channels; - - while (--counter >= 0) { - (*t_ABL)->mBuffers[counter].mNumberChannels = 1; - (*t_ABL)->mBuffers[counter].mDataByteSize = bufferSizeBytes; - (*t_ABL)->mBuffers[counter].mData = calloc (1, bufferSizeBytes); - } -} - -void -audio_osx_source::FreeAudioBufferList (AudioBufferList** t_ABL) -{ -// free pre-allocated audio buffer, if it exists - if (*t_ABL != NULL) { - int counter = (*t_ABL)->mNumberBuffers; - while (--counter >= 0) - free ((*t_ABL)->mBuffers[counter].mData); - free (*t_ABL); - (*t_ABL) = 0; - } -} - -bool audio_osx_source::IsRunning () -{ - UInt32 AURunning = 0, AUSize = sizeof (UInt32); - - OSStatus err = AudioUnitGetProperty (d_InputAU, - kAudioOutputUnitProperty_IsRunning, - kAudioUnitScope_Global, - 0, - &AURunning, - &AUSize); - CheckErrorAndThrow (err, "AudioUnitGetProperty IsRunning", - "audio_osx_source::IsRunning"); - - return (AURunning); -} - -bool audio_osx_source::start () -{ - if (! IsRunning ()) { - OSStatus err = AudioOutputUnitStart (d_InputAU); - CheckErrorAndThrow (err, "AudioOutputUnitStart", - "audio_osx_source::start"); - } - - return (true); -} - -bool audio_osx_source::stop () -{ - if (IsRunning ()) { - OSStatus err = AudioOutputUnitStop (d_InputAU); - CheckErrorAndThrow (err, "AudioOutputUnitStart", - "audio_osx_source::stop"); - for (UInt32 n = 0; n < d_n_user_channels; n++) { - d_buffers[n]->abort (); - } - } - - return (true); -} - -audio_osx_source::~audio_osx_source () -{ - OSStatus err = noErr; - -// stop the AudioUnit - stop(); - -#if _OSX_DO_LISTENERS_ -// remove the listeners - - err = AudioUnitRemovePropertyListener - (d_InputAU, - kAudioUnitProperty_StreamFormat, - (AudioUnitPropertyListenerProc) UnitListener); - CheckError (err, "~audio_osx_source: AudioUnitRemovePropertyListener"); - - err = AudioHardwareRemovePropertyListener - (kAudioHardwarePropertyDefaultInputDevice, - (AudioHardwarePropertyListenerProc) HardwareListener); - CheckError (err, "~audio_osx_source: AudioHardwareRemovePropertyListener"); -#endif - -// free pre-allocated audio buffers - FreeAudioBufferList (&d_InputBuffer); - - if (d_passThrough == false) { - err = AudioConverterDispose (d_AudioConverter); - CheckError (err, "~audio_osx_source: AudioConverterDispose"); - FreeAudioBufferList (&d_OutputBuffer); - } - -// remove the audio unit - err = AudioUnitUninitialize (d_InputAU); - CheckError (err, "~audio_osx_source: AudioUnitUninitialize"); - -#ifndef GR_USE_OLD_AUDIO_UNIT - err = AudioComponentInstanceDispose (d_InputAU); - CheckError (err, "~audio_osx_source: AudioComponentInstanceDispose"); -#else - err = CloseComponent (d_InputAU); - CheckError (err, "~audio_osx_source: CloseComponent"); -#endif - -// empty and delete the queues - for (UInt32 n = 0; n < d_n_max_channels; n++) { - delete d_buffers[n]; - d_buffers[n] = 0; - } - delete [] d_buffers; - d_buffers = 0; - -// close and delete the control stuff - delete d_cond_data; - d_cond_data = 0; - delete d_internal; - d_internal = 0; -} - -audio_osx_source_sptr -audio_osx_make_source (int sampling_freq, - const std::string device_name, - bool do_block, - int channel_config, - int max_sample_count) -{ - return gnuradio::get_initial_sptr(new audio_osx_source (sampling_freq, - device_name, - do_block, - channel_config, - max_sample_count)); -} - -bool -audio_osx_source::check_topology (int ninputs, int noutputs) -{ -// check # inputs to make sure it's valid - if (ninputs != 0) { - std::cerr << "audio_osx_source::check_topology(): number of input " - << "streams provided (" << ninputs - << ") should be 0." << std::endl; - throw std::runtime_error ("audio_osx_source::check_topology()"); - } - -// check # outputs to make sure it's valid - if ((noutputs < 1) | (noutputs > (int) d_n_max_channels)) { - std::cerr << "audio_osx_source::check_topology(): number of output " - << "streams provided (" << noutputs << ") should be in [1," - << d_n_max_channels << "] for the selected audio device." - << std::endl; - throw std::runtime_error ("audio_osx_source::check_topology()"); - } - -// save the actual number of output (user) channels - d_n_user_channels = noutputs; - -#if _OSX_AU_DEBUG_ - std::cerr << "chk_topo: Actual # user output channels = " - << noutputs << std::endl; -#endif - - return (true); -} - -int -audio_osx_source::work -(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // acquire control to do processing here only - gruel::scoped_lock l (*d_internal); - -#if _OSX_AU_DEBUG_ - std::cerr << "work1: SC = " << d_queueSampleCount - << ", #OI = " << noutput_items - << ", #Chan = " << output_items.size() << std::endl; -#endif - - // set the actual # of output items to the 'desired' amount then - // verify that data is available; if not enough data is available, - // either wait until it is (is "do_block" is true), return (0) is no - // data is available and "do_block" is false, or process the actual - // amount of available data. - - UInt32 actual_noutput_items = noutput_items; - - if (d_queueSampleCount < actual_noutput_items) { - if (d_queueSampleCount == 0) { - // no data; do_block decides what to do - if (d_do_block == true) { - while (d_queueSampleCount == 0) { - // release control so-as to allow data to be retrieved; - // block until there is data to return - d_cond_data->wait (l); - // the condition's 'notify' was called; acquire control to - // keep thread safe - } - } else { - // no data & not blocking; return nothing - return (0); - } - } - // use the actual amount of available data - actual_noutput_items = d_queueSampleCount; - } - - // number of channels - int l_counter = (int) output_items.size(); - - // copy the items from the circular buffer(s) to 'work's output buffers - // verify that the number copied out is as expected. - - while (--l_counter >= 0) { - size_t t_n_output_items = actual_noutput_items; - d_buffers[l_counter]->dequeue ((float*) output_items[l_counter], - &t_n_output_items); - if (t_n_output_items != actual_noutput_items) { - std::cerr << "audio_osx_source::work(): ERROR: number of " - << "available items changing unexpectedly; expecting " - << actual_noutput_items << ", got " - << t_n_output_items << "." << std::endl; - throw std::runtime_error ("audio_osx_source::work()"); - } - } - - // subtract the actual number of items removed from the buffer(s) - // from the local accounting of the number of available samples - - d_queueSampleCount -= actual_noutput_items; - -#if _OSX_AU_DEBUG_ - std::cerr << "work2: SC = " << d_queueSampleCount - << ", act#OI = " << actual_noutput_items << std::endl - << "Returning." << std::endl; -#endif - - return (actual_noutput_items); -} - -OSStatus -audio_osx_source::ConverterCallback -(AudioConverterRef inAudioConverter, - UInt32* ioNumberDataPackets, - AudioBufferList* ioData, - AudioStreamPacketDescription** ioASPD, - void* inUserData) -{ - // take current device buffers and copy them to the tail of the - // input buffers the lead buffer is already there in the first - // d_leadSizeFrames slots - - audio_osx_source* This = static_cast<audio_osx_source*>(inUserData); - AudioBufferList* l_inputABL = This->d_InputBuffer; - UInt32 totalInputBufferSizeBytes = ((*ioNumberDataPackets) * sizeof (float)); - int counter = This->d_n_deviceChannels; - ioData->mNumberBuffers = This->d_n_deviceChannels; - This->d_n_ActualInputFrames = (*ioNumberDataPackets); - -#if _OSX_AU_DEBUG_ - std::cerr << "cc1: io#DP = " << (*ioNumberDataPackets) - << ", TIBSB = " << totalInputBufferSizeBytes - << ", #C = " << counter << std::endl; -#endif - - while (--counter >= 0) { - AudioBuffer* l_ioD_AB = &(ioData->mBuffers[counter]); - l_ioD_AB->mNumberChannels = 1; - l_ioD_AB->mData = (float*)(l_inputABL->mBuffers[counter].mData); - l_ioD_AB->mDataByteSize = totalInputBufferSizeBytes; - } - -#if _OSX_AU_DEBUG_ - std::cerr << "cc2: Returning." << std::endl; -#endif - - return (noErr); -} - -OSStatus -audio_osx_source::AUInputCallback (void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData) -{ - OSStatus err = noErr; - audio_osx_source* This = static_cast<audio_osx_source*>(inRefCon); - - gruel::scoped_lock l (*This->d_internal); - -#if _OSX_AU_DEBUG_ - std::cerr << "cb0: in#F = " << inNumberFrames - << ", inBN = " << inBusNumber - << ", SC = " << This->d_queueSampleCount << std::endl; -#endif - -// Get the new audio data from the input device - - err = AudioUnitRender (This->d_InputAU, - ioActionFlags, - inTimeStamp, - 1, //inBusNumber, - inNumberFrames, - This->d_InputBuffer); - CheckErrorAndThrow (err, "AudioUnitRender", - "audio_osx_source::AUInputCallback"); - - UInt32 AvailableInputFrames = inNumberFrames; - This->d_n_AvailableInputFrames = inNumberFrames; - -// get the number of actual output frames, -// either via converting the buffer or not - - UInt32 ActualOutputFrames; - - if (This->d_passThrough == true) { - ActualOutputFrames = AvailableInputFrames; - } else { - UInt32 AvailableInputBytes = AvailableInputFrames * sizeof (float); - UInt32 AvailableOutputBytes = AvailableInputBytes; - UInt32 AvailableOutputFrames = AvailableOutputBytes / sizeof (float); - UInt32 propertySize = sizeof (AvailableOutputBytes); - err = AudioConverterGetProperty (This->d_AudioConverter, - kAudioConverterPropertyCalculateOutputBufferSize, - &propertySize, - &AvailableOutputBytes); - CheckErrorAndThrow (err, "AudioConverterGetProperty CalculateOutputBufferSize", "audio_osx_source::audio_osx_source"); - - AvailableOutputFrames = AvailableOutputBytes / sizeof (float); - -#if 0 -// when decimating too much, the output sounds warbly due to -// fluctuating # of output frames -// This should not be a surprise, but there's probably some -// clever programming that could lessed the effect ... -// like finding the "ideal" # of output frames, and keeping -// that number constant no matter the # of input frames - UInt32 l_InputBytes = AvailableOutputBytes; - propertySize = sizeof (AvailableOutputBytes); - err = AudioConverterGetProperty (This->d_AudioConverter, - kAudioConverterPropertyCalculateInputBufferSize, - &propertySize, - &l_InputBytes); - CheckErrorAndThrow (err, "AudioConverterGetProperty CalculateInputBufferSize", "audio_osx_source::audio_osx_source"); - - if (l_InputBytes < AvailableInputBytes) { -// OK to zero pad the input a little - AvailableOutputFrames += 1; - AvailableOutputBytes = AvailableOutputFrames * sizeof (float); - } -#endif - -#if _OSX_AU_DEBUG_ - std::cerr << "cb1: avail: #IF = " << AvailableInputFrames - << ", #OF = " << AvailableOutputFrames << std::endl; -#endif - ActualOutputFrames = AvailableOutputFrames; - -// convert the data to the correct rate -// on input, ActualOutputFrames is the number of available output frames - - err = AudioConverterFillComplexBuffer (This->d_AudioConverter, - (AudioConverterComplexInputDataProc)(This->ConverterCallback), - inRefCon, - &ActualOutputFrames, - This->d_OutputBuffer, - NULL); - CheckErrorAndThrow (err, "AudioConverterFillComplexBuffer", - "audio_osx_source::AUInputCallback"); - -// on output, ActualOutputFrames is the actual number of output frames - -#if _OSX_AU_DEBUG_ - std::cerr << "cb2: actual: #IF = " << This->d_n_ActualInputFrames - << ", #OF = " << AvailableOutputFrames << std::endl; - if (This->d_n_ActualInputFrames != AvailableInputFrames) - std::cerr << "cb2.1: avail#IF = " << AvailableInputFrames - << ", actual#IF = " << This->d_n_ActualInputFrames << std::endl; -#endif - } - -// add the output frames to the buffers' queue, checking for overflow - - int l_counter = This->d_n_user_channels; - int res = 0; - - while (--l_counter >= 0) { - float* inBuffer = (float*) This->d_OutputBuffer->mBuffers[l_counter].mData; - -#if _OSX_AU_DEBUG_ - std::cerr << "cb3: enqueuing audio data." << std::endl; -#endif - - int l_res = This->d_buffers[l_counter]->enqueue (inBuffer, ActualOutputFrames); - if (l_res == -1) - res = -1; - } - - if (res == -1) { -// data coming in too fast -// drop oldest buffer - fputs ("aO", stderr); - fflush (stderr); -// set the local number of samples available to the max - This->d_queueSampleCount = This->d_buffers[0]->buffer_length_items (); - } else { -// keep up the local sample count - This->d_queueSampleCount += ActualOutputFrames; - } - -#if _OSX_AU_DEBUG_ - std::cerr << "cb4: #OI = " << ActualOutputFrames - << ", #Cnt = " << This->d_queueSampleCount - << ", mSC = " << This->d_max_sample_count << std::endl; -#endif - -// signal that data is available, if appropraite - This->d_cond_data->notify_one (); - -#if _OSX_AU_DEBUG_ - std::cerr << "cb5: returning." << std::endl; -#endif - - return (err); -} - -void -audio_osx_source::SetDefaultInputDeviceAsCurrent -() -{ -// set the default input device - AudioDeviceID deviceID; - UInt32 dataSize = sizeof (AudioDeviceID); - AudioHardwareGetProperty (kAudioHardwarePropertyDefaultInputDevice, - &dataSize, - &deviceID); - OSStatus err = AudioUnitSetProperty (d_InputAU, - kAudioOutputUnitProperty_CurrentDevice, - kAudioUnitScope_Global, - 0, - &deviceID, - sizeof (AudioDeviceID)); - CheckErrorAndThrow (err, "AudioUnitSetProperty Current Device", - "audio_osx_source::SetDefaultInputDeviceAsCurrent"); -} - -#if _OSX_DO_LISTENERS_ -OSStatus -audio_osx_source::HardwareListener -(AudioHardwarePropertyID inPropertyID, - void *inClientData) -{ - OSStatus err = noErr; - audio_osx_source* This = static_cast<audio_osx_source*>(inClientData); - - std::cerr << "a_o_s::HardwareListener" << std::endl; - -// set the new default hardware input device for use by our AU - - This->SetDefaultInputDeviceAsCurrent (); - -// reset the converter to tell it that the stream has changed - - err = AudioConverterReset (This->d_AudioConverter); - CheckErrorAndThrow (err, "AudioConverterReset", - "audio_osx_source::UnitListener"); - - return (err); -} - -OSStatus -audio_osx_source::UnitListener -(void *inRefCon, - AudioUnit ci, - AudioUnitPropertyID inID, - AudioUnitScope inScope, - AudioUnitElement inElement) -{ - OSStatus err = noErr; - audio_osx_source* This = static_cast<audio_osx_source*>(inRefCon); - AudioStreamBasicDescription asbd; - - std::cerr << "a_o_s::UnitListener" << std::endl; - -// get the converter's input ASBD (for printing) - - UInt32 propertySize = sizeof (asbd); - err = AudioConverterGetProperty (This->d_AudioConverter, - kAudioConverterCurrentInputStreamDescription, - &propertySize, - &asbd); - CheckErrorAndThrow (err, "AudioConverterGetProperty " - "CurrentInputStreamDescription", - "audio_osx_source::UnitListener"); - - std::cerr << "UnitListener: Input Source changed." << std::endl - << "Old Source Output Info:" << std::endl; - PrintStreamDesc (&asbd); - -// get the new input unit's output ASBD - - propertySize = sizeof (asbd); - err = AudioUnitGetProperty (This->d_InputAU, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, 1, - &asbd, &propertySize); - CheckErrorAndThrow (err, "AudioUnitGetProperty StreamFormat", - "audio_osx_source::UnitListener"); - - std::cerr << "New Source Output Info:" << std::endl; - PrintStreamDesc (&asbd); - -// set the converter's input ASBD to this - - err = AudioConverterSetProperty (This->d_AudioConverter, - kAudioConverterCurrentInputStreamDescription, - propertySize, - &asbd); - CheckErrorAndThrow (err, "AudioConverterSetProperty " - "CurrentInputStreamDescription", - "audio_osx_source::UnitListener"); - -// reset the converter to tell it that the stream has changed - - err = AudioConverterReset (This->d_AudioConverter); - CheckErrorAndThrow (err, "AudioConverterReset", - "audio_osx_source::UnitListener"); - - return (err); -} -#endif diff --git a/gr-audio-osx/src/audio_osx_source.h b/gr-audio-osx/src/audio_osx_source.h deleted file mode 100644 index e8df47b16..000000000 --- a/gr-audio-osx/src/audio_osx_source.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_OSX_SOURCE_H -#define INCLUDED_AUDIO_OSX_SOURCE_H - -#include <gr_sync_block.h> -#include <string> -#include <AudioToolbox/AudioToolbox.h> -#include <AudioUnit/AudioUnit.h> -#include <circular_buffer.h> - -class audio_osx_source; -typedef boost::shared_ptr<audio_osx_source> audio_osx_source_sptr; - -audio_osx_source_sptr -audio_osx_make_source (int sample_rate = 44100, - const std::string device_name = "", - bool do_block = true, - int channel_config = -1, - int max_sample_count = -1); - -/*! - * \brief audio source using OSX - * - * Input signature is one or two streams of floats. - * Samples must be in the range [-1,1]. - */ - -class audio_osx_source : public gr_sync_block { - friend audio_osx_source_sptr - audio_osx_make_source (int sample_rate, - const std::string device_name, - bool do_block, - int channel_config, - int max_sample_count); - - Float64 d_deviceSampleRate, d_outputSampleRate; - int d_channel_config; - UInt32 d_inputBufferSizeFrames, d_inputBufferSizeBytes; - UInt32 d_outputBufferSizeFrames, d_outputBufferSizeBytes; - UInt32 d_deviceBufferSizeFrames, d_deviceBufferSizeBytes; - UInt32 d_leadSizeFrames, d_leadSizeBytes; - UInt32 d_trailSizeFrames, d_trailSizeBytes; - UInt32 d_extraBufferSizeFrames, d_extraBufferSizeBytes; - UInt32 d_queueSampleCount, d_max_sample_count; - UInt32 d_n_AvailableInputFrames, d_n_ActualInputFrames; - UInt32 d_n_user_channels, d_n_max_channels, d_n_deviceChannels; - bool d_do_block, d_passThrough, d_waiting_for_data; - gruel::mutex* d_internal; - gruel::condition_variable* d_cond_data; - circular_buffer<float>** d_buffers; - -// AudioUnits and Such - AudioUnit d_InputAU; - AudioBufferList* d_InputBuffer; - AudioBufferList* d_OutputBuffer; - AudioConverterRef d_AudioConverter; - -protected: - audio_osx_source (int sample_rate = 44100, - const std::string device_name = "", - bool do_block = true, - int channel_config = -1, - int max_sample_count = -1); - -public: - ~audio_osx_source (); - - bool start (); - bool stop (); - bool IsRunning (); - - bool check_topology (int ninputs, int noutputs); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - void SetDefaultInputDeviceAsCurrent (); - - void AllocAudioBufferList (AudioBufferList** t_ABL, - UInt32 n_channels, - UInt32 inputBufferSizeBytes); - - void FreeAudioBufferList (AudioBufferList** t_ABL); - - static OSStatus ConverterCallback (AudioConverterRef inAudioConverter, - UInt32* ioNumberDataPackets, - AudioBufferList* ioData, - AudioStreamPacketDescription** outASPD, - void* inUserData); - - static OSStatus AUInputCallback (void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList *ioData); -#if _OSX_DO_LISTENERS_ - static OSStatus UnitListener (void *inRefCon, - AudioUnit ci, - AudioUnitPropertyID inID, - AudioUnitScope inScope, - AudioUnitElement inElement); - - static OSStatus HardwareListener (AudioHardwarePropertyID inPropertyID, - void *inClientData); -#endif -}; - -#endif /* INCLUDED_AUDIO_OSX_SOURCE_H */ diff --git a/gr-audio-osx/src/circular_buffer.h b/gr-audio-osx/src/circular_buffer.h deleted file mode 100644 index 48758bf87..000000000 --- a/gr-audio-osx/src/circular_buffer.h +++ /dev/null @@ -1,315 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _CIRCULAR_BUFFER_H_ -#define _CIRCULAR_BUFFER_H_ - -#include <gruel/thread.h> -#include <iostream> -#include <stdexcept> - -#ifndef DO_DEBUG -#define DO_DEBUG 0 -#endif - -#if DO_DEBUG -#define DEBUG(X) do{X} while(0); -#else -#define DEBUG(X) do{} while(0); -#endif - -template <class T> -class circular_buffer -{ -private: -// the buffer to use - T* d_buffer; - -// the following are in Items (type T) - size_t d_bufLen_I, d_readNdx_I, d_writeNdx_I; - size_t d_n_avail_write_I, d_n_avail_read_I; - -// stuff to control access to class internals - gruel::mutex* d_internal; - gruel::condition_variable* d_readBlock; - gruel::condition_variable* d_writeBlock; - -// booleans to decide how to control reading, writing, and aborting - bool d_doWriteBlock, d_doFullRead, d_doAbort; - - void delete_mutex_cond () { - if (d_internal) { - delete d_internal; - d_internal = NULL; - } - if (d_readBlock) { - delete d_readBlock; - d_readBlock = NULL; - } - if (d_writeBlock) { - delete d_writeBlock; - d_writeBlock = NULL; - } - }; - -public: - circular_buffer (size_t bufLen_I, - bool doWriteBlock = true, bool doFullRead = false) { - if (bufLen_I == 0) - throw std::runtime_error ("circular_buffer(): " - "Number of items to buffer must be > 0.\n"); - d_bufLen_I = bufLen_I; - d_buffer = (T*) new T[d_bufLen_I]; - d_doWriteBlock = doWriteBlock; - d_doFullRead = doFullRead; - d_internal = NULL; - d_readBlock = d_writeBlock = NULL; - reset (); - DEBUG (std::cerr << "c_b(): buf len (items) = " << d_bufLen_ - << ", doWriteBlock = " << (d_doWriteBlock ? "true" : "false") - << ", doFullRead = " << (d_doFullRead ? "true" : "false") - << std::endl); - }; - - ~circular_buffer () { - delete_mutex_cond (); - delete [] d_buffer; - }; - - inline size_t n_avail_write_items () { - gruel::scoped_lock l (*d_internal); - size_t retVal = d_n_avail_write_I; - return (retVal); - }; - - inline size_t n_avail_read_items () { - gruel::scoped_lock l (*d_internal); - size_t retVal = d_n_avail_read_I; - return (retVal); - }; - - inline size_t buffer_length_items () {return (d_bufLen_I);}; - inline bool do_write_block () {return (d_doWriteBlock);}; - inline bool do_full_read () {return (d_doFullRead);}; - - void reset () { - d_doAbort = false; - bzero (d_buffer, d_bufLen_I * sizeof (T)); - d_readNdx_I = d_writeNdx_I = d_n_avail_read_I = 0; - d_n_avail_write_I = d_bufLen_I; - delete_mutex_cond (); - // create a mutex to handle contention of shared resources; - // any routine needed access to shared resources uses lock() - // before doing anything, then unlock() when finished. - d_internal = new gruel::mutex (); - // link the internal mutex to the read and write conditions; - // when wait() is called, the internal mutex will automatically - // be unlock()'ed. Upon return (from a notify_one() to the condition), - // the internal mutex will be lock()'ed. - d_readBlock = new gruel::condition_variable (); - d_writeBlock = new gruel::condition_variable (); - }; - -/* - * enqueue: add the given buffer of item-length to the queue, - * first-in-first-out (FIFO). - * - * inputs: - * buf: a pointer to the buffer holding the data - * - * bufLen_I: the buffer length in items (of the instantiated type) - * - * returns: - * -1: on overflow (write is not blocking, and data is being - * written faster than it is being read) - * 0: if nothing to do (0 length buffer) - * 1: if success - * 2: in the process of aborting, do doing nothing - * - * will throw runtime errors if inputs are improper: - * buffer pointer is NULL - * buffer length is larger than the instantiated buffer length - */ - - int enqueue (T* buf, size_t bufLen_I) { - DEBUG (std::cerr << "enqueue: buf = " << (void*) buf - << ", bufLen = " << bufLen_I - << ", #av_wr = " << d_n_avail_write_I - << ", #av_rd = " << d_n_avail_read_I << std::endl); - if (bufLen_I > d_bufLen_I) { - std::cerr << "ERROR: cannot add buffer longer (" - << bufLen_I << ") than instantiated length (" - << d_bufLen_I << ")." << std::endl; - throw std::runtime_error ("circular_buffer::enqueue()"); - } - - if (bufLen_I == 0) - return (0); - if (!buf) - throw std::runtime_error ("circular_buffer::enqueue(): " - "input buffer is NULL.\n"); - gruel::scoped_lock l (*d_internal); - if (d_doAbort) { - return (2); - } - // set the return value to 1: success; change if needed - int retval = 1; - if (bufLen_I > d_n_avail_write_I) { - if (d_doWriteBlock) { - while (bufLen_I > d_n_avail_write_I) { - DEBUG (std::cerr << "enqueue: #len > #a, waiting." << std::endl); - // wait; will automatically unlock() the internal mutex via - // the scoped lock - d_writeBlock->wait (l); - // and auto re-lock() it here. - if (d_doAbort) { - DEBUG (std::cerr << "enqueue: #len > #a, aborting." << std::endl); - return (2); - } - DEBUG (std::cerr << "enqueue: #len > #a, done waiting." << std::endl); - } - } else { - d_n_avail_read_I = d_bufLen_I - bufLen_I; - d_n_avail_write_I = bufLen_I; - DEBUG (std::cerr << "circular_buffer::enqueue: overflow" << std::endl); - retval = -1; - } - } - size_t n_now_I = d_bufLen_I - d_writeNdx_I, n_start_I = 0; - if (n_now_I > bufLen_I) - n_now_I = bufLen_I; - else if (n_now_I < bufLen_I) - n_start_I = bufLen_I - n_now_I; - bcopy (buf, &(d_buffer[d_writeNdx_I]), n_now_I * sizeof (T)); - if (n_start_I) { - bcopy (&(buf[n_now_I]), d_buffer, n_start_I * sizeof (T)); - d_writeNdx_I = n_start_I; - } else - d_writeNdx_I += n_now_I; - d_n_avail_read_I += bufLen_I; - d_n_avail_write_I -= bufLen_I; - d_readBlock->notify_one (); - return (retval); - }; - -/* - * dequeue: removes from the queue the number of items requested, or - * available, into the given buffer on a FIFO basis. - * - * inputs: - * buf: a pointer to the buffer into which to copy the data - * - * bufLen_I: pointer to the number of items to remove in items - * (of the instantiated type) - * - * returns: - * 0: if nothing to do (0 length buffer) - * 1: if success - * 2: in the process of aborting, do doing nothing - * - * will throw runtime errors if inputs are improper: - * buffer pointer is NULL - * buffer length pointer is NULL - * buffer length is larger than the instantiated buffer length - */ - - int dequeue (T* buf, size_t* bufLen_I) { - DEBUG (std::cerr << "dequeue: buf = " << ((void*) buf) - << ", *bufLen = " << (*bufLen_I) - << ", #av_wr = " << d_n_avail_write_I - << ", #av_rd = " << d_n_avail_read_I << std::endl); - if (!bufLen_I) - throw std::runtime_error ("circular_buffer::dequeue(): " - "input bufLen pointer is NULL.\n"); - if (!buf) - throw std::runtime_error ("circular_buffer::dequeue(): " - "input buffer pointer is NULL.\n"); - size_t l_bufLen_I = *bufLen_I; - if (l_bufLen_I == 0) - return (0); - if (l_bufLen_I > d_bufLen_I) { - std::cerr << "ERROR: cannot remove buffer longer (" - << l_bufLen_I << ") than instantiated length (" - << d_bufLen_I << ")." << std::endl; - throw std::runtime_error ("circular_buffer::dequeue()"); - } - - gruel::scoped_lock l (*d_internal); - if (d_doAbort) { - return (2); - } - if (d_doFullRead) { - while (d_n_avail_read_I < l_bufLen_I) { - DEBUG (std::cerr << "dequeue: #a < #len, waiting." << std::endl); - // wait; will automatically unlock() the internal mutex via - // the scoped lock - d_readBlock->wait (l); - // and re-lock() it here. - if (d_doAbort) { - DEBUG (std::cerr << "dequeue: #a < #len, aborting." << std::endl); - return (2); - } - DEBUG (std::cerr << "dequeue: #a < #len, done waiting." << std::endl); - } - } else { - while (d_n_avail_read_I == 0) { - DEBUG (std::cerr << "dequeue: #a == 0, waiting." << std::endl); - // wait; will automatically unlock() the internal mutex via - // the scoped lock - d_readBlock->wait (l); - // and re-lock() it here. - if (d_doAbort) { - DEBUG (std::cerr << "dequeue: #a == 0, aborting." << std::endl); - return (2); - } - DEBUG (std::cerr << "dequeue: #a == 0, done waiting." << std::endl); - } - } - if (l_bufLen_I > d_n_avail_read_I) - l_bufLen_I = d_n_avail_read_I; - size_t n_now_I = d_bufLen_I - d_readNdx_I, n_start_I = 0; - if (n_now_I > l_bufLen_I) - n_now_I = l_bufLen_I; - else if (n_now_I < l_bufLen_I) - n_start_I = l_bufLen_I - n_now_I; - bcopy (&(d_buffer[d_readNdx_I]), buf, n_now_I * sizeof (T)); - if (n_start_I) { - bcopy (d_buffer, &(buf[n_now_I]), n_start_I * sizeof (T)); - d_readNdx_I = n_start_I; - } else - d_readNdx_I += n_now_I; - *bufLen_I = l_bufLen_I; - d_n_avail_read_I -= l_bufLen_I; - d_n_avail_write_I += l_bufLen_I; - d_writeBlock->notify_one (); - return (1); - }; - - void abort () { - gruel::scoped_lock l (*d_internal); - d_doAbort = true; - d_writeBlock->notify_one (); - d_readBlock->notify_one (); - }; -}; - -#endif /* _CIRCULAR_BUFFER_H_ */ diff --git a/gr-audio-osx/src/qa_osx.py b/gr-audio-osx/src/qa_osx.py deleted file mode 100755 index 385aa0269..000000000 --- a/gr-audio-osx/src/qa_osx.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio. -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import audio_osx - -class qa_osx (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have OSX drivers, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.main () diff --git a/gr-audio-osx/src/run_tests.in b/gr-audio-osx/src/run_tests.in deleted file mode 100644 index d88c275e0..000000000 --- a/gr-audio-osx/src/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-audio-osx \ - @abs_top_builddir@/gr-audio-osx \ - @srcdir@ diff --git a/gr-audio-osx/src/test_audio_loop.py b/gr-audio-osx/src/test_audio_loop.py deleted file mode 100755 index 662631dfb..000000000 --- a/gr-audio-osx/src/test_audio_loop.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio. -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr -from gnuradio import audio -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -class my_graph(gr.top_block): - - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-O", "--audio-output", - type="string", - default="", - help="audio output device name. E.g., hw:0,0 or /dev/dsp") - parser.add_option("-I", "--audio-input", - type="string", - default="", - help="audio input device name. E.g., hw:0,0 or /dev/dsp") - parser.add_option("-r", "--sample-rate", - type="eng_float", - default=48000, - help="set sample rate to RATE (48000)") - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - sample_rate = int(options.sample_rate) - src = audio.source (sample_rate, options.audio_output) - dst = audio.sink (sample_rate, options.audio_output) - - max_chan = max (src.output_signature().max_streams(), - dst.output_signature().max_streams()) - - for i in range (max_chan): - self.connect ((src, i), (dst, i)) - -if __name__ == '__main__': - try: - my_graph().run() - except KeyboardInterrupt: - pass diff --git a/gr-audio-portaudio/.gitignore b/gr-audio-portaudio/.gitignore deleted file mode 100644 index 53edad32f..000000000 --- a/gr-audio-portaudio/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/config.cache -/config.h -/config.h.in -/config.log -/config.status -/configure -/depcomp -/install-sh -/libtool -/ltmain.sh -/make.log -/missing -/missing -/mkinstalldirs -/py-compile -/stamp-h -/stamp-h.in -/stamp-h1 -/stamp-h1.in -/stamp-h2.in diff --git a/gr-audio-portaudio/Makefile.am b/gr-audio-portaudio/Makefile.am deleted file mode 100644 index 198d89f87..000000000 --- a/gr-audio-portaudio/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2006,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -dist_pkgconfig_DATA = gnuradio-audio-portaudio.pc - -etcdir = $(gr_prefsdir) -dist_etc_DATA = gr-audio-portaudio.conf diff --git a/gr-audio-portaudio/README b/gr-audio-portaudio/README deleted file mode 100644 index bd6fac643..000000000 --- a/gr-audio-portaudio/README +++ /dev/null @@ -1,99 +0,0 @@ -The instructions below are now obsolete. Please see: - -http://gnuradio.org/trac/wiki/PortAudioInstall - -====== -OBSOLETED - -These instructions are intended for Linux. On other systems you will have to -construct something compatible to build gr-audio-portaudio. - -In order to use portaudio with gnuradio you will need to download and install -a late version of portaudio. Please cd to a directory where the cvs command -below will be allowed to build the portaudio directory tree. - -cvs -d:pserver:anonymous@www.portaudio.com:/home/cvs co -r v19-devel portaudio - -This will make a directory portaudio unless you already have one. It will -check out the Portaudio API version 2 release 1.9. - -In the directory where this README is found, there is a patch file. Hopefully -this patch will not be needed for long. Portaudio is working with us to use -auto*, libtool, etc. The patch is autoconfiscate.patch. - -cd to the portaudio directory and run - -patch -p0 <autoconfiscate.patch - -this will modify the portaudio source tree to use standard tools and prepare -it for use with gnuradio. Now run - -chmod u+x bootstrap - -you may need to edit bootstrap and remove the 2.50 at the end of some of the -commands (on SUSE 10.0 for example). - -./bootstrap - -./configure --help - - -will reveal the options for configure that are available to you. If you do not -understand the options or wish to accept the defaults please just run - -./configure - -If you do not want the includes and libraries install in /usr/local (standard) -then enter the prefix arguments to ./configure. This document will assume you -are doing the standard installation and that will be into /usr/local. - -On Linux if you have the jack tool available from - -http://jackit.sourceforge.net - -the portaudio configure will enable the library to talk to jack. - -Now you are ready to make the portaudio library. - -make; sudo make install;sudo ldconfig (possibly /sbin/ldconfig). - -will make the code and install it into the prefix (/usr/local) selected and -will cache the configuration information for other programs to use for their -configuration options. - -Now you are ready to install gr-audio-portaudio. In the gr-build directory -you may run - -cvs co gr-audio-portaudio - -cd gr-audio-portaudio -../buildit - -will configure, make, and install the portaudio sink and source. - -In gnuradio-examples/python/audio please test by running - -./mono_tone_portaudio.py - - -If this runs you are likely in business but this chooses the default device -(typically /dev/dsp which is being run by alsa under oss emulation and on a -Mac it will choose coreaudio). - -./mono_tone_portaudio.py -O hw:0,0 - -chooses the default alsa device. - -./mono_tone_portaudio.py -O /dev/dsp - -will force the use of OSS and the default oss device. To run with jack, you -will probably enter the following command: - -./mono_tone_portaudio.py -O alsa_pcm - - -In the portaudio directory, you may list the devices visible to portaudio by -searching for and running the command - -pa_devs - diff --git a/gr-audio-portaudio/autoconfiscate.patch b/gr-audio-portaudio/autoconfiscate.patch deleted file mode 100755 index fd7b9c370..000000000 --- a/gr-audio-portaudio/autoconfiscate.patch +++ /dev/null @@ -1,1299 +0,0 @@ -Index: portaudio-2.0.pc.in -=================================================================== -RCS file: /home/cvs/portaudio/Attic/portaudio-2.0.pc.in,v -retrieving revision 1.1.2.1 -diff -u -b -B -w -p -r1.1.2.1 portaudio-2.0.pc.in ---- portaudio-2.0.pc.in 19 Mar 2006 13:02:36 -0000 1.1.2.1 -+++ portaudio-2.0.pc.in 19 Mar 2006 22:26:01 -0000 -@@ -9,4 +9,4 @@ Requires: - Version: 19 - - Libs: -L${libdir} -lportaudio @LIBS@ --Cflags: -I${includedir} @THREAD_CFLAGS@ -+Cflags: -I${includedir} @PTHREAD_CFLAGS@ -Index: pa_asio/iasiothiscallresolver.cpp -=================================================================== -RCS file: /home/cvs/portaudio/pa_asio/Attic/iasiothiscallresolver.cpp,v -retrieving revision 1.1.2.4 -diff -u -b -B -w -p -r1.1.2.4 iasiothiscallresolver.cpp ---- pa_asio/iasiothiscallresolver.cpp 10 Jul 2004 03:27:41 -0000 1.1.2.4 -+++ pa_asio/iasiothiscallresolver.cpp 19 Mar 2006 22:26:03 -0000 -@@ -152,6 +152,7 @@ - recent versions of the gcc assembler. - */ - -+#include <config.h> - - // We only need IASIOThiscallResolver at all if we are on Win32. For other - // platforms we simply bypass the IASIOThiscallResolver definition to allow us -Index: pa_asio/pa_asio.cpp -=================================================================== -RCS file: /home/cvs/portaudio/pa_asio/pa_asio.cpp,v -retrieving revision 1.7.2.68 -diff -u -b -B -w -p -r1.7.2.68 pa_asio.cpp ---- pa_asio/pa_asio.cpp 5 Dec 2005 04:55:28 -0000 1.7.2.68 -+++ pa_asio/pa_asio.cpp 19 Mar 2006 22:26:14 -0000 -@@ -106,7 +106,7 @@ - must be closed). - */ - -- -+#include <config.h> - - #include <stdio.h> - #include <assert.h> -Index: pa_common/pa_allocation.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_allocation.c,v -retrieving revision 1.1.2.6 -diff -u -b -B -w -p -r1.1.2.6 pa_allocation.c ---- pa_common/pa_allocation.c 20 Dec 2004 12:07:51 -0000 1.1.2.6 -+++ pa_common/pa_allocation.c 19 Mar 2006 22:26:15 -0000 -@@ -35,6 +35,8 @@ - */ - - -+#include <config.h> -+ - #include "pa_allocation.h" - #include "pa_util.h" - -Index: pa_common/pa_converters.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_converters.c,v -retrieving revision 1.1.2.27 -diff -u -b -B -w -p -r1.1.2.27 pa_converters.c ---- pa_common/pa_converters.c 2 Nov 2005 12:14:07 -0000 1.1.2.27 -+++ pa_common/pa_converters.c 19 Mar 2006 22:26:23 -0000 -@@ -49,6 +49,8 @@ - */ - - -+#include <config.h> -+ - #include "pa_converters.h" - #include "pa_dither.h" - #include "pa_endianness.h" -Index: pa_common/pa_cpuload.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_cpuload.c,v -retrieving revision 1.1.2.14 -diff -u -b -B -w -p -r1.1.2.14 pa_cpuload.c ---- pa_common/pa_cpuload.c 8 Jan 2004 22:01:12 -0000 1.1.2.14 -+++ pa_common/pa_cpuload.c 19 Mar 2006 22:26:24 -0000 -@@ -41,6 +41,8 @@ - */ - - -+#include <config.h> -+ - #include "pa_cpuload.h" - - #include <assert.h> -Index: pa_common/pa_dither.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_dither.c,v -retrieving revision 1.1.2.6 -diff -u -b -B -w -p -r1.1.2.6 pa_dither.c ---- pa_common/pa_dither.c 28 May 2005 22:49:02 -0000 1.1.2.6 -+++ pa_common/pa_dither.c 19 Mar 2006 22:26:24 -0000 -@@ -34,6 +34,8 @@ - */ - - -+#include <config.h> -+ - #include "pa_dither.h" - #include "pa_types.h" - -Index: pa_common/pa_front.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_front.c,v -retrieving revision 1.1.2.52 -diff -u -b -B -w -p -r1.1.2.52 pa_front.c ---- pa_common/pa_front.c 7 Dec 2005 20:10:34 -0000 1.1.2.52 -+++ pa_common/pa_front.c 19 Mar 2006 22:26:30 -0000 -@@ -89,6 +89,8 @@ enquire about status on the PortAudio ma - */ - - -+#include <config.h> -+ - #include <stdio.h> - #include <stdarg.h> - #include <memory.h> -Index: pa_common/pa_process.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_process.c,v -retrieving revision 1.1.2.51 -diff -u -b -B -w -p -r1.1.2.51 pa_process.c ---- pa_common/pa_process.c 27 Oct 2005 23:28:48 -0000 1.1.2.51 -+++ pa_common/pa_process.c 19 Mar 2006 22:26:35 -0000 -@@ -72,6 +72,8 @@ - */ - - -+#include <config.h> -+ - #include <assert.h> - #include <string.h> /* memset() */ - -Index: pa_common/pa_skeleton.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_skeleton.c,v -retrieving revision 1.1.2.39 -diff -u -b -B -w -p -r1.1.2.39 pa_skeleton.c ---- pa_common/pa_skeleton.c 26 Nov 2003 14:56:09 -0000 1.1.2.39 -+++ pa_common/pa_skeleton.c 19 Mar 2006 22:26:38 -0000 -@@ -40,6 +40,8 @@ - */ - - -+#include <config.h> -+ - #include <string.h> /* strlen() */ - - #include "pa_util.h" -Index: pa_common/pa_stream.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/Attic/pa_stream.c,v -retrieving revision 1.1.2.12 -diff -u -b -B -w -p -r1.1.2.12 pa_stream.c ---- pa_common/pa_stream.c 20 Sep 2003 21:31:00 -0000 1.1.2.12 -+++ pa_common/pa_stream.c 19 Mar 2006 22:26:39 -0000 -@@ -36,6 +36,8 @@ - */ - - -+#include <config.h> -+ - #include "pa_stream.h" - - -Index: pa_common/pa_trace.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_common/pa_trace.c,v -retrieving revision 1.1.1.1.2.4 -diff -u -b -B -w -p -r1.1.1.1.2.4 pa_trace.c ---- pa_common/pa_trace.c 2 Nov 2005 12:06:44 -0000 1.1.1.1.2.4 -+++ pa_common/pa_trace.c 19 Mar 2006 22:26:39 -0000 -@@ -35,6 +35,8 @@ - */ - - -+#include <config.h> -+ - #include <stdio.h> - #include <stdlib.h> - #include <string.h> -Index: pa_jack/pa_jack.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_jack/Attic/pa_jack.c,v -retrieving revision 1.1.2.20 -diff -u -b -B -w -p -r1.1.2.20 pa_jack.c ---- pa_jack/pa_jack.c 2 Oct 2005 22:02:26 -0000 1.1.2.20 -+++ pa_jack/pa_jack.c 19 Mar 2006 22:26:46 -0000 -@@ -35,6 +35,8 @@ - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -+#include <config.h> -+ - #include <string.h> - #include <regex.h> - #include <stdlib.h> -@@ -56,7 +58,7 @@ - #include "pa_process.h" - #include "pa_allocation.h" - #include "pa_cpuload.h" --#include "../pablio/ringbuffer.c" -+#include "pablio/ringbuffer.c" - - static int aErr_; - static PaError paErr_; /* For use with ENSURE_PA */ -Index: pa_linux_alsa/pa_linux_alsa.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_linux_alsa/Attic/pa_linux_alsa.c,v -retrieving revision 1.1.2.90 -diff -u -b -B -w -p -r1.1.2.90 pa_linux_alsa.c ---- pa_linux_alsa/pa_linux_alsa.c 19 Mar 2006 12:28:44 -0000 1.1.2.90 -+++ pa_linux_alsa/pa_linux_alsa.c 19 Mar 2006 22:27:00 -0000 -@@ -34,6 +34,8 @@ - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -+#include <config.h> -+ - #define ALSA_PCM_NEW_HW_PARAMS_API - #define ALSA_PCM_NEW_SW_PARAMS_API - #include <alsa/asoundlib.h> -Index: pa_mac/pa_mac_hostapis.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_mac/Attic/pa_mac_hostapis.c,v -retrieving revision 1.1.2.1 -diff -u -b -B -w -p -r1.1.2.1 pa_mac_hostapis.c ---- pa_mac/pa_mac_hostapis.c 27 May 2004 22:39:58 -0000 1.1.2.1 -+++ pa_mac/pa_mac_hostapis.c 19 Mar 2006 22:27:00 -0000 -@@ -33,6 +33,7 @@ - Mac OS host API initialization function table. - */ - -+#include <config.h> - - #include "pa_hostapi.h" - -Index: pa_mac_core/pa_mac_core.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_mac_core/pa_mac_core.c,v -retrieving revision 1.8.2.11 -diff -u -b -B -w -p -r1.8.2.11 pa_mac_core.c ---- pa_mac_core/pa_mac_core.c 27 Feb 2006 14:25:50 -0000 1.8.2.11 -+++ pa_mac_core/pa_mac_core.c 19 Mar 2006 22:27:08 -0000 -@@ -45,6 +45,8 @@ - @brief AUHAL implementation of PortAudio - */ - -+#include <config.h> -+ - #include <string.h> /* strlen(), memcmp() etc. */ - - #include <AudioUnit/AudioUnit.h> -Index: pa_mac_core/pa_mac_core_old.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_mac_core/Attic/pa_mac_core_old.c,v -retrieving revision 1.1.2.1 -diff -u -b -B -w -p -r1.1.2.1 pa_mac_core_old.c ---- pa_mac_core/pa_mac_core_old.c 24 Dec 2005 01:22:52 -0000 1.1.2.1 -+++ pa_mac_core/pa_mac_core_old.c 19 Mar 2006 22:27:14 -0000 -@@ -34,6 +34,8 @@ - * - */ - -+#include <config.h> -+ - #include <CoreAudio/CoreAudio.h> - #include <AudioToolbox/AudioToolbox.h> - #include <stdio.h> -Index: pa_mac_core/pa_mac_core_utilities.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_mac_core/Attic/pa_mac_core_utilities.c,v -retrieving revision 1.1.2.2 -diff -u -b -B -w -p -r1.1.2.2 pa_mac_core_utilities.c ---- pa_mac_core/pa_mac_core_utilities.c 9 Dec 2005 19:43:14 -0000 1.1.2.2 -+++ pa_mac_core/pa_mac_core_utilities.c 19 Mar 2006 22:27:14 -0000 -@@ -10,6 +10,8 @@ - * by Bjorn Roche. - */ - -+#include <config.h> -+ - /* - * Translates MacOS generated errors into PaErrors - */ -Index: pa_mac_sm/pa_mac_sm.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_mac_sm/Attic/pa_mac_sm.c,v -retrieving revision 1.1.2.1 -diff -u -b -B -w -p -r1.1.2.1 pa_mac_sm.c ---- pa_mac_sm/pa_mac_sm.c 7 Jun 2002 21:20:48 -0000 1.1.2.1 -+++ pa_mac_sm/pa_mac_sm.c 19 Mar 2006 22:27:21 -0000 -@@ -76,6 +76,8 @@ O- Add support for native sample data fo - O- Review buffer sizing. Should it be based on result of siDeviceBufferInfo query? - O- Determine default devices somehow. - */ -+#include <config.h> -+ - #include <stdio.h> - #include <stdlib.h> - #include <string.h> -Index: pa_sgi/pa_sgi.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_sgi/pa_sgi.c,v -retrieving revision 1.2.2.20 -diff -u -b -B -w -p -r1.2.2.20 pa_sgi.c ---- pa_sgi/pa_sgi.c 3 Jan 2004 19:20:09 -0000 1.2.2.20 -+++ pa_sgi/pa_sgi.c 19 Mar 2006 22:27:27 -0000 -@@ -123,6 +123,8 @@ - a outputs stereo. One can observe this in SGI's 'Audio Queue Monitor'. - */ - -+#include <config.h> -+ - #include <string.h> /* For strlen() but also for strerror()! */ - #include <stdio.h> /* printf() */ - #include <math.h> /* fabs() */ -Index: pa_unix/pa_unix_hostapis.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_unix/Attic/pa_unix_hostapis.c,v -retrieving revision 1.1.2.5 -diff -u -b -B -w -p -r1.1.2.5 pa_unix_hostapis.c ---- pa_unix/pa_unix_hostapis.c 2 Oct 2003 12:35:46 -0000 1.1.2.5 -+++ pa_unix/pa_unix_hostapis.c 19 Mar 2006 22:27:28 -0000 -@@ -30,6 +30,8 @@ - */ - - -+#include <config.h> -+ - #include "pa_hostapi.h" - - PaError PaJack_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index ); -Index: pa_unix/pa_unix_util.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_unix/Attic/pa_unix_util.c,v -retrieving revision 1.1.2.8 -diff -u -b -B -w -p -r1.1.2.8 pa_unix_util.c ---- pa_unix/pa_unix_util.c 20 Nov 2005 13:46:13 -0000 1.1.2.8 -+++ pa_unix/pa_unix_util.c 19 Mar 2006 22:27:28 -0000 -@@ -31,6 +31,8 @@ - */ - - -+#include <config.h> -+ - #include <pthread.h> - #include <unistd.h> - #include <stdlib.h> -Index: pa_unix_oss/pa_unix_oss.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_unix_oss/pa_unix_oss.c,v -retrieving revision 1.6.2.27 -diff -u -b -B -w -p -r1.6.2.27 pa_unix_oss.c ---- pa_unix_oss/pa_unix_oss.c 21 Feb 2006 19:13:56 -0000 1.6.2.27 -+++ pa_unix_oss/pa_unix_oss.c 19 Mar 2006 22:27:35 -0000 -@@ -35,6 +35,8 @@ - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -+#include <config.h> -+ - #include <stdio.h> - #include <string.h> - #include <math.h> -@@ -42,7 +44,6 @@ - #include <sys/ioctl.h> - #include <unistd.h> - #include <pthread.h> --#include <alloca.h> - #include <malloc.h> - #include <assert.h> - #include <errno.h> -@@ -52,14 +53,21 @@ - #include <limits.h> - #include <semaphore.h> - --#ifdef __FreeBSD__ -+#ifdef HAVE_SYS_SOUNDCARD_H - # include <sys/soundcard.h> -+#elif HAVE_LINUX_SOUNDCARD_H -+# include <linux/soundcard.h> -+#elif HAVE_SOUNDCARD_H -+# include <soundcard.h> -+#else -+# include <machine/soundcard.h> /* JH20010905 */ -+#endif -+ -+#ifdef __FreeBSD__ - # define DEVICE_NAME_BASE "/dev/dsp" - #elif defined __linux__ --# include <linux/soundcard.h> - # define DEVICE_NAME_BASE "/dev/dsp" - #else --# include <machine/soundcard.h> /* JH20010905 */ - # define DEVICE_NAME_BASE "/dev/audio" - #endif - -@@ -1913,7 +1921,12 @@ static signed long GetStreamWriteAvailab - PaOssStream *stream = (PaOssStream*)s; - int delay = 0; - -+/* -+ * FIXME: SNDCTL_DSP_GETODELAY does not exist on NetBSD -+ */ -+#ifdef SNDCTL_DSP_GETODELAY - if( ioctl( stream->playback->fd, SNDCTL_DSP_GETODELAY, &delay ) < 0 ) -+#endif - return paUnanticipatedHostError; - - return (PaOssStreamComponent_BufferSize( stream->playback ) - delay) / PaOssStreamComponent_FrameSize( stream->playback ); -Index: pa_unix_oss/recplay.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_unix_oss/recplay.c,v -retrieving revision 1.1.1.1 -diff -u -b -B -w -p -r1.1.1.1 recplay.c ---- pa_unix_oss/recplay.c 22 Jan 2002 00:52:44 -0000 1.1.1.1 -+++ pa_unix_oss/recplay.c 19 Mar 2006 22:27:35 -0000 -@@ -4,6 +4,8 @@ - * Minimal record and playback test. - * - */ -+#include <config.h> -+ - #include <stdio.h> - #include <unistd.h> - #include <stdlib.h> -Index: pa_win/pa_win_hostapis.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_win/Attic/pa_win_hostapis.c,v -retrieving revision 1.1.2.10 -diff -u -b -B -w -p -r1.1.2.10 pa_win_hostapis.c ---- pa_win/pa_win_hostapis.c 8 Sep 2004 17:31:37 -0000 1.1.2.10 -+++ pa_win/pa_win_hostapis.c 19 Mar 2006 22:27:36 -0000 -@@ -36,6 +36,7 @@ - the Unix version does, we should consider being consistent. - */ - -+#include <config.h> - - #include "pa_hostapi.h" - -Index: pa_win/pa_win_util.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_win/Attic/pa_win_util.c,v -retrieving revision 1.1.2.7 -diff -u -b -B -w -p -r1.1.2.7 pa_win_util.c ---- pa_win/pa_win_util.c 15 Sep 2003 18:30:26 -0000 1.1.2.7 -+++ pa_win/pa_win_util.c 19 Mar 2006 22:27:36 -0000 -@@ -37,6 +37,9 @@ - bug. (see msdn kb Q274323). - */ - -+#include <config.h> -+ -+ - #include <windows.h> - #include <mmsystem.h> /* for timeGetTime() */ - -Index: pa_win/pa_x86_plain_converters.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_win/Attic/pa_x86_plain_converters.c,v -retrieving revision 1.1.2.2 -diff -u -b -B -w -p -r1.1.2.2 pa_x86_plain_converters.c ---- pa_win/pa_x86_plain_converters.c 28 Feb 2003 01:49:59 -0000 1.1.2.2 -+++ pa_win/pa_x86_plain_converters.c 19 Mar 2006 22:27:40 -0000 -@@ -1,3 +1,5 @@ -+#include <config.h> -+ - #include "pa_x86_plain_converters.h" - - #include "pa_converters.h" -Index: pa_win_ds/dsound_wrapper.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_win_ds/dsound_wrapper.c,v -retrieving revision 1.1.1.1.2.11 -diff -u -b -B -w -p -r1.1.1.1.2.11 dsound_wrapper.c ---- pa_win_ds/dsound_wrapper.c 7 Sep 2003 13:04:53 -0000 1.1.1.1.2.11 -+++ pa_win_ds/dsound_wrapper.c 19 Mar 2006 22:27:43 -0000 -@@ -33,6 +33,8 @@ - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -+#include <config.h> -+ - #include <stdio.h> - #include <stdlib.h> - #include <math.h> -Index: pa_win_ds/pa_win_ds.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_win_ds/Attic/pa_win_ds.c,v -retrieving revision 1.1.2.51 -diff -u -b -B -w -p -r1.1.2.51 pa_win_ds.c ---- pa_win_ds/pa_win_ds.c 26 Jan 2006 01:13:18 -0000 1.1.2.51 -+++ pa_win_ds/pa_win_ds.c 19 Mar 2006 22:27:49 -0000 -@@ -58,6 +58,8 @@ - O- fix "patest_stop.c" - */ - -+#include <config.h> -+ - #include <stdio.h> - #include <string.h> /* strlen() */ - -Index: pa_win_wdmks/pa_win_wdmks.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_win_wdmks/Attic/pa_win_wdmks.c,v -retrieving revision 1.1.2.4 -diff -u -b -B -w -p -r1.1.2.4 pa_win_wdmks.c ---- pa_win_wdmks/pa_win_wdmks.c 19 Nov 2005 10:14:01 -0000 1.1.2.4 -+++ pa_win_wdmks/pa_win_wdmks.c 19 Mar 2006 22:28:00 -0000 -@@ -42,6 +42,8 @@ - of a device for the duration of active stream using those devices - */ - -+#include <config.h> -+ - #include <stdio.h> - - /* Debugging/tracing support */ -Index: pa_win_wmme/pa_win_wmme.c -=================================================================== -RCS file: /home/cvs/portaudio/pa_win_wmme/pa_win_wmme.c,v -retrieving revision 1.6.2.88 -diff -u -b -B -w -p -r1.6.2.88 pa_win_wmme.c ---- pa_win_wmme/pa_win_wmme.c 16 Feb 2006 01:56:45 -0000 1.6.2.88 -+++ pa_win_wmme/pa_win_wmme.c 19 Mar 2006 22:28:14 -0000 -@@ -100,6 +100,8 @@ Non-critical stuff for the future: - Events (when necessary) inside the ReadStream() and WriteStream() functions. - */ - -+#include <config.h> -+ - #include <stdio.h> - #include <stdlib.h> - #include <math.h> ---- /dev/null 2006-03-10 00:02:48.821312048 +0100 -+++ Makefile.am 2006-03-19 22:49:42.000000000 +0100 -@@ -0,0 +1,215 @@ -+# -+# PortAudio V19 Makefile.am -+# -+# Stéphane Fillod -+# -+ -+INCLUDES = -I$(top_srcdir)/pa_common -+ -+COMMON_SRC = \ -+ pa_common/pa_allocation.c \ -+ pa_common/pa_converters.c \ -+ pa_common/pa_cpuload.c \ -+ pa_common/pa_dither.c \ -+ pa_common/pa_front.c \ -+ pa_common/pa_process.c \ -+ pa_common/pa_skeleton.c \ -+ pa_common/pa_stream.c \ -+ pa_common/pa_trace.c -+ -+libportaudio_coreaudio_la_SOURCES = \ -+ pa_mac/pa_mac_hostapis.c \ -+ pa_mac_core/pa_mac_core.c -+ -+libportaudio_mac_asio_la_SOURCES = \ -+ pa_asio/iasiothiscallresolver.cpp -+libportaudio_mac_asio_la_LIBADD = @ASIO_OBJS@ -+ -+libportaudio_dsound_la_SOURCES = \ -+ pa_win_ds/pa_win_ds.c \ -+ pa_win_ds/dsound_wrapper.c \ -+ pa_win/pa_win_hostapis.c \ -+ pa_win/pa_win_util.c -+ -+libportaudio_win_asio_la_SOURCES = \ -+ pa_asio/pa_asio.cpp \ -+ pa_win/pa_win_hostapis.c \ -+ pa_win/pa_win_util.c \ -+ pa_asio/iasiothiscallresolver.cpp -+libportaudio_win_asio_la_LIBADD = @ASIO_OBJS@ -+ -+libportaudio_wdmks_la_SOURCES = \ -+ pa_win_wdmks/pa_win_wdmks.c \ -+ pa_win/pa_win_hostapis.c \ -+ pa_win/pa_win_util.c -+ -+libportaudio_wmme_la_SOURCES = \ -+ pa_win_wmme/pa_win_wmme.c \ -+ pa_win/pa_win_hostapis.c \ -+ pa_win/pa_win_util.c -+ -+libportaudio_sgi_la_SOURCES = \ -+ pa_sgi/pa_sgi.c -+ -+libportaudio_alsa_la_SOURCES = \ -+ pa_linux_alsa/pa_linux_alsa.c -+ -+libportaudio_jack_la_SOURCES = \ -+ pa_jack/pa_jack.c -+ -+libportaudio_oss_la_SOURCES = \ -+ pa_unix_oss/pa_unix_oss.c -+ -+libportaudio_unix_la_SOURCES = \ -+ pa_unix/pa_unix_hostapis.c \ -+ pa_unix/pa_unix_util.c -+ -+EXTRA_LTLIBRARIES = \ -+ libportaudio-coreaudio.la \ -+ libportaudio-mac-asio.la \ -+ libportaudio-dsound.la \ -+ libportaudio-win-asio.la \ -+ libportaudio-wdmks.la \ -+ libportaudio-wmme.la \ -+ libportaudio-sgi.la \ -+ libportaudio-alsa.la \ -+ libportaudio-jack.la \ -+ libportaudio-oss.la \ -+ libportaudio-unix.la -+ -+noinst_LTLIBRARIES = @PA_LIBADD@ -+lib_LTLIBRARIES = libportaudio.la -+ -+ -+libportaudio_la_SOURCES = \ -+ $(COMMON_SRC) -+ -+# -no-undefined is required by Win32 and MacOSX, should be harmless otherwise -+libportaudio_la_LDFLAGS = $(WINLDFLAGS) -no-undefined -version-info @PA_ABI@:@PA_REV@:@PA_AGE@ -+libportaudio_la_CFLAGS = $(AM_CFLAGS) -+libportaudio_la_LIBADD = @PA_LIBADD@ -lm -+libportaudio_la_DEPENDENCIES = @PA_LIBADD@ -+ -+ -+noinst_HEADERS = \ -+ pa_asio/iasiothiscallresolver.h \ -+ pa_asio/pa_asio.h \ -+ pa_beos/PlaybackNode.h \ -+ pablio/pablio.h \ -+ pablio/ringbuffer.h \ -+ pa_common/pa_allocation.h \ -+ pa_common/pa_converters.h \ -+ pa_common/pa_cpuload.h \ -+ pa_common/pa_dither.h \ -+ pa_common/pa_endianness.h \ -+ pa_common/pa_hostapi.h \ -+ pa_common/pa_process.h \ -+ pa_common/pa_stream.h \ -+ pa_common/pa_trace.h \ -+ pa_common/pa_types.h \ -+ pa_common/pa_util.h \ -+ pa_dll_switch/PaDllEntry.h \ -+ pa_dll_switch/portaudio.h \ -+ pa_linux_alsa/pa_linux_alsa.h \ -+ pa_mac_core/pa_mac_core.h \ -+ pa_unix/pa_unix_util.h \ -+ pa_win_ds/dsound_wrapper.h \ -+ pa_win/pa_x86_plain_converters.h \ -+ pa_win_wmme/pa_win_wmme.h -+ -+include_HEADERS = \ -+ pa_common/portaudio.h -+ -+ -+TESTS = \ -+ pa_tests/paqa_errs \ -+ pa_tests/patest1 \ -+ pa_tests/patest_buffer \ -+ pa_tests/patest_callbackstop \ -+ pa_tests/patest_clip \ -+ pa_tests/patest_dither \ -+ pa_tests/patest_hang \ -+ pa_tests/patest_in_overflow \ -+ pa_tests/patest_latency \ -+ pa_tests/patest_leftright \ -+ pa_tests/patest_longsine \ -+ pa_tests/patest_many \ -+ pa_tests/patest_maxsines \ -+ pa_tests/patest_multi_sine \ -+ pa_tests/patest_out_underflow \ -+ pa_tests/patest_pink \ -+ pa_tests/patest_prime \ -+ pa_tests/patest_read_record \ -+ pa_tests/patest_record \ -+ pa_tests/patest_ringmix \ -+ pa_tests/patest_saw \ -+ pa_tests/patest_sine8 \ -+ pa_tests/patest_sine \ -+ pa_tests/patest_sine_formats \ -+ pa_tests/patest_sine_time \ -+ pa_tests/patest_start_stop \ -+ pa_tests/patest_stop \ -+ pa_tests/patest_sync \ -+ pa_tests/patest_toomanysines \ -+ pa_tests/patest_underflow \ -+ pa_tests/patest_wire \ -+ pa_tests/patest_write_sine \ -+ pa_tests/pa_devs \ -+ pa_tests/pa_fuzz \ -+ pa_tests/pa_minlat \ -+ pa_tests/paqa_devs -+ -+check_PROGRAMS = $(TESTS) -+ -+LDADD = libportaudio.la -+ -+# Most of these don't compile yet. Put them in TESTS, above, if -+# you want to try to compile them... -+ALL_TESTS = \ -+ pa_tests/debug_convert \ -+ pa_tests/debug_dither_calc \ -+ pa_tests/debug_dual \ -+ pa_tests/debug_multi_in \ -+ pa_tests/debug_multi_out \ -+ pa_tests/debug_record \ -+ pa_tests/debug_record_reuse \ -+ pa_tests/debug_sine_amp \ -+ pa_tests/debug_sine \ -+ pa_tests/debug_sine_formats \ -+ pa_tests/debug_srate \ -+ pa_tests/debug_test1 \ -+ $(TESTS) -+ -+pkgconfigdir = $(libdir)/pkgconfig -+pkgconfig_DATA = portaudio-2.0.pc -+ -+ -+SUBDIRS= -+DIST_SUBDIRS= -+ -+ACLOCAL_AMFLAGS = -I config -+ -+doc: config.doxy -+ doxygen config.doxy -+ -+# pa_asio pa_beos pablio pa_common pa_dll_switch pa_jack pa_linux_alsa pa_mac pa_mac_core pa_mac_sm pa_sgi pa_tests pa_unix pa_unix_oss pa_win pa_win_ds pa_win_wdmks pa_win_wmme -+ -+PABLIO = \ -+ pablio/pablio.def \ -+ pablio/README.txt \ -+ pablio/ringbuffer.h \ -+ pablio/test_rw_echo.c \ -+ pablio/test_w_saw.c \ -+ pablio/pablio.c \ -+ pablio/pablio.h \ -+ pablio/ringbuffer.c \ -+ pablio/test_rw.c \ -+ pablio/test_w_saw8.c -+ -+EXTRA_DIST = \ -+ $(PABLIO) \ -+ config.doxy \ -+ LICENSE.txt \ -+ README.txt \ -+ portaudio-2.0.pc.in \ -+ V19-devel-readme.txt ---- /dev/null 2006-03-10 00:02:48.821312048 +0100 -+++ configure.ac 2006-03-19 22:49:13.000000000 +0100 -@@ -0,0 +1,278 @@ -+dnl -+dnl portaudio V19 configure.ac script -+dnl -+dnl Stephane Fillod, Dominic Mazzoni, Arve Knudsen -+dnl -+ -+dnl Require autoconf >= 2.57 -+AC_PREREQ(2.57) -+ -+dnl Init autoconf and make sure configure is being called -+dnl from the right directory -+AC_INIT([portaudio], [2.0cvs], [portaudio@techweb.rfa.org]) -+AC_CONFIG_SRCDIR([pa_common/portaudio.h]) -+AC_CONFIG_HEADERS(config.h) -+AC_CANONICAL_TARGET([]) -+ -+dnl Automake Initialisation. -+AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION, -) -+AM_MAINTAINER_MODE -+ -+dnl Portaudio library interface version, see libtool(info), esp. -+dnl node 6.3 "Updating version info" -+PA_ABI=19 -+PA_REV=0 -+PA_AGE=0 -+AC_SUBST(PA_ABI) -+AC_SUBST(PA_REV) -+AC_SUBST(PA_AGE) -+ -+ -+dnl Checks for programs. -+ -+AC_PROG_CC -+AC_PROG_CXX -+AC_PROG_RANLIB -+AC_PROG_INSTALL -+AC_PROG_MAKE_SET -+ -+AC_AIX -+AC_ISC_POSIX -+AC_MINIX -+AM_PROG_CC_STDC -+AC_PROG_GCC_TRADITIONAL -+AC_C_CONST -+AC_C_INLINE -+ -+dnl Check for Mingw support -+#GR_PWIN32 -+ -+dnl libtool Initialisation -+AC_LIBTOOL_WIN32_DLL -+AC_PROG_LIBTOOL -+ -+ACX_PTHREAD -+ -+dnl This must be one of the first tests we do or it will fail... -+AC_C_BIGENDIAN -+ -+dnl checks for various host APIs and arguments to configure that -+dnl turn them on or off -+ -+AC_CHECK_LIB(asound, snd_pcm_open, [have_alsa=yes], [have_alsa=no]) -+ -+ -+PKG_CHECK_MODULES(JACK, jack, [have_jack=yes], [have_jack=no]) -+PKG_CHECK_LIB(jack_client_new, [$JACK_LIBS], [$JACK_CFLAGS], [have_jack=yes], [have_jack=no]) -+ -+AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h soundcard.h machine/soundcard.h]) -+AC_CHECK_HEADERS(sys/ioctl.h, [have_oss=yes], [have_oss=no]) -+ -+dnl sizeof checks: we will need a 16-bit and a 32-bit type -+ -+AC_CHECK_SIZEOF(short) -+AC_CHECK_SIZEOF(int) -+AC_CHECK_SIZEOF(long) -+ -+dnl Specify options -+ -+AC_ARG_WITH(alsa, -+ [ --with-alsa (default=yes)], -+ [with_alsa=$withval], [with_alsa=$have_alsa]) -+ -+AC_ARG_WITH(jack, -+ [ --with-jack (default=yes)], -+ [with_jack=$withval], [with_jack=$have_jack]) -+ -+AC_ARG_WITH(oss, -+ [ --with-oss (default=yes)], -+ [with_oss=$withval], [with_oss=$have_oss]) -+ -+AC_ARG_WITH(winapi, -+ [ --with-winapi ((wmme/directx/asio) default=wmme)], -+ [with_winapi=$withval], [with_winapi="wmme"]) -+ -+dnl Mac API added for ASIO, can have other api's listed -+AC_ARG_WITH(macapi, -+ [ --with-macapi ((asio/core/sm) default=core)], -+ [with_macapi=$withval], [with_macapi="core"]) -+ -+AC_ARG_WITH(asiodir, -+ [ --with-asiodir (default=/usr/local/asiosdk2)], -+ [with_asiodir=$withval], [with_asiodir="/usr/local/asiosdk2"]) -+ -+AC_ARG_WITH(dxdir, -+ [ --with-dxdir (default=/usr/local/dx7sdk)], -+ [with_dxdir=$withval], [with_dxdir="/usr/local/dx7sdk"]) -+ -+AC_ARG_ENABLE(debug-output, -+ [ --enable-debug-output], -+ [if test x$enableval != xno ; then -+ AC_DEFINE(PA_ENABLE_DEBUG_OUTPUT,,[Enable debugging messages]) -+ fi -+ ]) -+ -+dnl BSD configuration -+AC_HAVE_LIBRARY(ossaudio) -+ -+dnl Mac OS X configuration -+ -+AC_CHECK_LIB(CoreAudio, OpenAComponent, -+ [ -+ have_coreaudio=yes -+ PA_LIBADD="$PA_LIBADD libportaudio-coreaudio.la" -+ AC_DEFINE([PA_USE_COREAUDIO], [], [Define to use Mac OS X CoreAudio]) -+ #LIBS="-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon" -+ LIBS="-lCoreAudio -lAudioToolbox -lAudioUnit -lCarbon" -+ ], have_coreaudio=no) -+ -+ASIO_CFLAGS="" -+ASIO_OBJS="" -+ -+if [[ $with_asiodir ]] ; then -+ ASIODIR="$with_asiodir" -+fi -+ -+if [[ $with_macapi = "asio" ]] ; then -+ echo "ASIODIR: $ASIODIR" -+ ASIO_CFLAGS="-Ipa_asio -I$ASIDIR/host/mac -I$ASIODIR/common" -+ ASIO_OBJS=$ASIODIR/common/asio.o $ASIODIR/host/asiodrivers.o $ASIODIR/host/mac/asioshlib.o -+ PA_LIBADD="$PA_LIBADD libportaudio-mac-asio.la" -+fi -+ -+if [[ $with_winapi = "asio" ]] ; then -+ echo "ASIODIR: $ASIODIR" -+ ASIO_CFLAGS="-ffast-math -fomit-frame-pointer -Ipa_asio -I$ASIDIR/host/pc -I$ASIODIR/common -I$ASIODIR/host -DPA_NO_WMME -DPA_NO_DS -DPA_NO_WDMKS -DWINDOWS" -+ ASIO_OBJS=$ASIODIR/common/asio.o $ASIODIR/host/asiodrivers.o $ASIODIR/host/pc/asiolist.o -+ LIBS="$LIBS -lwinmm -lole32 -luuid" -+ PA_LIBADD="$PA_LIBADD libportaudio-win-asio.la" -+fi -+ -+ -+dnl MingW/Win configuration -+ -+AC_TRY_LINK_LIB(dsound, [DSW_InitOutputBuffer(0,0,0,0);], [ -+ #include <windows.h> -+ #include <DSound.h> -+ ], [-I$DXDIR/include], -+ [ -+ have_directx=yes -+ DXDIR="$with_dxdir" -+ echo "DXDIR: $DXDIR" -+ # LDFLAGS -L./dx7sdk/lib ? -+ LIBS="-lwinmm -ldsound -lole32" -+ CFLAGS="$CFLAGS -I$DXDIR/include -DPA_NO_WMME -DPA_NO_ASIO -DPA_NO_WDMKS" -+ PA_LIBADD="$PA_LIBADD libportaudio-dsound.la" -+ ], have_directx=no) -+ -+AC_TRY_LINK_LIB(kernel32, [DeviceIoControl(0,0,0,0,0,0,0,0);],[ -+ #include <windows.h> -+ #include <winbase.h> -+ #include <ks.h> -+ ], [-I$DXDIR/include], -+ [ -+ have_wdmks=yes -+ DXDIR="$with_dxdir" -+ echo "DXDIR: $DXDIR" -+ # LDFLAGS -L./dx7sdk/lib ? -+ LIBS="-lwinmm -luuid -lsetupapi -lole32" -+ CFLAGS="$CFLAGS -I$DXDIR/include -DPA_NO_WMME -DPA_NO_DS -DPA_NO_ASIO" -+ PA_LIBADD="$PA_LIBADD libportaudio-wdmks.la" -+ ], have_wdmks=no) -+ -+# WMME default ? -+AC_TRY_LINK_LIB(winmm, [waveOutOpen(0,0,0,0,0,0);],[ -+ #include <windows.h> -+ #include <mmsystem.h> -+ ], [], -+ [ -+ have_wmme=yes -+ LIBS="-lwinmm -lole32 -luuid" -+ CFLAGS="$CFLAGS -DPA_NO_DS -DPA_NO_ASIO -DPA_NO_WDMKS" -+ PA_LIBADD="$PA_LIBADD libportaudio-wmme.la" -+ ], have_wmme=no) -+ -+ -+dnl Unix configuration -+ -+dnl SGI IRIX audio library (AL) configuration (Pieter, oct 2-13, 2003). -+dnl The 'dmedia' library is needed to read the Unadjusted System Time (UST). -+dnl -+ -+AC_CHECK_LIB(audio, alOpenPort, [have_AL=1], [have_AL=0]) -+AC_CHECK_LIB(dmedia, dmGetUST, [have_dmedia=1], [have_dmedia=0]) -+ -+ -+if [[ $have_AL = "yes" ] && [ $have_dmedia = "yes" ]] ; then -+ dnl See the '#ifdef PA_USE_SGI' in file pa_unix/pa_unix_hostapis.c -+ dnl which selects the appropriate PaXXX_Initialize() function. -+ dnl -+ -+ LIBS="-ldmedia -laudio" -+ AC_DEFINE([PA_USE_SGI], [], [Define to use special SGI system support]) -+ PA_LIBADD="$PA_LIBADD libportaudio-sgi.la" -+ -+ # TODO: -+ #AC_MSG_ERROR([IRIX audio library not found!]) -+ #AC_MSG_ERROR([IRIX digital media library not found!]) -+fi -+ -+ -+if [[ $have_alsa = "yes" ] && [ $with_alsa != "no" ]] ; then -+ LIBS="$LIBS -lasound" -+ AC_DEFINE([PA_USE_ALSA], [], [Define to use ALSA]) -+ PA_LIBADD="$PA_LIBADD libportaudio-alsa.la" -+fi -+ -+if [[ $have_jack = "yes" ] && [ $with_jack != "no" ]] ; then -+ LIBS="$LIBS $JACK_LIBS" -+ CFLAGS="$CFLAGS $JACK_CFLAGS" -+ AC_DEFINE([PA_USE_JACK], [], [Define to use JACK]) -+ PA_LIBADD="$PA_LIBADD libportaudio-jack.la" -+fi -+ -+if [[ $with_oss != "no" ]] ; then -+ AC_DEFINE([PA_USE_OSS], [], [Define to use Open Sound System]) -+ PA_LIBADD="$PA_LIBADD libportaudio-oss.la" -+fi -+ -+dnl SGI books say -lpthread should be the last of the libs mentioned. -+if [[ $acx_pthread_ok = "yes" ]] ; then -+ LIBS="$LIBS $PTHREAD_LIBS" -+ PA_LIBADD="$PA_LIBADD libportaudio-unix.la" -+else -+ if [[ $with_winapi != "wmme" -a $with_winapi != "directx" -a $with_winapi != "asio" ]] ; then -+ AC_MSG_ERROR([libpthread not found!]) -+ fi -+fi -+ -+ -+if [[ $with_macapi = "asio" ] || [ $with_winapi = "asio" ]] ; then -+ echo "ASIODIR: $ASIODIR" -+ -+ CFLAGS="$CFLAGS $ASIO_CFLAGS" -+fi -+ -+if [[ $ac_cv_c_bigendian = "yes" ]] ; then -+ CFLAGS="$CFLAGS -DPA_BIG_ENDIAN" -+else -+ CFLAGS="$CFLAGS -DPA_LITTLE_ENDIAN" -+fi -+ -+ -+CXXFLAGS="$CXXFLAGS" -+ -+#CFLAGS="-g -O2 -Wall -pedantic -pipe" -+ -+CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+ -+ -+dnl extra variables -+AC_SUBST(PA_LIBADD) -+AC_SUBST(ASIO_OBJS) -+AC_SUBST(PTHREAD_CFLAGS) -+AC_SUBST(CXXFLAGS) -+AC_SUBST(NASM) -+AC_SUBST(NASMOPT) -+ -+AC_OUTPUT([Makefile portaudio-2.0.pc]) ---- /dev/null 2006-03-10 00:02:48.821312048 +0100 -+++ config/acx_pthread.m4 2006-03-17 15:41:05.000000000 +0100 -@@ -0,0 +1,190 @@ -+dnl Available from the GNU Autoconf Macro Archive at: -+dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html -+dnl -+AC_DEFUN([ACX_PTHREAD], [ -+AC_REQUIRE([AC_CANONICAL_HOST]) -+AC_LANG_SAVE -+AC_LANG_C -+acx_pthread_ok=no -+ -+# We used to check for pthread.h first, but this fails if pthread.h -+# requires special compiler flags (e.g. on True64 or Sequent). -+# It gets checked for in the link test anyway. -+ -+# First of all, check if the user has set any of the PTHREAD_LIBS, -+# etcetera environment variables, and if threads linking works using -+# them: -+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then -+ save_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+ save_LIBS="$LIBS" -+ LIBS="$PTHREAD_LIBS $LIBS" -+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) -+ AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) -+ AC_MSG_RESULT($acx_pthread_ok) -+ if test x"$acx_pthread_ok" = xno; then -+ PTHREAD_LIBS="" -+ PTHREAD_CFLAGS="" -+ fi -+ LIBS="$save_LIBS" -+ CFLAGS="$save_CFLAGS" -+fi -+ -+# We must check for the threads library under a number of different -+# names; the ordering is very important because some systems -+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -+# libraries is broken (non-POSIX). -+ -+# Create a list of thread flags to try. Items starting with a "-" are -+# C compiler flags, and other items are library names, except for "none" -+# which indicates that we try without any flags at all. -+ -+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" -+ -+# The ordering *is* (sometimes) important. Some notes on the -+# individual items follow: -+ -+# pthreads: AIX (must check this before -lpthread) -+# none: in case threads are in libc; should be tried before -Kthread and -+# other compiler flags to prevent continual compiler warnings -+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -+# -pthreads: Solaris/gcc -+# -mthreads: Mingw32/gcc, Lynx/gcc -+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -+# doesn't hurt to check since this sometimes defines pthreads too; -+# also defines -D_REENTRANT) -+# pthread: Linux, etcetera -+# --thread-safe: KAI C++ -+ -+case "${host_cpu}-${host_os}" in -+ *solaris*) -+ -+ # On Solaris (at least, for some versions), libc contains stubbed -+ # (non-functional) versions of the pthreads routines, so link-based -+ # tests will erroneously succeed. (We need to link with -pthread or -+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather -+ # a function called by this macro, so we could check for that, but -+ # who knows whether they'll stub that too in a future libc.) So, -+ # we'll just look for -pthreads and -lpthread first: -+ -+ acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" -+ ;; -+esac -+ -+if test x"$acx_pthread_ok" = xno; then -+for flag in $acx_pthread_flags; do -+ -+ case $flag in -+ none) -+ AC_MSG_CHECKING([whether pthreads work without any flags]) -+ ;; -+ -+ -*) -+ AC_MSG_CHECKING([whether pthreads work with $flag]) -+ PTHREAD_CFLAGS="$flag" -+ ;; -+ -+ *) -+ AC_MSG_CHECKING([for the pthreads library -l$flag]) -+ PTHREAD_LIBS="-l$flag" -+ ;; -+ esac -+ -+ save_LIBS="$LIBS" -+ save_CFLAGS="$CFLAGS" -+ LIBS="$PTHREAD_LIBS $LIBS" -+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+ -+ # Check for various functions. We must include pthread.h, -+ # since some functions may be macros. (On the Sequent, we -+ # need a special flag -Kthread to make this header compile.) -+ # We check for pthread_join because it is in -lpthread on IRIX -+ # while pthread_create is in libc. We check for pthread_attr_init -+ # due to DEC craziness with -lpthreads. We check for -+ # pthread_cleanup_push because it is one of the few pthread -+ # functions on Solaris that doesn't have a non-functional libc stub. -+ # We try pthread_create on general principles. -+ AC_TRY_LINK([#include <pthread.h>], -+ [pthread_t th; pthread_join(th, 0); -+ pthread_attr_init(0); pthread_cleanup_push(0, 0); -+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], -+ [acx_pthread_ok=yes]) -+ -+ LIBS="$save_LIBS" -+ CFLAGS="$save_CFLAGS" -+ -+ AC_MSG_RESULT($acx_pthread_ok) -+ if test "x$acx_pthread_ok" = xyes; then -+ break; -+ fi -+ -+ PTHREAD_LIBS="" -+ PTHREAD_CFLAGS="" -+done -+fi -+ -+# Various other checks: -+if test "x$acx_pthread_ok" = xyes; then -+ save_LIBS="$LIBS" -+ LIBS="$PTHREAD_LIBS $LIBS" -+ save_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+ -+ # Detect AIX lossage: threads are created detached by default -+ # and the JOINABLE attribute has a nonstandard name (UNDETACHED). -+ AC_MSG_CHECKING([for joinable pthread attribute]) -+ AC_TRY_LINK([#include <pthread.h>], -+ [int attr=PTHREAD_CREATE_JOINABLE;], -+ ok=PTHREAD_CREATE_JOINABLE, ok=unknown) -+ if test x"$ok" = xunknown; then -+ AC_TRY_LINK([#include <pthread.h>], -+ [int attr=PTHREAD_CREATE_UNDETACHED;], -+ ok=PTHREAD_CREATE_UNDETACHED, ok=unknown) -+ fi -+ if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then -+ AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok, -+ [Define to the necessary symbol if this constant -+ uses a non-standard name on your system.]) -+ fi -+ AC_MSG_RESULT(${ok}) -+ if test x"$ok" = xunknown; then -+ AC_MSG_WARN([we do not know how to create joinable pthreads]) -+ fi -+ -+ AC_MSG_CHECKING([if more special flags are required for pthreads]) -+ flag=no -+ case "${host_cpu}-${host_os}" in -+ *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; -+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; -+ esac -+ AC_MSG_RESULT(${flag}) -+ if test "x$flag" != xno; then -+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" -+ fi -+ -+ LIBS="$save_LIBS" -+ CFLAGS="$save_CFLAGS" -+ -+ # More AIX lossage: must compile with cc_r -+ AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) -+else -+ PTHREAD_CC="$CC" -+fi -+ -+AC_SUBST(PTHREAD_LIBS) -+AC_SUBST(PTHREAD_CFLAGS) -+AC_SUBST(PTHREAD_CC) -+ -+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -+if test x"$acx_pthread_ok" = xyes; then -+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) -+ : -+else -+ acx_pthread_ok=no -+ $2 -+fi -+AC_LANG_RESTORE -+])dnl ACX_PTHREAD ---- /dev/null 2006-03-10 00:02:48.821312048 +0100 -+++ config/pkg_check.m4 2006-03-17 22:12:37.000000000 +0100 -@@ -0,0 +1,49 @@ -+ -+AC_DEFUN([PKG_CHECK_LIB], [ -+AC_REQUIRE([AC_CANONICAL_HOST]) -+AC_LANG_SAVE -+AC_LANG_C -+ -+ save_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS $3" -+ save_LIBS="$LIBS" -+ LIBS="$2 $LIBS" -+ AC_MSG_CHECKING([for $1 in LIBS=$2 with CFLAGS=$3]) -+ AC_TRY_LINK_FUNC([$1], pkg_check_try_link=yes, pkg_check_try_link=no) -+ AC_MSG_RESULT($pkg_check_try_link) -+ LIBS="$save_LIBS" -+ CFLAGS="$save_CFLAGS" -+ -+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -+if test x"$pkg_check_try_link" = xyes; then -+ $4 -+else -+ $5 -+fi -+AC_LANG_RESTORE -+])dnl PKG_CHECK_LIB -+ -+ -+AC_DEFUN([AC_TRY_LINK_LIB], [ -+AC_REQUIRE([AC_CANONICAL_HOST]) -+AC_LANG_SAVE -+AC_LANG_C -+ -+ save_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS $4" -+ save_LIBS="$LIBS" -+ LIBS="-l$1 $LIBS" -+ AC_MSG_CHECKING([for $2 in $1]) -+ AC_TRY_LINK([$3], [$2], ac_try_link_lib=yes, ac_try_link_lib=no) -+ AC_MSG_RESULT($ac_try_link_lib) -+ LIBS="$save_LIBS" -+ CFLAGS="$save_CFLAGS" -+ -+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -+if test x"$ac_try_link_lib" = xyes; then -+ $5 -+else -+ $6 -+fi -+AC_LANG_RESTORE -+])dnl AC_TRY_LINK_LIB ---- /dev/null 2006-03-10 00:02:48.821312048 +0100 -+++ bootstrap 2006-03-19 23:33:58.000000000 +0100 -@@ -0,0 +1,9 @@ -+#!/bin/sh -+ -+rm -rf config.cache autom4te*.cache -+ -+aclocal-1.9 -I config -+autoconf2.50 -+autoheader2.50 -+libtoolize --automake -+automake-1.9 --add-missing --foreign diff --git a/gr-audio-portaudio/gnuradio-audio-portaudio.pc.in b/gr-audio-portaudio/gnuradio-audio-portaudio.pc.in deleted file mode 100644 index 086195965..000000000 --- a/gr-audio-portaudio/gnuradio-audio-portaudio.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: gnuradio-audio-portaudio -Description: The GNU Radio block for the PORTAUDIO sound system -Requires: gnuradio-core -Version: @LIBVER@ -Libs: -L${libdir} -lgnuradio-audio-portaudio -Cflags: -I${includedir} diff --git a/gr-audio-portaudio/gr-audio-portaudio.conf b/gr-audio-portaudio/gr-audio-portaudio.conf deleted file mode 100644 index 0dd147443..000000000 --- a/gr-audio-portaudio/gr-audio-portaudio.conf +++ /dev/null @@ -1,10 +0,0 @@ -# This file contains system wide configuration data for GNU Radio. -# You may override any setting on a per-user basis by editing -# ~/.gnuradio/config.conf - -[audio_portaudio] - -#default_input_device = hw:0,0 -#default_output_device = hw:0,0 - -verbose = false diff --git a/gr-audio-portaudio/src/.gitignore b/gr-audio-portaudio/src/.gitignore deleted file mode 100644 index f05e85127..000000000 --- a/gr-audio-portaudio/src/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.pyc -/*.pyo -/usrp.py -/usrp.cc -/audio_oss.cc -/audio_oss.py -/audio_portaudio.py -/audio_portaudio.cc -/run_tests -/gnuradio -/guile -/python diff --git a/gr-audio-portaudio/src/Makefile.am b/gr-audio-portaudio/src/Makefile.am deleted file mode 100644 index f8d42792b..000000000 --- a/gr-audio-portaudio/src/Makefile.am +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright 2004,2008,2009,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -TESTS = -EXTRA_DIST += run_tests.in -DISTCLEANFILES += run_tests - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(PORTAUDIO_CFLAGS) $(WITH_INCLUDES) - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - audio_portaudio_sink.h \ - audio_portaudio_source.h - -noinst_HEADERS = \ - gri_portaudio.h - -noinst_PYTHON = \ - qa_portaudio.py - -lib_LTLIBRARIES = libgnuradio-audio-portaudio.la - -libgnuradio_audio_portaudio_la_SOURCES = \ - audio_portaudio_sink.cc \ - audio_portaudio_source.cc \ - gri_portaudio.cc - -libgnuradio_audio_portaudio_la_LIBADD = \ - $(GNURADIO_CORE_LA) \ - $(PORTAUDIO_LIBS) - -libgnuradio_audio_portaudio_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) - - -################################### -# SWIG interfaces and libraries - -TOP_SWIG_IFILES = \ - audio_portaudio.i - -# Install so that they end up available as: -# import gnuradio.audio_portaudio -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -audio_portaudio_pythondir_category = \ - gnuradio - -# additional libraries for linking with the SWIG-generated library -audio_portaudio_la_swig_libadd = \ - libgnuradio-audio-portaudio.la - - -if PYTHON -TESTS += run_tests -endif
\ No newline at end of file diff --git a/gr-audio-portaudio/src/Makefile.swig.gen b/gr-audio-portaudio/src/Makefile.swig.gen deleted file mode 100644 index 32c2e54e1..000000000 --- a/gr-audio-portaudio/src/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for audio_portaudio.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/audio_portaudio -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/audio_portaudio -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -audio_portaudio_pythondir_category ?= gnuradio/audio_portaudio -audio_portaudio_pylibdir_category ?= $(audio_portaudio_pythondir_category) -audio_portaudio_pythondir = $(pythondir)/$(audio_portaudio_pythondir_category) -audio_portaudio_pylibdir = $(pyexecdir)/$(audio_portaudio_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -audio_portaudio_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/audio_portaudio -# FIXME: determince whether these should be installed with gnuradio. -audio_portaudio_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -audio_portaudio_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -audio_portaudio_swiginclude_HEADERS = \ - audio_portaudio.i \ - $(audio_portaudio_swiginclude_headers) - -if PYTHON -audio_portaudio_pylib_LTLIBRARIES = \ - _audio_portaudio.la - -_audio_portaudio_la_SOURCES = \ - python/audio_portaudio.cc \ - $(audio_portaudio_la_swig_sources) - -audio_portaudio_python_PYTHON = \ - audio_portaudio.py \ - $(audio_portaudio_python) - -_audio_portaudio_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_portaudio_la_swig_libadd) - -_audio_portaudio_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_portaudio_la_swig_ldflags) - -_audio_portaudio_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_portaudio_la_swig_cxxflags) - -python/audio_portaudio.cc: audio_portaudio.py -audio_portaudio.py: audio_portaudio.i - -# Include the python dependencies for this file --include python/audio_portaudio.d - -endif # end of if python - -if GUILE - -audio_portaudio_scmlib_LTLIBRARIES = \ - libguile-gnuradio-audio_portaudio.la -libguile_gnuradio_audio_portaudio_la_SOURCES = \ - guile/audio_portaudio.cc \ - $(audio_portaudio_la_swig_sources) -nobase_audio_portaudio_scm_DATA = \ - gnuradio/audio_portaudio.scm \ - gnuradio/audio_portaudio-primitive.scm -libguile_gnuradio_audio_portaudio_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_portaudio_la_swig_libadd) -libguile_gnuradio_audio_portaudio_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_portaudio_la_swig_ldflags) -libguile_gnuradio_audio_portaudio_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_portaudio_la_swig_cxxflags) - -guile/audio_portaudio.cc: gnuradio/audio_portaudio.scm -gnuradio/audio_portaudio.scm: audio_portaudio.i -gnuradio/audio_portaudio-primitive.scm: gnuradio/audio_portaudio.scm - -# Include the guile dependencies for this file --include guile/audio_portaudio.d - -endif # end of GUILE - - diff --git a/gr-audio-portaudio/src/audio_portaudio.i b/gr-audio-portaudio/src/audio_portaudio.i deleted file mode 100644 index 612b0afff..000000000 --- a/gr-audio-portaudio/src/audio_portaudio.i +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "audio_portaudio_sink.h" -#include "audio_portaudio_source.h" -%} - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_portaudio,source) - -audio_portaudio_source_sptr -audio_portaudio_make_source (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - -class audio_portaudio_source : public gr_sync_block { - - protected: - audio_portaudio_source (int sampling_rate, - const std::string device_name, - bool ok_to_block - ) throw (std::runtime_error); - - public: - ~audio_portaudio_source (); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_portaudio,sink) - -audio_portaudio_sink_sptr -audio_portaudio_make_sink (int sampling_rate, - const std::string dev = "", - bool ok_to_block = true - ) throw (std::runtime_error); - -class audio_portaudio_sink : public gr_sync_block { - - protected: - audio_portaudio_sink (int sampling_rate, - const std::string device_name, - bool ok_to_block - ) throw (std::runtime_error); - - public: - ~audio_portaudio_sink (); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-audio_portaudio" "scm_init_gnuradio_audio_portaudio_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-audio-portaudio/src/audio_portaudio_sink.cc b/gr-audio-portaudio/src/audio_portaudio_sink.cc deleted file mode 100644 index 64e64ccf4..000000000 --- a/gr-audio-portaudio/src/audio_portaudio_sink.cc +++ /dev/null @@ -1,362 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in he 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_portaudio_sink.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <stdio.h> -#include <iostream> -#include <unistd.h> -#include <stdexcept> -#include <gri_portaudio.h> -#include <string.h> - -//#define LOGGING 0 // define to 0 or 1 - -#define SAMPLE_FORMAT paFloat32 -typedef float sample_t; - -// Number of portaudio buffers in the ringbuffer -static const unsigned int N_BUFFERS = 4; - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_portaudio", "default_output_device", ""); -} - -void -audio_portaudio_sink::create_ringbuffer(void) -{ - int bufsize_samples = d_portaudio_buffer_size_frames * d_output_parameters.channelCount; - - if (d_verbose) - fprintf(stderr,"ring buffer size = %d frames\n", - N_BUFFERS*bufsize_samples/d_output_parameters.channelCount); - - // FYI, the buffer indicies are in units of samples. - d_writer = gr_make_buffer(N_BUFFERS * bufsize_samples, sizeof(sample_t)); - d_reader = gr_buffer_add_reader(d_writer, 0); -} - -/* - * This routine will be called by the PortAudio engine when audio is needed. - * It may called at interrupt level on some machines so don't do anything - * that could mess up the system like calling malloc() or free(). - * - * Our job is to write framesPerBuffer frames into outputBuffer. - */ -int -portaudio_sink_callback (const void *inputBuffer, - void *outputBuffer, - unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *arg) -{ - audio_portaudio_sink *self = (audio_portaudio_sink *)arg; - int nreqd_samples = - framesPerBuffer * self->d_output_parameters.channelCount; - - int navail_samples = self->d_reader->items_available(); - - if (nreqd_samples <= navail_samples) { // We've got enough data... - { - gruel::scoped_lock guard(self->d_ringbuffer_mutex); - - memcpy(outputBuffer, - self->d_reader->read_pointer(), - nreqd_samples * sizeof(sample_t)); - self->d_reader->update_read_pointer(nreqd_samples); - - self->d_ringbuffer_ready = true; - } - - // Tell the sink thread there is new room in the ringbuffer. - self->d_ringbuffer_cond.notify_one(); - return paContinue; - } - - else { // underrun - self->d_nunderuns++; - ssize_t r = ::write(2, "aU", 2); // FIXME change to non-blocking call - if(r == -1) { - perror("audio_portaudio_source::portaudio_source_callback write error to stderr."); - } - - // FIXME we should transfer what we've got and pad the rest - memset(outputBuffer, 0, nreqd_samples * sizeof(sample_t)); - - self->d_ringbuffer_ready = true; - self->d_ringbuffer_cond.notify_one(); // Tell the sink to get going! - - return paContinue; - } -} - - -// ---------------------------------------------------------------- - -audio_portaudio_sink_sptr -audio_portaudio_make_sink (int sampling_rate, const std::string dev, bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_portaudio_sink (sampling_rate, - dev, ok_to_block)); -} - -audio_portaudio_sink::audio_portaudio_sink(int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_portaudio_sink", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(0, 0, 0)), - d_sampling_rate(sampling_rate), - d_device_name(device_name.empty() ? default_device_name() : device_name), - d_ok_to_block(ok_to_block), - d_verbose(gr_prefs::singleton()->get_bool("audio_portaudio", "verbose", false)), - d_portaudio_buffer_size_frames(0), - d_stream(0), - d_ringbuffer_mutex(), - d_ringbuffer_cond(), - d_ringbuffer_ready(false), - d_nunderuns(0) -{ - memset(&d_output_parameters, 0, sizeof(d_output_parameters)); - //if (LOGGING) - // d_log = gri_logger::singleton(); - - PaError err; - int i, numDevices; - PaDeviceIndex device = 0; - const PaDeviceInfo *deviceInfo = NULL; - - err = Pa_Initialize(); - if (err != paNoError) { - bail ("Initialize failed", err); - } - - if (d_verbose) - gri_print_devices(); - - numDevices = Pa_GetDeviceCount(); - if (numDevices < 0) - bail("Pa Device count failed", 0); - if (numDevices == 0) - bail("no devices available", 0); - - if (d_device_name.empty()) - { - // FIXME Get smarter about picking something - fprintf(stderr,"\nUsing Default Device\n"); - device = Pa_GetDefaultOutputDevice(); - deviceInfo = Pa_GetDeviceInfo(device); - fprintf(stderr,"%s is the chosen device using %s as the host\n", - deviceInfo->name, Pa_GetHostApiInfo(deviceInfo->hostApi)->name); - } - else - { - bool found = false; - fprintf(stderr,"\nTest Devices\n"); - for (i=0;i<numDevices;i++) { - deviceInfo = Pa_GetDeviceInfo( i ); - fprintf(stderr,"Testing device name: %s",deviceInfo->name); - if (deviceInfo->maxOutputChannels <= 0) { - fprintf(stderr,"\n"); - continue; - } - if (strstr(deviceInfo->name, d_device_name.c_str())){ - fprintf(stderr," Chosen!\n"); - device = i; - fprintf(stderr,"%s using %s as the host\n",d_device_name.c_str(), - Pa_GetHostApiInfo(deviceInfo->hostApi)->name), fflush(stderr); - found = true; - deviceInfo = Pa_GetDeviceInfo(device); - i = numDevices; // force loop exit - } - else - fprintf(stderr,"\n"),fflush(stderr); - } - - if (!found){ - bail("Failed to find specified device name", 0); - exit(1); - } - } - - - d_output_parameters.device = device; - d_output_parameters.channelCount = deviceInfo->maxOutputChannels; - d_output_parameters.sampleFormat = SAMPLE_FORMAT; - d_output_parameters.suggestedLatency = deviceInfo->defaultLowOutputLatency; - d_output_parameters.hostApiSpecificStreamInfo = NULL; - - // We fill in the real channelCount in check_topology when we know - // how many inputs are connected to us. - - // Now that we know the maximum number of channels (allegedly) - // supported by the h/w, we can compute a reasonable input - // signature. The portaudio specs say that they'll accept any - // number of channels from 1 to max. - set_input_signature(gr_make_io_signature(1, deviceInfo->maxOutputChannels, - sizeof (sample_t))); -} - - -bool -audio_portaudio_sink::check_topology (int ninputs, int noutputs) -{ - PaError err; - - if (Pa_IsStreamActive(d_stream)) - { - Pa_CloseStream(d_stream); - d_stream = 0; - d_reader.reset(); // boost::shared_ptr for d_reader = 0 - d_writer.reset(); // boost::shared_ptr for d_write = 0 - } - - d_output_parameters.channelCount = ninputs; // # of channels we're really using - -#if 1 - d_portaudio_buffer_size_frames = (int)(0.0213333333 * d_sampling_rate + 0.5); // Force 1024 frame buffers at 48000 - fprintf(stderr, "Latency = %8.5f, requested sampling_rate = %g\n", // Force latency to 21.3333333.. ms - 0.0213333333, (double)d_sampling_rate); -#endif - err = Pa_OpenStream(&d_stream, - NULL, // No input - &d_output_parameters, - d_sampling_rate, - d_portaudio_buffer_size_frames, - paClipOff, - &portaudio_sink_callback, - (void*)this); - - if (err != paNoError) { - output_error_msg ("OpenStream failed", err); - return false; - } - -#if 0 - const PaStreamInfo *psi = Pa_GetStreamInfo(d_stream); - - d_portaudio_buffer_size_frames = (int)(d_output_parameters.suggestedLatency * psi->sampleRate); - fprintf(stderr, "Latency = %7.4f, psi->sampleRate = %g\n", - d_output_parameters.suggestedLatency, psi->sampleRate); -#endif - - fprintf(stderr, "d_portaudio_buffer_size_frames = %d\n", d_portaudio_buffer_size_frames); - - assert(d_portaudio_buffer_size_frames != 0); - - create_ringbuffer(); - - err = Pa_StartStream(d_stream); - if (err != paNoError) { - output_error_msg ("StartStream failed", err); - return false; - } - - return true; -} - -audio_portaudio_sink::~audio_portaudio_sink () -{ - Pa_StopStream(d_stream); // wait for output to drain - Pa_CloseStream(d_stream); - Pa_Terminate(); -} - -/* - * This version consumes everything sent to it, blocking if required. - * I think this will allow us better control of the total buffering/latency - * in the audio path. - */ -int -audio_portaudio_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float **in = (const float **) &input_items[0]; - const unsigned nchan = d_output_parameters.channelCount; // # of channels == samples/frame - - int k; - - for (k = 0; k < noutput_items; ){ - int nframes = d_writer->space_available() / nchan; // How much space in ringbuffer - if (nframes == 0){ // no room... - if (d_ok_to_block){ - { - gruel::scoped_lock guard(d_ringbuffer_mutex); - while (!d_ringbuffer_ready) - d_ringbuffer_cond.wait(guard); - } - - continue; - } - else { - // There's no room and we're not allowed to block. - // (A USRP is most likely controlling the pacing through the pipeline.) - // We drop the samples on the ground, and say we processed them all ;) - // - // FIXME, there's probably room for a bit more finesse here. - return noutput_items; - } - } - - // We can write the smaller of the request and the room we've got - { - gruel::scoped_lock guard(d_ringbuffer_mutex); - - int nf = std::min(noutput_items - k, nframes); - float *p = (float *) d_writer->write_pointer(); - - for (int i = 0; i < nf; i++) - for (unsigned int c = 0; c < nchan; c++) - *p++ = in[c][k + i]; - - d_writer->update_write_pointer(nf * nchan); - k += nf; - - d_ringbuffer_ready = false; - } - } - - return k; // tell how many we actually did -} - -void -audio_portaudio_sink::output_error_msg (const char *msg, int err) -{ - fprintf (stderr, "audio_portaudio_sink[%s]: %s: %s\n", - d_device_name.c_str (), msg, Pa_GetErrorText(err)); -} - -void -audio_portaudio_sink::bail (const char *msg, int err) throw (std::runtime_error) -{ - output_error_msg (msg, err); - throw std::runtime_error ("audio_portaudio_sink"); -} diff --git a/gr-audio-portaudio/src/audio_portaudio_sink.h b/gr-audio-portaudio/src/audio_portaudio_sink.h deleted file mode 100644 index 71cbfcf9f..000000000 --- a/gr-audio-portaudio/src/audio_portaudio_sink.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_AUDIO_PORTAUDIO_SINK_H -#define INCLUDED_AUDIO_PORTAUDIO_SINK_H - -#include <gr_sync_block.h> -#include <gr_buffer.h> -#include <gruel/thread.h> -#include <string> -#include <portaudio.h> -#include <stdexcept> -//#include <gri_logger.h> - -class audio_portaudio_sink; -typedef boost::shared_ptr<audio_portaudio_sink> audio_portaudio_sink_sptr; - -/*! - * \brief PORTAUDIO audio sink. - * - * \param sampling_rate sampling rate in Hz - * \param device_name PORTAUDIO device name, e.g., "pa:" - * \param ok_to_block true if it's ok for us to block - */ -audio_portaudio_sink_sptr -audio_portaudio_make_sink (int sampling_rate, - const std::string device_name = "", - bool ok_to_block = true); - -PaStreamCallback portaudio_sink_callback; - - -/*! - * \ Audio sink using PORTAUDIO - * - * Input samples must be in the range [-1,1]. - */ -class audio_portaudio_sink : public gr_sync_block { - friend audio_portaudio_sink_sptr - audio_portaudio_make_sink (int sampling_rate, - const std::string device_name, - bool ok_to_block); - - friend PaStreamCallback portaudio_sink_callback; - - - unsigned int d_sampling_rate; - std::string d_device_name; - bool d_ok_to_block; - bool d_verbose; - - unsigned int d_portaudio_buffer_size_frames; // number of frames in a portaudio buffer - - PaStream *d_stream; - PaStreamParameters d_output_parameters; - - gr_buffer_sptr d_writer; // buffer used between work and callback - gr_buffer_reader_sptr d_reader; - - gruel::mutex d_ringbuffer_mutex; - gruel::condition_variable d_ringbuffer_cond; - bool d_ringbuffer_ready; - - // random stats - int d_nunderuns; // count of underruns - //gri_logger_sptr d_log; // handle to non-blocking logging instance - - void output_error_msg (const char *msg, int err); - void bail (const char *msg, int err) throw (std::runtime_error); - void create_ringbuffer(); - - - protected: - audio_portaudio_sink (int sampling_rate, const std::string device_name, - bool ok_to_block); - - public: - ~audio_portaudio_sink (); - - bool check_topology (int ninputs, int noutputs); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_AUDIO_PORTAUDIO_SINK_H */ diff --git a/gr-audio-portaudio/src/audio_portaudio_source.cc b/gr-audio-portaudio/src/audio_portaudio_source.cc deleted file mode 100644 index e508fda22..000000000 --- a/gr-audio-portaudio/src/audio_portaudio_source.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in he 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_portaudio_source.h> -#include <gr_io_signature.h> -#include <gr_prefs.h> -#include <stdio.h> -#include <iostream> -#include <unistd.h> -#include <stdexcept> -#include <gri_portaudio.h> -#include <string.h> - -//#define LOGGING 0 // define to 0 or 1 - -#define SAMPLE_FORMAT paFloat32 -typedef float sample_t; - -// Number of portaudio buffers in the ringbuffer -static const unsigned int N_BUFFERS = 4; - -static std::string -default_device_name () -{ - return gr_prefs::singleton()->get_string("audio_portaudio", "default_input_device", ""); -} - -void -audio_portaudio_source::create_ringbuffer(void) -{ - int bufsize_samples = d_portaudio_buffer_size_frames * d_input_parameters.channelCount; - - if (d_verbose) - fprintf(stderr, "ring buffer size = %d frames\n", - N_BUFFERS*bufsize_samples/d_input_parameters.channelCount); - - // FYI, the buffer indicies are in units of samples. - d_writer = gr_make_buffer(N_BUFFERS * bufsize_samples, sizeof(sample_t)); - d_reader = gr_buffer_add_reader(d_writer, 0); -} - -/* - * This routine will be called by the PortAudio engine when audio is needed. - * It may called at interrupt level on some machines so don't do anything - * that could mess up the system like calling malloc() or free(). - * - * Our job is to copy framesPerBuffer frames from inputBuffer. - */ -int -portaudio_source_callback (const void *inputBuffer, - void *outputBuffer, - unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *arg) -{ - audio_portaudio_source *self = (audio_portaudio_source *)arg; - int nchan = self->d_input_parameters.channelCount; - int nframes_to_copy = framesPerBuffer; - int nframes_room = self->d_writer->space_available() / nchan; - - if (nframes_to_copy <= nframes_room){ // We've got room for the data .. - //if (LOGGING) - // self->d_log->printf("PAsrc cb: f/b = %4ld\n", framesPerBuffer); - - // copy from input buffer to ringbuffer - { - gruel::scoped_lock(d_ringbuffer_mutex); - - memcpy(self->d_writer->write_pointer(), - inputBuffer, - nframes_to_copy * nchan * sizeof(sample_t)); - self->d_writer->update_write_pointer(nframes_to_copy * nchan); - - // Tell the source thread there is new data in the ringbuffer. - self->d_ringbuffer_ready = true; - } - - self->d_ringbuffer_cond.notify_one(); - return paContinue; - } - - else { // overrun - self->d_noverruns++; - ssize_t r = ::write(2, "aO", 2); // FIXME change to non-blocking call - if(r == -1) { - perror("audio_portaudio_source::portaudio_source_callback write error to stderr."); - } - - self->d_ringbuffer_ready = false; - self->d_ringbuffer_cond.notify_one(); // Tell the sink to get going! - return paContinue; - } -} - - -// ---------------------------------------------------------------- - -audio_portaudio_source_sptr -audio_portaudio_make_source (int sampling_rate, const std::string dev, bool ok_to_block) -{ - return gnuradio::get_initial_sptr(new audio_portaudio_source (sampling_rate, - dev, ok_to_block)); -} - -audio_portaudio_source::audio_portaudio_source(int sampling_rate, - const std::string device_name, - bool ok_to_block) - : gr_sync_block ("audio_portaudio_source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(0, 0, 0)), - d_sampling_rate(sampling_rate), - d_device_name(device_name.empty() ? default_device_name() : device_name), - d_ok_to_block(ok_to_block), - d_verbose(gr_prefs::singleton()->get_bool("audio_portaudio", "verbose", false)), - d_portaudio_buffer_size_frames(0), - d_stream(0), - d_ringbuffer_mutex(), - d_ringbuffer_cond(), - d_ringbuffer_ready(false), - d_noverruns(0) -{ - memset(&d_input_parameters, 0, sizeof(d_input_parameters)); - //if (LOGGING) - // d_log = gri_logger::singleton(); - - PaError err; - int i, numDevices; - PaDeviceIndex device = 0; - const PaDeviceInfo *deviceInfo = NULL; - - - err = Pa_Initialize(); - if (err != paNoError) { - bail ("Initialize failed", err); - } - - if (d_verbose) - gri_print_devices(); - - numDevices = Pa_GetDeviceCount(); - if (numDevices < 0) - bail("Pa Device count failed", 0); - if (numDevices == 0) - bail("no devices available", 0); - - if (d_device_name.empty()) - { - // FIXME Get smarter about picking something - device = Pa_GetDefaultInputDevice(); - deviceInfo = Pa_GetDeviceInfo(device); - fprintf(stderr,"%s is the chosen device using %s as the host\n", - deviceInfo->name, Pa_GetHostApiInfo(deviceInfo->hostApi)->name); - } - else - { - bool found = false; - - for (i=0;i<numDevices;i++) { - deviceInfo = Pa_GetDeviceInfo( i ); - fprintf(stderr,"Testing device name: %s",deviceInfo->name); - if (deviceInfo->maxInputChannels <= 0) { - fprintf(stderr,"\n"); - continue; - } - if (strstr(deviceInfo->name, d_device_name.c_str())){ - fprintf(stderr," Chosen!\n"); - device = i; - fprintf(stderr,"%s using %s as the host\n",d_device_name.c_str(), - Pa_GetHostApiInfo(deviceInfo->hostApi)->name), fflush(stderr); - found = true; - deviceInfo = Pa_GetDeviceInfo(device); - i = numDevices; // force loop exit - } - else - fprintf(stderr,"\n"),fflush(stderr); - } - - if (!found){ - bail("Failed to find specified device name", 0); - } - } - - - d_input_parameters.device = device; - d_input_parameters.channelCount = deviceInfo->maxInputChannels; - d_input_parameters.sampleFormat = SAMPLE_FORMAT; - d_input_parameters.suggestedLatency = deviceInfo->defaultLowInputLatency; - d_input_parameters.hostApiSpecificStreamInfo = NULL; - - // We fill in the real channelCount in check_topology when we know - // how many inputs are connected to us. - - // Now that we know the maximum number of channels (allegedly) - // supported by the h/w, we can compute a reasonable output - // signature. The portaudio specs say that they'll accept any - // number of channels from 1 to max. - set_output_signature(gr_make_io_signature(1, deviceInfo->maxInputChannels, - sizeof (sample_t))); -} - - -bool -audio_portaudio_source::check_topology (int ninputs, int noutputs) -{ - PaError err; - - if (Pa_IsStreamActive(d_stream)) - { - Pa_CloseStream(d_stream); - d_stream = 0; - d_reader.reset(); // boost::shared_ptr for d_reader = 0 - d_writer.reset(); // boost::shared_ptr for d_write = 0 - } - - d_input_parameters.channelCount = noutputs; // # of channels we're really using - -#if 1 - d_portaudio_buffer_size_frames = (int)(0.0213333333 * d_sampling_rate + 0.5); // Force 512 frame buffers at 48000 - fprintf(stderr, "Latency = %8.5f, requested sampling_rate = %g\n", // Force latency to 21.3333333.. ms - 0.0213333333, (double)d_sampling_rate); -#endif - err = Pa_OpenStream(&d_stream, - &d_input_parameters, - NULL, // No output - d_sampling_rate, - d_portaudio_buffer_size_frames, - paClipOff, - &portaudio_source_callback, - (void*)this); - - if (err != paNoError) { - output_error_msg ("OpenStream failed", err); - return false; - } - -#if 0 - const PaStreamInfo *psi = Pa_GetStreamInfo(d_stream); - - d_portaudio_buffer_size_frames = (int)(d_input_parameters.suggestedLatency * psi->sampleRate); - fprintf(stderr, "Latency = %7.4f, psi->sampleRate = %g\n", - d_input_parameters.suggestedLatency, psi->sampleRate); -#endif - - fprintf(stderr, "d_portaudio_buffer_size_frames = %d\n", d_portaudio_buffer_size_frames); - - assert(d_portaudio_buffer_size_frames != 0); - - create_ringbuffer(); - - err = Pa_StartStream(d_stream); - if (err != paNoError) { - output_error_msg ("StartStream failed", err); - return false; - } - - return true; -} - -audio_portaudio_source::~audio_portaudio_source () -{ - Pa_StopStream(d_stream); // wait for output to drain - Pa_CloseStream(d_stream); - Pa_Terminate(); -} - -int -audio_portaudio_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float **out = (float **) &output_items[0]; - const unsigned nchan = d_input_parameters.channelCount; // # of channels == samples/frame - - int k; - for (k = 0; k < noutput_items; ){ - - int nframes = d_reader->items_available() / nchan; // # of frames in ringbuffer - if (nframes == 0){ // no data right now... - if (k > 0) // If we've produced anything so far, return that - return k; - - if (d_ok_to_block) { - gruel:: scoped_lock guard(d_ringbuffer_mutex); - while (d_ringbuffer_ready == false) - d_ringbuffer_cond.wait(guard); // block here, then try again - continue; - } - - assert(k == 0); - - // There's no data and we're not allowed to block. - // (A USRP is most likely controlling the pacing through the pipeline.) - // This is an underun. The scheduler wouldn't have called us if it - // had anything better to do. Thus we really need to produce some amount - // of "fill". - // - // There are lots of options for comfort noise, etc. - // FIXME We'll fill with zeros for now. Yes, it will "click"... - - // Fill with some frames of zeros - { - gruel::scoped_lock guard(d_ringbuffer_mutex); - - int nf = std::min(noutput_items - k, (int) d_portaudio_buffer_size_frames); - for (int i = 0; i < nf; i++){ - for (unsigned int c = 0; c < nchan; c++){ - out[c][k + i] = 0; - } - } - k += nf; - - d_ringbuffer_ready = false; - return k; - } - } - - // We can read the smaller of the request and what's in the buffer. - { - gruel::scoped_lock guard(d_ringbuffer_mutex); - - int nf = std::min(noutput_items - k, nframes); - - const float *p = (const float *) d_reader->read_pointer(); - for (int i = 0; i < nf; i++){ - for (unsigned int c = 0; c < nchan; c++){ - out[c][k + i] = *p++; - } - } - d_reader->update_read_pointer(nf * nchan); - k += nf; - d_ringbuffer_ready = false; - } - } - - return k; // tell how many we actually did -} - -void -audio_portaudio_source::output_error_msg (const char *msg, int err) -{ - fprintf (stderr, "audio_portaudio_source[%s]: %s: %s\n", - d_device_name.c_str (), msg, Pa_GetErrorText(err)); -} - -void -audio_portaudio_source::bail (const char *msg, int err) throw (std::runtime_error) -{ - output_error_msg (msg, err); - throw std::runtime_error ("audio_portaudio_source"); -} diff --git a/gr-audio-portaudio/src/audio_portaudio_source.h b/gr-audio-portaudio/src/audio_portaudio_source.h deleted file mode 100644 index 31e70a127..000000000 --- a/gr-audio-portaudio/src/audio_portaudio_source.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006.2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_AUDIO_PORTAUDIO_SOURCE_H -#define INCLUDED_AUDIO_PORTAUDIO_SOURCE_H - -#include <gr_sync_block.h> -#include <gr_buffer.h> -#include <gruel/thread.h> -#include <string> -#include <portaudio.h> -#include <stdexcept> - -class audio_portaudio_source; -typedef boost::shared_ptr<audio_portaudio_source> audio_portaudio_source_sptr; - -/*! - * \brief PORTAUDIO audio source. - * - * \param sampling_rate sampling rate in Hz - * \param device_name PORTAUDIO device name, e.g., "pa:" - * \param ok_to_block true if it's ok for us to block - */ -audio_portaudio_source_sptr -audio_portaudio_make_source (int sampling_rate, - const std::string device_name = "", - bool ok_to_block = true); - -PaStreamCallback portaudio_source_callback; - - -/*! - * \ Audio source using PORTAUDIO - * - * Input samples must be in the range [-1,1]. - */ -class audio_portaudio_source : public gr_sync_block { - friend audio_portaudio_source_sptr - audio_portaudio_make_source (int sampling_rate, - const std::string device_name, - bool ok_to_block); - - friend PaStreamCallback portaudio_source_callback; - - - unsigned int d_sampling_rate; - std::string d_device_name; - bool d_ok_to_block; - bool d_verbose; - - unsigned int d_portaudio_buffer_size_frames; // number of frames in a portaudio buffer - - PaStream *d_stream; - PaStreamParameters d_input_parameters; - - gr_buffer_sptr d_writer; // buffer used between work and callback - gr_buffer_reader_sptr d_reader; - - gruel::mutex d_ringbuffer_mutex; - gruel::condition_variable d_ringbuffer_cond; - bool d_ringbuffer_ready; - - // random stats - int d_noverruns; // count of overruns - - void output_error_msg (const char *msg, int err); - void bail (const char *msg, int err) throw (std::runtime_error); - void create_ringbuffer(); - - - protected: - audio_portaudio_source (int sampling_rate, const std::string device_name, - bool ok_to_block); - - public: - ~audio_portaudio_source (); - - bool check_topology (int ninputs, int noutputs); - - int work (int ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_AUDIO_PORTAUDIO_SOURCE_H */ diff --git a/gr-audio-portaudio/src/gri_portaudio.cc b/gr-audio-portaudio/src/gri_portaudio.cc deleted file mode 100644 index faa472337..000000000 --- a/gr-audio-portaudio/src/gri_portaudio.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_portaudio.h> -#include <portaudio.h> -#include <string.h> - - -PaDeviceIndex -gri_pa_find_device_by_name(const char *name) -{ - int i; - int numDevices; - const PaDeviceInfo *pdi; - int len = strlen( name ); - PaDeviceIndex result = paNoDevice; - numDevices = Pa_GetDeviceCount(); - for( i=0; i<numDevices; i++ ) - { - pdi = Pa_GetDeviceInfo( i ); - if( strncmp( name, pdi->name, len ) == 0 ) - { - result = i; - break; - } - } - return result; -} - - -void -gri_print_devices() -{ - int numDevices, defaultDisplayed, myDevice=0; - const PaDeviceInfo *deviceInfo; - - numDevices = Pa_GetDeviceCount(); - if (numDevices < 0) - return; - - printf("Number of devices found = %d\n", numDevices); - - for (int i=0; i < numDevices; i++ ) { - deviceInfo = Pa_GetDeviceInfo( i ); - printf( "--------------------------------------- device #%d\n", i ); - /* Mark global and API specific default devices */ - defaultDisplayed = 0; - if( i == Pa_GetDefaultInputDevice() ) - { - myDevice = i; - printf( "[ Default Input" ); - defaultDisplayed = 1; - } - else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultInputDevice ) - { - const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi ); - printf( "[ Default %s Input", hostInfo->name ); - defaultDisplayed = 1; - } - - if( i == Pa_GetDefaultOutputDevice() ) - { - printf( (defaultDisplayed ? "," : "[") ); - printf( " Default Output" ); - defaultDisplayed = 1; - } - else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultOutputDevice ) - { - const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi ); - printf( (defaultDisplayed ? "," : "[") ); - printf( " Default %s Output", hostInfo->name ); - defaultDisplayed = 1; - } - if( defaultDisplayed ) - printf( " ]\n" ); - - /* print device info fields */ - printf( "Name = %s\n", deviceInfo->name ); - printf( "Host API = %s\n", Pa_GetHostApiInfo( deviceInfo->hostApi )->name ); - printf( "Max inputs = %d", deviceInfo->maxInputChannels ); - printf( ", Max outputs = %d\n", deviceInfo->maxOutputChannels ); - - printf( "Default low input latency = %8.3f\n", deviceInfo->defaultLowInputLatency ); - printf( "Default low output latency = %8.3f\n", deviceInfo->defaultLowOutputLatency ); - printf( "Default high input latency = %8.3f\n", deviceInfo->defaultHighInputLatency ); - printf( "Default high output latency = %8.3f\n", deviceInfo->defaultHighOutputLatency ); - } -} diff --git a/gr-audio-portaudio/src/gri_portaudio.h b/gr-audio-portaudio/src/gri_portaudio.h deleted file mode 100644 index 36191e25a..000000000 --- a/gr-audio-portaudio/src/gri_portaudio.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_PORTAUDIO_H -#define INCLUDED_GRI_PORTAUDIO_H - -#include <stdio.h> -#include <portaudio.h> - -PaDeviceIndex gri_pa_find_device_by_name(const char *name); -void gri_print_devices(); - -#endif /* INCLUDED_GRI_PORTAUDIO_H */ diff --git a/gr-audio-portaudio/src/qa_portaudio.py b/gr-audio-portaudio/src/qa_portaudio.py deleted file mode 100755 index 20731f38d..000000000 --- a/gr-audio-portaudio/src/qa_portaudio.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import audio_portaudio - -class test_audio_portaudio (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have PORTAUDIO drivers, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.run(test_audio_portaudio, "test_audio_portaudio.xml") diff --git a/gr-audio-portaudio/src/run_tests.in b/gr-audio-portaudio/src/run_tests.in deleted file mode 100644 index 0b483dbcf..000000000 --- a/gr-audio-portaudio/src/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-audio-portaudio \ - @abs_top_builddir@/gr-audio-portaudio \ - @srcdir@ diff --git a/gr-audio-windows/.gitignore b/gr-audio-windows/.gitignore deleted file mode 100644 index 53edad32f..000000000 --- a/gr-audio-windows/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/config.cache -/config.h -/config.h.in -/config.log -/config.status -/configure -/depcomp -/install-sh -/libtool -/ltmain.sh -/make.log -/missing -/missing -/mkinstalldirs -/py-compile -/stamp-h -/stamp-h.in -/stamp-h1 -/stamp-h1.in -/stamp-h2.in diff --git a/gr-audio-windows/Makefile.am b/gr-audio-windows/Makefile.am deleted file mode 100644 index b3cecff96..000000000 --- a/gr-audio-windows/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright 2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src diff --git a/gr-audio-windows/README b/gr-audio-windows/README deleted file mode 100644 index 4564c7c7b..000000000 --- a/gr-audio-windows/README +++ /dev/null @@ -1,66 +0,0 @@ - -# Copyright 2001,2005 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -gr-audio-windows will add an audio-sink to gnuradio for windows - -Requirements for building: -make sure you have the following installed: -mingw -libtool (recent version ,built yourself, (if needed remove old libtool macros from /usr/share/aclocal)) -msys -python2.4 (just install the prebuild binary for windows) -boost (built yourself, maybe just unpacking the source somewhere will do, we only use header files) -cppunit (built yourself) -gnuradio-core (built with mingw) - -Building: -sources from cvs: -edit bootstrap to your needs (see below for example) -./bootstrap -./configure /configure --with-cppunit-prefix=/whereiscppunit --with-boost-include-dir=/c/whereisboost PYTHON=/c/Python24/python am_cv_python_pythondir=/c/Python24/Lib/site-packages am_cv_python_pyexecdir=/c/Python24/Lib/site-packages -make -make check -make install - - -If you have multiple versions of aclocal then edit bootstrap and change aclocal and automake to the latest version - -You really need a recent libtool to get this built on mingw. -If you build it with default options it will be placed in /usr/local, but the default libtool will still be in /usr. -This will result in old m4 macros will be used by aclocal. -So if you have a more recent libtool installed in /usr/local add -I /usr/local/share/aclocal to the aclocal commandline in bootstrap. -(And add any other directories with the most recent m4 macros) -You could also uninstall (delete) the old libtool macros in /usr/share/aclocal - -bootstrap example: - -!/bin/sh -rm -fr config.cache autom4te*.cache -aclocal-1.8 -I /usr/local/share/aclocal -I config -autoconf -autoheader -libtoolize --automake -automake-1.8 --add-missing - - -configuration example: -./configure --with-cppunit-prefix=/usr/local --with-boost-include-dir=/d/boost_1_32_0/include/boost-1_32 PYTHON=/d/Python24/python am_cv_python_pythondir=/d/Python24/Lib/site-packages am_cv_python_pyexecdir=/d/Python24/Lib/site-packages - -Martin Dvh, juli 2005 diff --git a/gr-audio-windows/src/.gitignore b/gr-audio-windows/src/.gitignore deleted file mode 100644 index 7f6631569..000000000 --- a/gr-audio-windows/src/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/config.cache -/config.h -/config.h.in -/config.log -/config.status -/configure -/depcomp -/install-sh -/libtool -/ltmain.sh -/make.log -/missing -/missing -/mkinstalldirs -/py-compile -/stamp-h -/stamp-h.in -/stamp-h1 -/stamp-h1.in -/stamp-h2.in -/run_tests -/audio_windows.cc -/audio_windows.py -/gnuradio -/guile -/python diff --git a/gr-audio-windows/src/Makefile.am b/gr-audio-windows/src/Makefile.am deleted file mode 100644 index 1d7b253ec..000000000 --- a/gr-audio-windows/src/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright 2004,2005,2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -TESTS = -DISTCLEANFILES += run_tests -EXTRA_DIST += run_tests.in - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) - -noinst_PYTHON = qa_audio_windows.py - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - audio_windows_sink.h \ - audio_windows_source.h - -lib_LTLIBRARIES = libgnuradio-audio-windows.la - -libgnuradio_audio_windows_la_SOURCES = \ - audio_windows_sink.cc \ - audio_windows_source.cc - -libgnuradio_audio_windows_la_LIBADD = \ - $(GNURADIO_CORE_LA) \ - $(WINAUDIO_LIBS) - -libgnuradio_audio_windows_la_LDFLAGS = \ - $(LIBGNURADIO_CORE_EXTRA_LDFLAGS) \ - $(NO_UNDEFINED) \ - $(LTVERSIONFLAGS) - -################################### -# SWIG interface and library - -TOP_SWIG_IFILES = \ - audio_windows.i - -# Install so that they end up available as: -# import gnuradio.audio_windows -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -audio_windows_pythondir_category = \ - gnuradio - -# additional libraries for linking with the SWIG-generated library -audio_windows_la_swig_libadd = \ - libgnuradio-audio-windows.la - -if PYTHON -TESTS += run_tests -endif diff --git a/gr-audio-windows/src/Makefile.swig.gen b/gr-audio-windows/src/Makefile.swig.gen deleted file mode 100644 index cc21f30bc..000000000 --- a/gr-audio-windows/src/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for audio_windows.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/audio_windows -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/audio_windows -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -audio_windows_pythondir_category ?= gnuradio/audio_windows -audio_windows_pylibdir_category ?= $(audio_windows_pythondir_category) -audio_windows_pythondir = $(pythondir)/$(audio_windows_pythondir_category) -audio_windows_pylibdir = $(pyexecdir)/$(audio_windows_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -audio_windows_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/audio_windows -# FIXME: determince whether these should be installed with gnuradio. -audio_windows_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -audio_windows_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -audio_windows_swiginclude_HEADERS = \ - audio_windows.i \ - $(audio_windows_swiginclude_headers) - -if PYTHON -audio_windows_pylib_LTLIBRARIES = \ - _audio_windows.la - -_audio_windows_la_SOURCES = \ - python/audio_windows.cc \ - $(audio_windows_la_swig_sources) - -audio_windows_python_PYTHON = \ - audio_windows.py \ - $(audio_windows_python) - -_audio_windows_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_windows_la_swig_libadd) - -_audio_windows_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_windows_la_swig_ldflags) - -_audio_windows_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_windows_la_swig_cxxflags) - -python/audio_windows.cc: audio_windows.py -audio_windows.py: audio_windows.i - -# Include the python dependencies for this file --include python/audio_windows.d - -endif # end of if python - -if GUILE - -audio_windows_scmlib_LTLIBRARIES = \ - libguile-gnuradio-audio_windows.la -libguile_gnuradio_audio_windows_la_SOURCES = \ - guile/audio_windows.cc \ - $(audio_windows_la_swig_sources) -nobase_audio_windows_scm_DATA = \ - gnuradio/audio_windows.scm \ - gnuradio/audio_windows-primitive.scm -libguile_gnuradio_audio_windows_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(audio_windows_la_swig_libadd) -libguile_gnuradio_audio_windows_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(audio_windows_la_swig_ldflags) -libguile_gnuradio_audio_windows_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(audio_windows_la_swig_cxxflags) - -guile/audio_windows.cc: gnuradio/audio_windows.scm -gnuradio/audio_windows.scm: audio_windows.i -gnuradio/audio_windows-primitive.scm: gnuradio/audio_windows.scm - -# Include the guile dependencies for this file --include guile/audio_windows.d - -endif # end of GUILE - - diff --git a/gr-audio-windows/src/audio_windows.i b/gr-audio-windows/src/audio_windows.i deleted file mode 100644 index c154eacd6..000000000 --- a/gr-audio-windows/src/audio_windows.i +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "audio_windows_sink.h" -#include "audio_windows_source.h" -%} - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_windows,sink) - -audio_windows_sink_sptr -audio_windows_make_sink (int sampling_freq, - const std::string dev = "" - ) throw (std::runtime_error); - - -class audio_windows_sink : public gr_sync_block { - protected: - audio_windows_sink (int sampling_freq, const std::string device_name = ""); - - public: - ~audio_windows_sink (); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(audio_windows,source) - -audio_windows_source_sptr -audio_windows_make_source (int sampling_freq, - const std::string dev = "" - ) throw (std::runtime_error); - -class audio_windows_source : public gr_sync_block { - protected: - audio_windows_source (int sampling_freq, const std::string device_name = ""); - - public: - ~audio_windows_source (); -}; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-audio_windows" "scm_init_gnuradio_audio_windows_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-audio-windows/src/audio_windows_sink.cc b/gr-audio-windows/src/audio_windows_sink.cc deleted file mode 100644 index a47871954..000000000 --- a/gr-audio-windows/src/audio_windows_sink.cc +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- c++ -*- */ -/* -* Copyright 2004,2010 Free Software Foundation, Inc. -* -* This file is part of GNU Radio -* -* GNU Radio is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3, or (at your option) -* any later version. -* -* GNU Radio 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with GNU Radio; see the file COPYING. If not, write to -* the Free Software Foundation, Inc., 51 Franklin Street, -* Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_windows_sink.h> -#include <gr_io_signature.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> -#include <string> -#include <sstream> - -static const double CHUNK_TIME = 0.1; //0.001; // 100 ms - -// FIXME these should query some kind of user preference - -static std::string -default_device_name () -{ - return "WAVE_MAPPER"; -} - -audio_windows_sink::audio_windows_sink (int sampling_freq, const std::string device_name) - : gr_sync_block ("audio_windows_sink", - gr_make_io_signature (1, 2, sizeof (float)), - gr_make_io_signature (0, 0, 0)), - d_sampling_freq (sampling_freq), - d_device_name (device_name.empty ()? default_device_name () : device_name), - d_fd (-1), d_buffer (0), d_chunk_size (0) -{ - d_wave_write_event = CreateEvent (NULL, FALSE, FALSE, NULL); - if (open_waveout_device () < 0) - { - //fprintf (stderr, "audio_windows_sink:open_waveout_device() failed\n"); - perror ("audio_windows_sink:open_waveout_device( ) failed\n"); - throw - std::runtime_error ("audio_windows_sink:open_waveout_device() failed"); - } - - d_chunk_size = (int) (d_sampling_freq * CHUNK_TIME); - set_output_multiple (d_chunk_size); - - d_buffer = new short[d_chunk_size * 2]; - -} - -audio_windows_sink::~audio_windows_sink () -{ - /* Free the callback Event */ - CloseHandle (d_wave_write_event); - waveOutClose (d_h_waveout); - delete[]d_buffer; -} - -audio_windows_sink_sptr -audio_windows_make_sink (int sampling_freq, const std::string dev) -{ - return gnuradio::get_initial_sptr (new audio_windows_sink (sampling_freq, dev)); -} - - -int -audio_windows_sink::work (int noutput_items, - gr_vector_const_void_star & input_items, - gr_vector_void_star & output_items) -{ - const float *f0, *f1; - bool playtestsound = false; - if (playtestsound) - { - // dummy - - f0 = (const float *) input_items[0]; - - for (int i = 0; i < noutput_items; i += d_chunk_size) - { - for (int j = 0; j < d_chunk_size; j++) - { - d_buffer[2 * j + 0] = (short) (sin (2.0 * 3.1415926535897932384626 * (float) j * 1000.0 / (float) d_sampling_freq) * 8192 + 0); //+32767 - d_buffer[2 * j + 1] = d_buffer[2 * j + 0]; - } - f0 += d_chunk_size; - if (write_waveout - ((HPSTR) d_buffer, 2 * d_chunk_size * sizeof (short)) < 0) - { - fprintf (stderr, "audio_windows_sink: write failed\n"); - perror ("audio_windows_sink: write failed"); - } - } - // break; - } - else - { - switch (input_items.size ()) - { - - case 1: // mono input - - f0 = (const float *) input_items[0]; - - for (int i = 0; i < noutput_items; i += d_chunk_size) - { - for (int j = 0; j < d_chunk_size; j++) - { - d_buffer[2 * j + 0] = (short) (f0[j] * 32767); - d_buffer[2 * j + 1] = (short) (f0[j] * 32767); - } - f0 += d_chunk_size; - if (write_waveout - ((HPSTR) d_buffer, 2 * d_chunk_size * sizeof (short)) < 0) - { - //fprintf (stderr, "audio_windows_sink: write failed\n"); - perror ("audio_windows_sink: write failed"); - } - } - break; - - case 2: // stereo input - - f0 = (const float *) input_items[0]; - f1 = (const float *) input_items[1]; - - for (int i = 0; i < noutput_items; i += d_chunk_size) - { - for (int j = 0; j < d_chunk_size; j++) - { - d_buffer[2 * j + 0] = (short) (f0[j] * 32767); - d_buffer[2 * j + 1] = (short) (f1[j] * 32767); - } - f0 += d_chunk_size; - f1 += d_chunk_size; - if (write_waveout - ((HPSTR) d_buffer, 2 * d_chunk_size * sizeof (short)) < 0) - { - //fprintf (stderr, "audio_windows_sink: write failed\n"); - perror ("audio_windows_sink: write failed"); - } - } - break; - } - } - return noutput_items; -} - -int -audio_windows_sink::string_to_int (const std::string & s) -{ - int i; - std::istringstream (s) >> i; - return i; -} //ToInt() - -int -audio_windows_sink::open_waveout_device (void) -{ - - UINT /*UINT_PTR */ u_device_id; - /** Identifier of the waveform-audio output device to open. It can be either a device identifier or a handle of an open waveform-audio input device. You can use the following flag instead of a device identifier. - * - * Value Meaning - * WAVE_MAPPER The function selects a waveform-audio output device capable of playing the given format. - */ - if (d_device_name.empty () || default_device_name () == d_device_name) - u_device_id = WAVE_MAPPER; - else - u_device_id = (UINT) string_to_int (d_device_name); - // Open a waveform device for output using event callback. - - unsigned long result; - //HWAVEOUT outHandle; - WAVEFORMATEX wave_format; - - /* Initialize the WAVEFORMATEX for 16-bit, 44KHz, stereo */ - wave_format.wFormatTag = WAVE_FORMAT_PCM; - wave_format.nChannels = 2; - wave_format.nSamplesPerSec = d_sampling_freq; //44100; - wave_format.wBitsPerSample = 16; - wave_format.nBlockAlign = - wave_format.nChannels * (wave_format.wBitsPerSample / 8); - wave_format.nAvgBytesPerSec = - wave_format.nSamplesPerSec * wave_format.nBlockAlign; - wave_format.cbSize = 0; - - /* Open the (preferred) Digital Audio Out device. */ - result = waveOutOpen (&d_h_waveout, WAVE_MAPPER, &wave_format, (DWORD_PTR) d_wave_write_event, 0, CALLBACK_EVENT | WAVE_ALLOWSYNC); //|WAVE_FORMAT_DIRECT | CALLBACK_EVENT| WAVE_ALLOWSYNC - if (result) - { - fprintf (stderr, - "audio_windows_sink: Failed to open waveform output device.\n"); - perror ("audio_windows_sink: Failed to open waveform output device."); - //LocalUnlock(hFormat); - //LocalFree(hFormat); - //mmioClose(hmmio, 0); - return -1; - } - - // - // Do not Swallow the "open" event. - // - //WaitForSingleObject(d_wave_write_event, INFINITE); - - // Allocate and lock memory for the header. - - d_h_wave_hdr = GlobalAlloc (GMEM_MOVEABLE | GMEM_SHARE, - (DWORD) sizeof (WAVEHDR)); - if (d_h_wave_hdr == NULL) - { - //GlobalUnlock(hData); - //GlobalFree(hData); - //fprintf (stderr, "audio_windows_sink: Not enough memory for header.\n"); - perror ("audio_windows_sink: Not enough memory for header."); - return -1; - } - - d_lp_wave_hdr = (LPWAVEHDR) GlobalLock (d_h_wave_hdr); - if (d_lp_wave_hdr == NULL) - { - //GlobalUnlock(hData); - //GlobalFree(hData); - //fprintf (stderr, "audio_windows_sink: Failed to lock memory for header.\n"); - perror ("audio_windows_sink: Failed to lock memory for header."); - return -1; - } - //d_lp_wave_hdr->dwFlags = WHDR_DONE; - return 0; -} - -int -audio_windows_sink::write_waveout (HPSTR lp_data, DWORD dw_data_size) -{ - UINT w_result; - int teller = 100; - // After allocation, set up and prepare header. - /*while ((d_lp_wave_hdr->dwFlags & WHDR_DONE)==0 && teller>0) - { - teller--; - Sleep(1); - } */ - // Wait until previous wave write completes (first event is the open event). - WaitForSingleObject (d_wave_write_event, 100); //INFINITE - d_lp_wave_hdr->lpData = lp_data; - d_lp_wave_hdr->dwBufferLength = dw_data_size; - d_lp_wave_hdr->dwFlags = 0L; - /* Clear the WHDR_DONE bit (which the driver set last time that - this WAVEHDR was sent via waveOutWrite and was played). Some - drivers need this to be cleared */ - //d_lp_wave_hdr->dwFlags &= ~WHDR_DONE; - - d_lp_wave_hdr->dwLoops = 0L; - w_result = - waveOutPrepareHeader (d_h_waveout, d_lp_wave_hdr, sizeof (WAVEHDR)); - if (w_result != 0) - { - //GlobalUnlock( hData); - //GlobalFree(hData); - //fprintf (stderr, "audio_windows_sink: Failed to waveOutPrepareHeader. error %i\n",w_result); - perror ("audio_windows_sink: Failed to waveOutPrepareHeader"); - } - // Now the data block can be sent to the output device. The - // waveOutWrite function returns immediately and waveform - // data is sent to the output device in the background. - //while (! readyforplayback) Sleep(1); - //readyforplayback=false; - // - // - - w_result = waveOutWrite (d_h_waveout, d_lp_wave_hdr, sizeof (WAVEHDR)); - if (w_result != 0) - { - //GlobalUnlock( hData); - //GlobalFree(hData); - //fprintf (stderr, "audio_windows_sink: Failed to write block to device.error %i\n",w_result); - perror ("audio_windows_sink: Failed to write block to device"); - switch (w_result) - { - case MMSYSERR_INVALHANDLE: - fprintf (stderr, "Specified device handle is invalid. \n"); - break; - case MMSYSERR_NODRIVER: - fprintf (stderr, " No device driver is present. \n"); - break; - case MMSYSERR_NOMEM: - fprintf (stderr, " Unable to allocate or lock memory. \n"); - break; - case WAVERR_UNPREPARED: - fprintf (stderr, - " The data block pointed to by the pwh parameter hasn't been prepared. \n"); - break; - default: - fprintf (stderr, "Unknown error %i\n", w_result); - } - waveOutUnprepareHeader (d_h_waveout, d_lp_wave_hdr, sizeof (WAVEHDR)); - return -1; - } - // WaitForSingleObject(d_wave_write_event, INFINITE); - return 0; -} diff --git a/gr-audio-windows/src/audio_windows_sink.h b/gr-audio-windows/src/audio_windows_sink.h deleted file mode 100644 index 2212ecf06..000000000 --- a/gr-audio-windows/src/audio_windows_sink.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_WINDOWS_SINK_H -#define INCLUDED_AUDIO_WINDOWS_SINK_H - -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX // stops windef.h defining max/min under cygwin - -#include <windows.h> -#include <mmsystem.h> - -#include <gr_sync_block.h> -#include <string> - - -class audio_windows_sink; -typedef boost::shared_ptr <audio_windows_sink> audio_windows_sink_sptr; - -audio_windows_sink_sptr -audio_windows_make_sink (int sampling_freq, const std::string dev = ""); - -/*! - * \brief audio sink using winmm mmsystem (win32 only) - * - * input signature is one or two streams of floats. - * Input samples must be in the range [-1,1]. - */ - -class audio_windows_sink : public gr_sync_block -{ - friend - audio_windows_sink_sptr - audio_windows_make_sink (int sampling_freq, const std::string device_name); - - int d_sampling_freq; - std::string d_device_name; - int d_fd; - short *d_buffer; - int d_chunk_size; - HWAVEOUT d_h_waveout; - HGLOBAL d_h_wave_hdr; - LPWAVEHDR d_lp_wave_hdr; - HANDLE d_wave_write_event; - -protected: - int - string_to_int (const std::string & s); - audio_windows_sink (int sampling_freq, const std::string device_name = ""); - int - open_waveout_device (void); - int - write_waveout (HPSTR lp_data, DWORD dw_data_size); - -public: - ~audio_windows_sink (); - - int - work (int noutput_items, - gr_vector_const_void_star & input_items, - gr_vector_void_star & output_items); -}; - -#endif /* INCLUDED_AUDIO_WINDOWS_SINK_H */ diff --git a/gr-audio-windows/src/audio_windows_source.cc b/gr-audio-windows/src/audio_windows_source.cc deleted file mode 100644 index a88923afd..000000000 --- a/gr-audio-windows/src/audio_windows_source.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <audio_windows_source.h> -#include <gr_io_signature.h> -//include <sys/soundcard.h> -//include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <iostream> -#include <stdexcept> - - -static const double CHUNK_TIME = 0.005; // 5 ms - -// FIXME these should query some kind of user preference - -static std::string -default_device_name () -{ - return "/dev/dsp"; -} - -audio_windows_source::audio_windows_source (int sampling_freq, const std::string device_name) - : gr_sync_block ("audio_windows_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 2, sizeof (float))), - d_sampling_freq (sampling_freq), - d_device_name (device_name.empty ()? default_device_name () : device_name), - d_fd (-1), d_buffer (0), d_chunk_size (0) -{ - //FIXME TODO implement me -#if 0 - if ((d_fd = open (d_device_name.c_str (), O_RDONLY)) < 0) - { - fprintf (stderr, "audio_windows_source: "); - perror (d_device_name.c_str ()); - throw - std::runtime_error ("audio_windows_source"); - } - - d_chunk_size = (int) (d_sampling_freq * CHUNK_TIME); - set_output_multiple (d_chunk_size); - - d_buffer = new short[d_chunk_size * 2]; - - int format = AFMT_S16_NE; - int orig_format = format; - if (ioctl (d_fd, SNDCTL_DSP_SETFMT, &format) < 0) - { - std:: - cerr << "audio_windows_source: " << d_device_name << - " ioctl failed\n"; - perror (d_device_name.c_str ()); - throw - std::runtime_error ("audio_windows_source"); - } - - if (format != orig_format) - { - fprintf (stderr, "audio_windows_source: unable to support format %d\n", - orig_format); - fprintf (stderr, " card requested %d instead.\n", format); - } - - // set to stereo no matter what. Some hardware only does stereo - int channels = 2; - if (ioctl (d_fd, SNDCTL_DSP_CHANNELS, &channels) < 0 || channels != 2) - { - perror ("audio_windows_source: could not set STEREO mode"); - throw - std::runtime_error ("audio_windows_source"); - } - - // set sampling freq - int sf = sampling_freq; - if (ioctl (d_fd, SNDCTL_DSP_SPEED, &sf) < 0) - { - std::cerr << "audio_windows_source: " - << d_device_name << ": invalid sampling_freq " - << sampling_freq << "\n"; - sampling_freq = 8000; - if (ioctl (d_fd, SNDCTL_DSP_SPEED, &sf) < 0) - { - std:: - cerr << - "audio_windows_source: failed to set sampling_freq to 8000\n"; - throw - std::runtime_error ("audio_windows_source"); - } - } -#endif -} - -audio_windows_source::~audio_windows_source () -{ - /*close (d_fd); - delete [] d_buffer; - */ -} - -audio_windows_source_sptr -audio_windows_make_source (int sampling_freq, const std::string dev) -{ - return gnuradio::get_initial_sptr (new audio_windows_source (sampling_freq, dev)); -} - - -int -audio_windows_source::work (int noutput_items, - gr_vector_const_void_star & input_items, - gr_vector_void_star & output_items) -{ - //FIXME TODO implement me -#if 0 - float *f0 = (float *) output_items[0]; - float *f1 = (float *) output_items[1]; // will be invalid if this is mono output - - const int shorts_per_item = 2; // L + R - const int bytes_per_item = shorts_per_item * sizeof (short); - - // To minimize latency, never return more than CHUNK_TIME - // worth of samples per call to work. - // FIXME, we need an API to set this value - - noutput_items = std::min (noutput_items, d_chunk_size); - - int base = 0; - int ntogo = noutput_items; - - while (ntogo > 0) - { - int nbytes = std::min (ntogo, d_chunk_size) * bytes_per_item; - int result_nbytes = read (d_fd, d_buffer, nbytes); - - if (result_nbytes < 0) - { - perror ("audio_windows_source"); - return -1; // say we're done - } - - if ((result_nbytes & (bytes_per_item - 1)) != 0) - { - fprintf (stderr, "audio_windows_source: internal error.\n"); - throw std::runtime_error ("internal error"); - } - - int result_nitems = result_nbytes / bytes_per_item; - - // now unpack samples into output streams - - switch (output_items.size ()) - { - case 1: // mono output - for (int i = 0; i < result_nitems; i++) - { - f0[base + i] = d_buffer[2 * i + 0] * (1.0 / 32767); - } - break; - - case 2: // stereo output - for (int i = 0; i < result_nitems; i++) - { - f0[base + i] = d_buffer[2 * i + 0] * (1.0 / 32767); - f1[base + i] = d_buffer[2 * i + 1] * (1.0 / 32767); - } - break; - - default: - assert (0); - } - - ntogo -= result_nitems; - base += result_nitems; - } - - return noutput_items - ntogo; -#endif - return -1; // EOF -} diff --git a/gr-audio-windows/src/audio_windows_source.h b/gr-audio-windows/src/audio_windows_source.h deleted file mode 100644 index caeda36b8..000000000 --- a/gr-audio-windows/src/audio_windows_source.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_AUDIO_WINDOWS_SOURCE_H -#define INCLUDED_AUDIO_WINDOWS_SOURCE_H - -#include <gr_sync_block.h> -#include <string> - - -class audio_windows_source; -typedef boost::shared_ptr <audio_windows_source> audio_windows_source_sptr; - -audio_windows_source_sptr -audio_windows_make_source (int sampling_freq, const std::string dev = ""); - -/*! - * \brief audio source using winmm mmsystem (win32 only) - * - * Output signature is one or two streams of floats. - * Output samples will be in the range [-1,1]. - */ - -class audio_windows_source : public gr_sync_block -{ - friend - audio_windows_source_sptr - audio_windows_make_source (int sampling_freq, - const std::string device_name); - - int d_sampling_freq; - std::string d_device_name; - int d_fd; - short *d_buffer; - int d_chunk_size; - -protected: - audio_windows_source (int sampling_freq, const std::string device_name = ""); - -public: - ~audio_windows_source (); - - int - work (int noutput_items, - gr_vector_const_void_star & input_items, - gr_vector_void_star & output_items); -}; - -#endif /* INCLUDED_AUDIO_WINDOWS_SOURCE_H */ diff --git a/gr-audio-windows/src/qa_audio_windows.py b/gr-audio-windows/src/qa_audio_windows.py deleted file mode 100755 index 0d14535a6..000000000 --- a/gr-audio-windows/src/qa_audio_windows.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import audio_windows - -class qa_oss (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have audio drivers, soundcard, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.main () diff --git a/gr-audio-windows/src/run_tests.in b/gr-audio-windows/src/run_tests.in deleted file mode 100755 index f7de663ba..000000000 --- a/gr-audio-windows/src/run_tests.in +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-audio-windows \ - @abs_top_builddir@/gr-audio-windows \ - @srcdir@ |