diff options
-rw-r--r-- | gr-audio/Makefile.am | 5 | ||||
-rw-r--r-- | gr-audio/include/Makefile.am | 5 | ||||
-rw-r--r-- | gr-audio/include/gr_audio_api.h | 31 | ||||
-rw-r--r-- | gr-audio/include/gr_audio_sink.h | 41 | ||||
-rw-r--r-- | gr-audio/include/gr_audio_source.h | 41 | ||||
-rw-r--r-- | gr-audio/lib/Makefile.am | 18 | ||||
-rw-r--r-- | gr-audio/lib/gr_audio_registry.cc | 57 | ||||
-rw-r--r-- | gr-audio/lib/gr_audio_registry.h | 39 |
8 files changed, 237 insertions, 0 deletions
diff --git a/gr-audio/Makefile.am b/gr-audio/Makefile.am index 092d9b980..65cb397ca 100644 --- a/gr-audio/Makefile.am +++ b/gr-audio/Makefile.am @@ -27,3 +27,8 @@ if PYTHON SUBDIRS += swig endif +pkgconfigdir = $(libdir)/pkgconfig +dist_pkgconfig_DATA = gnuradio-audio.pc + +etcdir = $(gr_prefsdir) +dist_etc_DATA = gr-audio.conf diff --git a/gr-audio/include/Makefile.am b/gr-audio/include/Makefile.am index d5b319c36..a4db27d08 100644 --- a/gr-audio/include/Makefile.am +++ b/gr-audio/include/Makefile.am @@ -20,3 +20,8 @@ # include $(top_srcdir)/Makefile.common + +grinclude_HEADERS = \ + gr_audio_api.h \ + gr_audio_source.h \ + gr_audio_sink.h diff --git a/gr-audio/include/gr_audio_api.h b/gr-audio/include/gr_audio_api.h new file mode 100644 index 000000000..b21819bab --- /dev/null +++ b/gr-audio/include/gr_audio_api.h @@ -0,0 +1,31 @@ +/* + * Copyright 2011 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_GR_AUDIO_API_H +#define INCLUDED_GR_AUDIO_API_H + +#ifdef gnuradio_audio_EXPORTS +# define GR_AUDIO_API //FIXME needs attributes defines +#else +# define GR_AUDIO_API //FIXME needs attributes defines +#endif + +#endif /* INCLUDED_GR_AUDIO_API_H */ diff --git a/gr-audio/include/gr_audio_sink.h b/gr-audio/include/gr_audio_sink.h new file mode 100644 index 000000000..37ea6e7ba --- /dev/null +++ b/gr-audio/include/gr_audio_sink.h @@ -0,0 +1,41 @@ +/* + * Copyright 2011 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_GR_AUDIO_SINK_H +#define INCLUDED_GR_AUDIO_SINK_H + +#include <gr_audio_api.h> +#include <gr_sync_block.h> + +class GR_AUDIO_API gr_audio_sink : public gr_sync_block{ +public: + typedef boost::shared_ptr<gr_audio_sink> sptr; + + +}; + +GR_AUDIO_API gr_audio_sink::sptr gr_make_audio_sink( + int sampling_rate, + const std::string device_name = "", + bool ok_to_block = true +); + +#endif /* INCLUDED_GR_AUDIO_SINK_H */ diff --git a/gr-audio/include/gr_audio_source.h b/gr-audio/include/gr_audio_source.h new file mode 100644 index 000000000..1b4df9e2f --- /dev/null +++ b/gr-audio/include/gr_audio_source.h @@ -0,0 +1,41 @@ +/* + * Copyright 2011 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_GR_AUDIO_SOURCE_H +#define INCLUDED_GR_AUDIO_SOURCE_H + +#include <gr_audio_api.h> +#include <gr_sync_block.h> + +class GR_AUDIO_API gr_audio_source : public gr_sync_block{ +public: + typedef boost::shared_ptr<gr_audio_source> sptr; + + +}; + +GR_AUDIO_API gr_audio_source::sptr gr_make_audio_source( + int sampling_rate, + const std::string device_name = "", + bool ok_to_block = true +); + +#endif /* INCLUDED_GR_AUDIO_SOURCE_H */ diff --git a/gr-audio/lib/Makefile.am b/gr-audio/lib/Makefile.am index d5b319c36..8e5915ba2 100644 --- a/gr-audio/lib/Makefile.am +++ b/gr-audio/lib/Makefile.am @@ -20,3 +20,21 @@ # include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = \ + $(STD_DEFINES_AND_INCLUDES) \ + $(WITH_INCLUDES) \ + -I$(abs_top_srcdir)/gr-audio/include \ + -Dgnuradio_audio_EXPORTS + +lib_LTLIBRARIES = libgnuradio-audio.la + +libgnuradio_audio_la_SOURCES = \ + gr_audio_registry.cc + +libgnuradio_audio_la_LIBADD = \ + $(GNURADIO_CORE_LA) + +libgnuradio_audio_la_LDFLAGS = $(LTVERSIONFLAGS) + +noinst_HEADERS = gr_audio_registry.h diff --git a/gr-audio/lib/gr_audio_registry.cc b/gr-audio/lib/gr_audio_registry.cc new file mode 100644 index 000000000..e40d1ff0f --- /dev/null +++ b/gr-audio/lib/gr_audio_registry.cc @@ -0,0 +1,57 @@ +/* + * Copyright 2011 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 "gr_audio_registry.h" +#include <stdexcept> +#include <vector> + +static std::vector<gr_audio_registry_entry> &get_registry(void){ + static std::vector<gr_audio_registry_entry> _registry; + return _registry; +} + +void gr_audio_register(const gr_audio_registry_entry &entry){ + get_registry().push_back(entry); +} + +gr_audio_source::sptr gr_make_audio_source( + int sampling_rate, + const std::string device_name, + bool ok_to_block +){ + if (get_registry().empty()){ + throw std::runtime_error("no available audio factories"); + } + //TODO we may prefer to use a specific entry in the registry + return get_registry().front().source(sampling_rate, device_name, ok_to_block); +} + +gr_audio_sink::sptr gr_make_audio_sink( + int sampling_rate, + const std::string device_name, + bool ok_to_block +){ + if (get_registry().empty()){ + throw std::runtime_error("no available audio factories"); + } + //TODO we may prefer to use a specific entry in the registry + return get_registry().front().sink(sampling_rate, device_name, ok_to_block); +} diff --git a/gr-audio/lib/gr_audio_registry.h b/gr-audio/lib/gr_audio_registry.h new file mode 100644 index 000000000..4b43a408b --- /dev/null +++ b/gr-audio/lib/gr_audio_registry.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011 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_GR_AUDIO_REGISTRY_H +#define INCLUDED_GR_AUDIO_REGISTRY_H + +#include <gr_audio_sink.h> +#include <gr_audio_source.h> +#include <string> + +struct gr_audio_registry_entry{ + typedef gr_audio_source::sptr(*source_factory_t)(int, const std::string &, bool); + typedef gr_audio_sink::sptr(*sink_factory_t)(int, const std::string &, bool); + std::string name; + source_factory_t source; + sink_factory_t sink; +}; + +void gr_audio_register(const gr_audio_registry_entry &entry); + +#endif /* INCLUDED_GR_AUDIO_REGISTRY_H */ |