diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-08-13 16:06:19 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-08-13 17:06:15 -0400 |
commit | 2fc6293932564fd9f84a31898aa11c0b9a3b44cc (patch) | |
tree | 08ab00c8881968bcb86dfae04682ddbbf6cab8ac /gr-audio/lib | |
parent | f1c8ab4aff39340da87b82758263c11b4c9a6754 (diff) |
audio: modified the audio registration system.
Instead of static functions and macros, this just uses simple ifdefs in the code to register new audio components if cmake found them. The code is more complicated for the developer, if we ever add a new audio machine. But this allows us to use gr-audio in statically linked cases.
Diffstat (limited to 'gr-audio/lib')
-rw-r--r-- | gr-audio/lib/CMakeLists.txt | 24 | ||||
-rw-r--r-- | gr-audio/lib/alsa/alsa_sink.cc | 34 | ||||
-rw-r--r-- | gr-audio/lib/alsa/alsa_source.cc | 29 | ||||
-rw-r--r-- | gr-audio/lib/audio_registry.cc | 105 | ||||
-rw-r--r-- | gr-audio/lib/audio_registry.h | 83 | ||||
-rw-r--r-- | gr-audio/lib/jack/jack_sink.cc | 22 | ||||
-rw-r--r-- | gr-audio/lib/jack/jack_source.cc | 22 | ||||
-rw-r--r-- | gr-audio/lib/oss/oss_sink.cc | 7 | ||||
-rw-r--r-- | gr-audio/lib/oss/oss_source.cc | 7 | ||||
-rw-r--r-- | gr-audio/lib/osx/osx_sink.cc | 8 | ||||
-rw-r--r-- | gr-audio/lib/osx/osx_source.cc | 8 | ||||
-rw-r--r-- | gr-audio/lib/portaudio/portaudio_sink.cc | 9 | ||||
-rw-r--r-- | gr-audio/lib/portaudio/portaudio_source.cc | 9 | ||||
-rw-r--r-- | gr-audio/lib/windows/windows_sink.cc | 9 | ||||
-rw-r--r-- | gr-audio/lib/windows/windows_source.cc | 9 |
15 files changed, 260 insertions, 125 deletions
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)); |