summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-audio/doc/audio.dox56
-rw-r--r--gr-audio/lib/CMakeLists.txt24
-rw-r--r--gr-audio/lib/alsa/alsa_sink.cc34
-rw-r--r--gr-audio/lib/alsa/alsa_source.cc29
-rw-r--r--gr-audio/lib/audio_registry.cc105
-rw-r--r--gr-audio/lib/audio_registry.h83
-rw-r--r--gr-audio/lib/jack/jack_sink.cc22
-rw-r--r--gr-audio/lib/jack/jack_source.cc22
-rw-r--r--gr-audio/lib/oss/oss_sink.cc7
-rw-r--r--gr-audio/lib/oss/oss_source.cc7
-rw-r--r--gr-audio/lib/osx/osx_sink.cc8
-rw-r--r--gr-audio/lib/osx/osx_source.cc8
-rw-r--r--gr-audio/lib/portaudio/portaudio_sink.cc9
-rw-r--r--gr-audio/lib/portaudio/portaudio_source.cc9
-rw-r--r--gr-audio/lib/windows/windows_sink.cc9
-rw-r--r--gr-audio/lib/windows/windows_source.cc9
16 files changed, 316 insertions, 125 deletions
diff --git a/gr-audio/doc/audio.dox b/gr-audio/doc/audio.dox
index fd88b9e563..6b3bbd9ddf 100644
--- a/gr-audio/doc/audio.dox
+++ b/gr-audio/doc/audio.dox
@@ -61,4 +61,60 @@ its use would look like:
audio_source = audio.source(int(audio_rate), audio_input)
\endcode
+
+\section audio_adding Adding a New Audio Machine
+
+There may come a time when we need to define a new audio machine type
+besides those currently supported. To do this, we have to follow a
+simple pattern to add it to the list of potential machines GNU Radio
+can use.
+
+1. Add a new directory in gr-audio/lib for the new machine name, like
+the alsa, oss, etc. that are already there.
+
+2. Follow the pattern of the other machines to create the class
+structure for both a source and sink implementation for the machine.
+
+3. Make sure to add the factory function for both the new source and
+sink classes. Like in the ALSA sink case, we have:
+
+\code
+ sink::sptr
+ alsa_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
+ {
+ return sink::sptr
+ (new alsa_sink(sampling_rate, device_name, ok_to_block));
+ }
+\endcode
+
+4. Add the new source and sink factory functions to the audio
+registration list in gr-audio/lib/audio_registry.cc and
+audio_registry.h files. Select the appropriate registry priority, HIGH
+if you want this to be the default when using 'auto'. For Linux audio
+systems, we generally want to default to ALSA, fall back on OSS, but
+have other machine interfaces defined as MED priority. For example, in
+the .cc file for ALSA, OSS, and PortAudio:
+
+\code
+ #ifdef ALSA_FOUND
+ d_registry.push_back(register_source(REG_PRIO_HIGH, "alsa", alsa_source_fcn));
+ #endif /* ALSA_FOUND */
+
+ #ifdef OSS_FOUND
+ d_registry.push_back(register_source(REG_PRIO_LOW, "oss", oss_source_fcn));
+ #endif /* OSS_FOUND */
+
+ #ifdef PORTAUDIO_FOUND
+ d_registry.push_back(register_source(REG_PRIO_MED, "portaudio", portaudio_source_fcn));
+ #endif /* PORTAUDIO_FOUND */
+\endcode
+
+
+5. Follow the examples in the gr-audio/lib/CMakeLists.txt file for the
+different machine types to add the new one, including the
+add_definitions to provide the new YOURMACH_FOUND used in the
+audio_registry files.
+
*/
diff --git a/gr-audio/lib/CMakeLists.txt b/gr-audio/lib/CMakeLists.txt
index d50e547c72..81a497588e 100644
--- a/gr-audio/lib/CMakeLists.txt
+++ b/gr-audio/lib/CMakeLists.txt
@@ -17,6 +17,8 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
+include(GrComponent)
+
########################################################################
# Setup the include and linker paths
########################################################################
@@ -47,6 +49,9 @@ find_package(ALSA)
if(ALSA_FOUND)
+ add_definitions(-DALSA_FOUND)
+ GR_APPEND_SUBCOMPONENT("alsa")
+
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/alsa)
include_directories(${ALSA_INCLUDE_DIRS})
list(APPEND gr_audio_libs ${ALSA_LIBRARIES})
@@ -66,6 +71,9 @@ find_package(OSS)
if(OSS_FOUND)
+ add_definitions(-DOSS_FOUND)
+ GR_APPEND_SUBCOMPONENT("oss")
+
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/oss)
include_directories(${OSS_INCLUDE_DIRS})
list(APPEND gr_audio_sources
@@ -84,6 +92,9 @@ find_package(Jack)
if(JACK_FOUND)
+ add_definitions(-DJACK_FOUND)
+ GR_APPEND_SUBCOMPONENT("jack")
+
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/jack)
include_directories(${JACK_INCLUDE_DIRS})
list(APPEND gr_audio_libs ${JACK_LIBRARIES})
@@ -106,6 +117,9 @@ CHECK_INCLUDE_FILE_CXX(AudioToolbox/AudioToolbox.h AUDIO_TOOLBOX_H)
if(AUDIO_UNIT_H AND AUDIO_TOOLBOX_H)
+ add_definitions(-DOSX_FOUND)
+ GR_APPEND_SUBCOMPONENT("osx")
+
set(OSX_AUDIO_VALID 1 CACHE INTERNAL "OSX Audio is valid")
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/osx)
@@ -134,7 +148,10 @@ endif(AUDIO_UNIT_H AND AUDIO_TOOLBOX_H)
########################################################################
find_package(Portaudio)
-if(PORTAUDIO_FOUND)
+if(PORTAUDIO2_FOUND)
+
+ add_definitions(-DPORTAUDIO_FOUND)
+ GR_APPEND_SUBCOMPONENT("portaudio")
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/portaudio)
include_directories(${PORTAUDIO_INCLUDE_DIRS})
@@ -147,13 +164,16 @@ if(PORTAUDIO_FOUND)
)
list(APPEND gr_audio_confs ${CMAKE_CURRENT_SOURCE_DIR}/portaudio/gr-audio-portaudio.conf)
-endif(PORTAUDIO_FOUND)
+endif(PORTAUDIO2_FOUND)
########################################################################
## Windows Support
########################################################################
if(WIN32)
+ add_definitions(-DWIN32_FOUND)
+ GR_APPEND_SUBCOMPONENT("windows")
+
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/windows)
list(APPEND gr_audio_libs winmm.lib)
list(APPEND gr_audio_sources
diff --git a/gr-audio/lib/alsa/alsa_sink.cc b/gr-audio/lib/alsa/alsa_sink.cc
index a9224733aa..cfb247520f 100644
--- a/gr-audio/lib/alsa/alsa_sink.cc
+++ b/gr-audio/lib/alsa/alsa_sink.cc
@@ -36,15 +36,16 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SINK(REG_PRIO_HIGH, alsa)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ sink::sptr
+ alsa_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return sink::sptr
(new alsa_sink(sampling_rate, device_name, ok_to_block));
}
- static bool CHATTY_DEBUG = false;
+ static bool CHATTY_DEBUG = true;
static snd_pcm_format_t acceptable_formats[] = {
// these are in our preferred order...
@@ -111,8 +112,8 @@ namespace gr {
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));
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: %2%") \
+ % (d_device_name) % (snd_strerror(error)));
throw std::runtime_error("audio_alsa_sink");
}
@@ -171,9 +172,9 @@ namespace gr {
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);
+ GR_LOG_INFO(d_logger, boost::format("[%1%]: unable to support sampling rate %2%\n\tCard requested %3% instead.") \
+ % snd_pcm_name(d_pcm_handle) % orig_sampling_rate \
+ % d_sampling_rate);
}
/*
@@ -185,8 +186,6 @@ namespace gr {
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);
@@ -274,10 +273,11 @@ namespace gr {
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));
+ if(CHATTY_DEBUG) {
+ GR_LOG_DEBUG(d_logger, boost::format("[%1%]: sample resolution = %d bits") \
+ % snd_pcm_name(d_pcm_handle) \
+ % snd_pcm_hw_params_get_sbits(d_hw_params));
+ }
switch(d_format) {
case SND_PCM_FORMAT_S16:
@@ -533,8 +533,8 @@ namespace gr {
void
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));
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: %2%: %3%") \
+ % snd_pcm_name(d_pcm_handle) % msg % snd_strerror(err));
}
void
diff --git a/gr-audio/lib/alsa/alsa_source.cc b/gr-audio/lib/alsa/alsa_source.cc
index b6103c3c51..92a7bc549f 100644
--- a/gr-audio/lib/alsa/alsa_source.cc
+++ b/gr-audio/lib/alsa/alsa_source.cc
@@ -36,9 +36,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SOURCE(REG_PRIO_HIGH, alsa)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ source::sptr
+ alsa_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return source::sptr
(new alsa_source(sampling_rate, device_name, ok_to_block));
@@ -106,8 +107,8 @@ namespace gr {
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));
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: %2%") \
+ % (d_device_name) % (snd_strerror(error)));
throw std::runtime_error("audio_alsa_source");
}
@@ -168,9 +169,9 @@ namespace gr {
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);
+ GR_LOG_INFO(d_logger, boost::format("[%1%]: unable to support sampling rate %2%\n\tCard requested %3% instead.") \
+ % snd_pcm_name(d_pcm_handle) % orig_sampling_rate \
+ % d_sampling_rate);
}
/*
@@ -182,8 +183,6 @@ namespace gr {
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);
@@ -253,9 +252,9 @@ namespace gr {
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));
+ GR_LOG_DEBUG(d_logger, boost::format("[%1%]: sample resolution = %d bits") \
+ % snd_pcm_name(d_pcm_handle) \
+ % snd_pcm_hw_params_get_sbits(d_hw_params));
}
switch(d_format) {
@@ -499,8 +498,8 @@ namespace gr {
void
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));
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: %2%: %3%") \
+ % snd_pcm_name(d_pcm_handle) % msg % snd_strerror(err));
}
void
diff --git a/gr-audio/lib/audio_registry.cc b/gr-audio/lib/audio_registry.cc
index 98848a0f89..ece723f287 100644
--- a/gr-audio/lib/audio_registry.cc
+++ b/gr-audio/lib/audio_registry.cc
@@ -1,5 +1,5 @@
/*
- * Copyright 2011,2013 Free Software Foundation, Inc.
+ * Copyright 2011,2013-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,6 +22,7 @@
#include "audio_registry.h"
#include <boost/foreach.hpp>
#include <gnuradio/prefs.h>
+#include <gnuradio/logger.h>
#include <stdexcept>
#include <vector>
#include <iostream>
@@ -33,35 +34,84 @@ namespace gr {
* Create registries
**********************************************************************/
- struct source_entry_t {
- reg_prio_type prio;
- std::string arch;
- source_factory_t source;
- };
-
- static std::vector<source_entry_t> &get_source_registry(void)
+ static std::vector<source_entry_t> &
+ get_source_registry(void)
{
+ static bool src_reg = false;
static std::vector<source_entry_t> d_registry;
+
+ if(!src_reg) {
+#ifdef ALSA_FOUND
+ d_registry.push_back(register_source(REG_PRIO_HIGH, "alsa", alsa_source_fcn));
+#endif /* ALSA_FOUND */
+
+#ifdef OSS_FOUND
+ d_registry.push_back(register_source(REG_PRIO_LOW, "oss", oss_source_fcn));
+#endif /* OSS_FOUND */
+
+#ifdef PORTAUDIO_FOUND
+ d_registry.push_back(register_source(REG_PRIO_MED, "portaudio", portaudio_source_fcn));
+#endif /* PORTAUDIO_FOUND */
+
+#ifdef JACK_FOUND
+ d_registry.push_back(register_source(REG_PRIO_MED, "jack", jack_source_fcn));
+#endif /* JACK_FOUND */
+
+#ifdef OSX_FOUND
+ d_registry.push_back(register_source(REG_PRIO_HIGH, "osx", osx_source_fcn));
+#endif /* OSX_FOUND */
+
+#ifdef WIN32_FOUND
+ d_registry.push_back(register_source(REG_PRIO_HIGH, "windows", windows_source_fcn));
+#endif /* WIN32_FOUND */
+
+ src_reg = true;
+ }
+
return d_registry;
}
- struct sink_entry_t
- {
- reg_prio_type prio;
- std::string arch;
- sink_factory_t sink;
- };
-
- static std::vector<sink_entry_t> &get_sink_registry(void)
+ static std::vector<sink_entry_t> &
+ get_sink_registry(void)
{
+ static bool snk_reg = false;
static std::vector<sink_entry_t> d_registry;
+
+ if(!snk_reg) {
+#if ALSA_FOUND
+ d_registry.push_back(register_sink(REG_PRIO_HIGH, "alsa", alsa_sink_fcn));
+#endif /* ALSA_FOUND */
+
+#if OSS_FOUND
+ d_registry.push_back(register_sink(REG_PRIO_LOW, "oss", oss_sink_fcn));
+#endif /* OSS_FOUND */
+
+#if PORTAUDIO_FOUND
+ d_registry.push_back(register_sink(REG_PRIO_MED, "portaudio", portaudio_sink_fcn));
+#endif /* PORTAUDIO_FOUND */
+
+#if JACK_FOUND
+ d_registry.push_back(register_sink(REG_PRIO_MED, "jack", jack_sink_fcn));
+#endif /* JACK_FOUND */
+
+#ifdef OSX_FOUND
+ d_registry.push_back(register_sink(REG_PRIO_HIGH, "osx", osx_sink_fcn));
+#endif /* OSX_FOUND */
+
+#ifdef WIN32_FOUND
+ d_registry.push_back(register_sink(REG_PRIO_HIGH, "windows", windows_sink_fcn));
+#endif /* WIN32_FOUND */
+
+ snk_reg = true;
+ }
+
return d_registry;
}
/***********************************************************************
* Register functions
**********************************************************************/
- void
+ source_entry_t
register_source(reg_prio_type prio,
const std::string &arch,
source_factory_t source)
@@ -70,18 +120,19 @@ namespace gr {
entry.prio = prio;
entry.arch = arch;
entry.source = source;
- get_source_registry().push_back(entry);
+ return entry;
}
- void register_sink(reg_prio_type prio,
- const std::string &arch,
- sink_factory_t sink)
+ sink_entry_t
+ register_sink(reg_prio_type prio,
+ const std::string &arch,
+ sink_factory_t sink)
{
sink_entry_t entry;
entry.prio = prio;
entry.arch = arch;
entry.sink = sink;
- get_sink_registry().push_back(entry);
+ return entry;
}
/***********************************************************************
@@ -106,6 +157,9 @@ namespace gr {
const std::string device_name,
bool ok_to_block)
{
+ gr::logger_ptr logger, debug_logger;
+ configure_default_loggers(logger, debug_logger, "audio source");
+
if(get_source_registry().empty()) {
throw std::runtime_error("no available audio source factories");
}
@@ -121,7 +175,7 @@ namespace gr {
return e.source(sampling_rate, device_name, ok_to_block);
}
- //std::cout << "Audio source arch: " << entry.name << std::endl;
+ GR_LOG_INFO(logger, boost::format("Audio source arch: %1%") % (entry.arch));
return entry.source(sampling_rate, device_name, ok_to_block);
}
@@ -130,6 +184,9 @@ namespace gr {
const std::string device_name,
bool ok_to_block)
{
+ gr::logger_ptr logger, debug_logger;
+ configure_default_loggers(logger, debug_logger, "audio source");
+
if(get_sink_registry().empty()) {
throw std::runtime_error("no available audio sink factories");
}
@@ -146,7 +203,7 @@ namespace gr {
}
do_arch_warning(arch);
- //std::cout << "Audio sink arch: " << entry.name << std::endl;
+ GR_LOG_INFO(logger, boost::format("Audio sink arch: %1%") % (entry.arch));
return entry.sink(sampling_rate, device_name, ok_to_block);
}
diff --git a/gr-audio/lib/audio_registry.h b/gr-audio/lib/audio_registry.h
index 6caf5c4943..d18d5c5387 100644
--- a/gr-audio/lib/audio_registry.h
+++ b/gr-audio/lib/audio_registry.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -38,24 +38,77 @@ namespace gr {
REG_PRIO_HIGH = 300
};
- void register_source(reg_prio_type prio, const std::string &arch,
- source_factory_t source);
- void register_sink(reg_prio_type prio, const std::string &arch,
+ struct source_entry_t {
+ reg_prio_type prio;
+ std::string arch;
+ source_factory_t source;
+ };
+
+ struct sink_entry_t
+ {
+ reg_prio_type prio;
+ std::string arch;
+ sink_factory_t sink;
+ };
+
+ source_entry_t register_source(reg_prio_type prio, const std::string &arch,
+ source_factory_t source);
+ sink_entry_t register_sink(reg_prio_type prio, const std::string &arch,
sink_factory_t sink);
-#define AUDIO_REGISTER_FIXTURE(x) static struct x{x();}x;x::x()
+#ifdef ALSA_FOUND
+ source::sptr alsa_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+ sink::sptr alsa_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+#endif /* ALSA_FOUND */
+
+#ifdef OSS_FOUND
+ source::sptr oss_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+ sink::sptr oss_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+#endif /* OSS_FOUND */
+
+#ifdef PORTAUDIO_FOUND
+ source::sptr portaudio_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+ sink::sptr portaudio_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+#endif /* PORTAUDIO_FOUND */
+
+#ifdef JACK_FOUND
+ source::sptr jack_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+ sink::sptr jack_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+#endif /* JACK_FOUND */
-#define AUDIO_REGISTER_SOURCE(prio, arch) \
- static source::sptr arch##_source_fcn(int, const std::string &, bool); \
- AUDIO_REGISTER_FIXTURE(arch##_source_reg) { \
- register_source(prio, #arch, &arch##_source_fcn); \
- } static source::sptr arch##_source_fcn
+#ifdef OSX_FOUND
+ source::sptr osx_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+ sink::sptr osx_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+#endif /* OSX_FOUND */
-#define AUDIO_REGISTER_SINK(prio, arch) \
- static sink::sptr arch##_sink_fcn(int, const std::string &, bool); \
- AUDIO_REGISTER_FIXTURE(arch##_sink_reg) { \
- register_sink(prio, #arch, &arch##_sink_fcn); \
- } static sink::sptr arch##_sink_fcn
+#ifdef WIN32_FOUND
+ source::sptr windows_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+ sink::sptr windows_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block);
+#endif /* WIN32_FOUND */
} /* namespace audio */
} /* namespace gr */
diff --git a/gr-audio/lib/jack/jack_sink.cc b/gr-audio/lib/jack/jack_sink.cc
index 0da074290f..6261545028 100644
--- a/gr-audio/lib/jack/jack_sink.cc
+++ b/gr-audio/lib/jack/jack_sink.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005-2011,2013 Free Software Foundation, Inc.
+ * Copyright 2005-2011,2013-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -40,9 +40,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SINK(REG_PRIO_MED, jack)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ sink::sptr
+ jack_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return sink::sptr
(new jack_sink(sampling_rate, device_name, ok_to_block));
@@ -125,8 +126,8 @@ namespace gr {
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());
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: jack server not running?") \
+ % d_device_name);
throw std::runtime_error("audio_jack_sink");
}
@@ -153,9 +154,8 @@ namespace gr {
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);
+ GR_LOG_INFO(d_logger, boost::format("[%1%]: unable to support sampling rate %2%\n\tCard requested %3% instead.") \
+ % d_device_name % sampling_rate % d_sampling_rate);
}
}
@@ -251,8 +251,8 @@ namespace gr {
void
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);
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: %2%: %3%") \
+ % d_device_name % msg % err);
}
void
diff --git a/gr-audio/lib/jack/jack_source.cc b/gr-audio/lib/jack/jack_source.cc
index 9223cbb588..ced1d47d2e 100644
--- a/gr-audio/lib/jack/jack_source.cc
+++ b/gr-audio/lib/jack/jack_source.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2006,2010,2013 Free Software Foundation, Inc.
+ * Copyright 2005,2006,2010,2013-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -40,9 +40,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SOURCE(REG_PRIO_MED, jack)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ source::sptr
+ jack_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return source::sptr
(new jack_source(sampling_rate, device_name, ok_to_block));
@@ -125,8 +126,8 @@ namespace gr {
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());
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: jack server not running?") \
+ % d_device_name);
throw std::runtime_error("audio_jack_source");
}
@@ -150,9 +151,8 @@ namespace gr {
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);
+ GR_LOG_INFO(d_logger, boost::format("[%1%]: unable to support sampling rate %2%\n\tCard requested %3% instead.") \
+ % d_device_name % sampling_rate % d_sampling_rate);
}
}
@@ -251,8 +251,8 @@ namespace gr {
void
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);
+ GR_LOG_ERROR(d_logger, boost::format("[%1%]: %2%: %3%") \
+ % d_device_name % msg % err);
}
void
diff --git a/gr-audio/lib/oss/oss_sink.cc b/gr-audio/lib/oss/oss_sink.cc
index 75372b0b43..b11adc0f7e 100644
--- a/gr-audio/lib/oss/oss_sink.cc
+++ b/gr-audio/lib/oss/oss_sink.cc
@@ -41,9 +41,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SINK(REG_PRIO_LOW, oss)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ sink::sptr
+ oss_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return sink::sptr
(new oss_sink(sampling_rate, device_name, ok_to_block));
diff --git a/gr-audio/lib/oss/oss_source.cc b/gr-audio/lib/oss/oss_source.cc
index 0d27f74fa8..719349e948 100644
--- a/gr-audio/lib/oss/oss_source.cc
+++ b/gr-audio/lib/oss/oss_source.cc
@@ -41,9 +41,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SOURCE(REG_PRIO_LOW, oss)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ source::sptr
+ oss_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return source::sptr
(new oss_source(sampling_rate, device_name, ok_to_block));
diff --git a/gr-audio/lib/osx/osx_sink.cc b/gr-audio/lib/osx/osx_sink.cc
index dc21ab2025..0b304eea3f 100644
--- a/gr-audio/lib/osx/osx_sink.cc
+++ b/gr-audio/lib/osx/osx_sink.cc
@@ -34,10 +34,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SINK(REG_PRIO_HIGH, osx)
- (int sampling_rate,
- const std::string& device_name,
- bool ok_to_block)
+ sink::sptr
+ osx_sink_fcn(int sampling_rate,
+ const std::string& device_name,
+ bool ok_to_block)
{
return sink::sptr
(new osx_sink(sampling_rate, device_name, ok_to_block));
diff --git a/gr-audio/lib/osx/osx_source.cc b/gr-audio/lib/osx/osx_source.cc
index b51a6563ed..e37fc07d96 100644
--- a/gr-audio/lib/osx/osx_source.cc
+++ b/gr-audio/lib/osx/osx_source.cc
@@ -34,10 +34,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SOURCE(REG_PRIO_HIGH, osx)
- (int sampling_rate,
- const std::string& device_name,
- bool ok_to_block)
+ source::sptr
+ osx_source_fcn(int sampling_rate,
+ const std::string& device_name,
+ bool ok_to_block)
{
return source::sptr
(new osx_source(sampling_rate, device_name, ok_to_block));
diff --git a/gr-audio/lib/portaudio/portaudio_sink.cc b/gr-audio/lib/portaudio/portaudio_sink.cc
index f3315f1268..4a0a969895 100644
--- a/gr-audio/lib/portaudio/portaudio_sink.cc
+++ b/gr-audio/lib/portaudio/portaudio_sink.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006-2011,2013 Free Software Foundation, Inc.
+ * Copyright 2006-2011,2013-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -38,9 +38,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SINK(REG_PRIO_MED, portaudio)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ sink::sptr
+ portaudio_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return sink::sptr
(new portaudio_sink(sampling_rate, device_name, ok_to_block));
diff --git a/gr-audio/lib/portaudio/portaudio_source.cc b/gr-audio/lib/portaudio/portaudio_source.cc
index 178d507562..efbe2b6fc7 100644
--- a/gr-audio/lib/portaudio/portaudio_source.cc
+++ b/gr-audio/lib/portaudio/portaudio_source.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006-2011,2013 Free Software Foundation, Inc.
+ * Copyright 2006-2011,2013-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -38,9 +38,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SOURCE(REG_PRIO_MED, portaudio)(int sampling_rate,
- const std::string &device_name,
- bool ok_to_block)
+ source::sptr
+ portaudio_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool ok_to_block)
{
return source::sptr
(new portaudio_source(sampling_rate, device_name, ok_to_block));
diff --git a/gr-audio/lib/windows/windows_sink.cc b/gr-audio/lib/windows/windows_sink.cc
index 33a706baf5..6598c973d4 100644
--- a/gr-audio/lib/windows/windows_sink.cc
+++ b/gr-audio/lib/windows/windows_sink.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
-* Copyright 2004-2011,2013 Free Software Foundation, Inc.
+* Copyright 2004-2011,2013-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -40,9 +40,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SINK(REG_PRIO_HIGH, windows)(int sampling_rate,
- const std::string &device_name,
- bool)
+ sink::sptr
+ windows_sink_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool)
{
return sink::sptr
(new windows_sink(sampling_rate, device_name));
diff --git a/gr-audio/lib/windows/windows_source.cc b/gr-audio/lib/windows/windows_source.cc
index bc1597f0df..02c9311517 100644
--- a/gr-audio/lib/windows/windows_source.cc
+++ b/gr-audio/lib/windows/windows_source.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004-2011,2013 Free Software Foundation, Inc.
+ * Copyright 2004-2011,2013-2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -40,9 +40,10 @@
namespace gr {
namespace audio {
- AUDIO_REGISTER_SOURCE(REG_PRIO_HIGH, windows)(int sampling_rate,
- const std::string &device_name,
- bool)
+ source::sptr
+ windows_source_fcn(int sampling_rate,
+ const std::string &device_name,
+ bool)
{
return source::sptr
(new windows_source(sampling_rate, device_name));