From 36630b0fa3d29c54a666d3bb00a2fac804fa7df9 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 6 Nov 2014 08:03:56 +0100 Subject: Make cli output modules work with new samplerate() design. --- drumgizmo/audiooutputenginedl.cc | 22 +++---------------- drumgizmo/drumgizmoc.cc | 2 +- drumgizmo/output/alsa/alsa.cc | 29 +++++++++++-------------- drumgizmo/output/dummy/dummy.cc | 30 +++++++++++--------------- drumgizmo/output/jackaudio/jackaudio.cc | 17 --------------- drumgizmo/output/wavfile/wavfile.cc | 38 +++++++++++++++------------------ 6 files changed, 46 insertions(+), 92 deletions(-) (limited to 'drumgizmo') diff --git a/drumgizmo/audiooutputenginedl.cc b/drumgizmo/audiooutputenginedl.cc index fcedd9d..2648e8f 100644 --- a/drumgizmo/audiooutputenginedl.cc +++ b/drumgizmo/audiooutputenginedl.cc @@ -114,7 +114,8 @@ AudioOutputEngineDL::AudioOutputEngineDL(std::string name) o_samplerate = (output_samplerate_func_t) dlsym(lib, "samplerate"); dlsym_error = dlerror(); if(dlsym_error) { - o_samplerate = NULL; + printf("Cannot load symbol samplerate: %s\n", dlsym_error); + return; } ptr = o_create(); @@ -190,22 +191,5 @@ size_t AudioOutputEngineDL::getBufferSize() size_t AudioOutputEngineDL::samplerate() { if(o_samplerate) return o_samplerate(ptr); - return UNKNOWN_SAMPLERATE; + return 44100; } - -#ifdef TEST_AUDIOOUTPUTENGINEDL -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_AUDIOOUTPUTENGINEDL*/ diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index d5fa817..61f8eaa 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) return 1; } - AudioOutputEngine *oe = new AudioOutputEngineDL(outputengine); + AudioOutputEngineDL *oe = new AudioOutputEngineDL(outputengine); if(oe == NULL) { printf("Invalid output engine: %s\n", outputengine.c_str()); diff --git a/drumgizmo/output/alsa/alsa.cc b/drumgizmo/output/alsa/alsa.cc index 7b3a395..dc2ac73 100644 --- a/drumgizmo/output/alsa/alsa.cc +++ b/drumgizmo/output/alsa/alsa.cc @@ -49,6 +49,7 @@ public: void pre(size_t size); void run(int channel, sample_t* data, size_t size); void post(size_t size); + size_t samplerate(); private: snd_pcm_t *handle; @@ -157,6 +158,11 @@ void Alsa::post(size_t size) snd_pcm_writei(handle, data, size); } +size_t Alsa::samplerate() +{ + return srate; +} + extern "C" { void *create() { @@ -210,21 +216,10 @@ extern "C" { Alsa *alsa = (Alsa*)h; alsa->post(s); } -} - -#ifdef TEST_AUDIOOUTPUTENGINEALSA -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_AUDIOOUTPUTENGINEALSA*/ + size_t samplerate(void *h) + { + Alsa *alsa = (Alsa*)h; + return alsa->samplerate(); + } +} diff --git a/drumgizmo/output/dummy/dummy.cc b/drumgizmo/output/dummy/dummy.cc index cd210dc..e60f2b7 100644 --- a/drumgizmo/output/dummy/dummy.cc +++ b/drumgizmo/output/dummy/dummy.cc @@ -43,6 +43,8 @@ public: void pre(size_t size); void run(int channel, sample_t* data, size_t size); void post(size_t size); + + size_t samplerate(); }; Dummy::Dummy() @@ -83,6 +85,11 @@ void Dummy::post(size_t size) { } +size_t Dummy::samplerate() +{ + return 44100; +} + extern "C" { void *create() { @@ -136,21 +143,10 @@ extern "C" { Dummy *dummy = (Dummy*)h; dummy->post(size); } -} - -#ifdef TEST_AUDIOOUTPUTENGINEDUMMY -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_AUDIOOUTPUTENGINEDUMMY*/ + size_t samplerate(void *h) + { + Dummy *dummy = (Dummy*)h; + return dummy->samplerate(); + } +} diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc index b7fa4f9..5c04146 100644 --- a/drumgizmo/output/jackaudio/jackaudio.cc +++ b/drumgizmo/output/jackaudio/jackaudio.cc @@ -218,20 +218,3 @@ extern "C" { return jack->samplerate(); } } - -#ifdef TEST_AUDIOINPUTENGINEJACKAUDIO -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_AUDIOINPUTENGINEJACKAUDIO*/ diff --git a/drumgizmo/output/wavfile/wavfile.cc b/drumgizmo/output/wavfile/wavfile.cc index cb95715..fa4128e 100644 --- a/drumgizmo/output/wavfile/wavfile.cc +++ b/drumgizmo/output/wavfile/wavfile.cc @@ -44,6 +44,7 @@ public: void pre(size_t size); void run(int channel, sample_t* data, size_t size); void post(size_t size); + size_t samplerate(); private: SF_INFO sf_info; @@ -58,6 +59,10 @@ WavFile::WavFile() { fh = NULL; filename = "output"; + + sf_info.channels = 1;//channels; + sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; + sf_info.samplerate = 44100; } WavFile::~WavFile() @@ -74,10 +79,6 @@ WavFile::~WavFile() bool WavFile::init(int channels, char *cnames[]) { this->channels = channels; - - sf_info.channels = 1;//channels; - sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; - sf_info.samplerate = 44100; fh = (SNDFILE **)malloc(sizeof(SNDFILE *)*channels); @@ -102,6 +103,7 @@ bool WavFile::init(int channels, char *cnames[]) void WavFile::setParm(std::string parm, std::string value) { if(parm == "file") filename = value; + if(parm == "srate") sf_info.samplerate = atoi(value.c_str()); } bool WavFile::start() @@ -126,6 +128,11 @@ void WavFile::post(size_t size) { } +size_t WavFile::samplerate() +{ + return sf_info.samplerate; +} + extern "C" { void *create() { @@ -179,21 +186,10 @@ extern "C" { WavFile *sndfile = (WavFile*)h; sndfile->post(s); } -} - -#ifdef TEST_AUDIOOUTPUTENGINESNDFILE -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). -TEST_END; - -#endif/*TEST_AUDIOOUTPUTENGINESNDFILE*/ + size_t samplerate(void *h) + { + WavFile *wavfile = (WavFile*)h; + return wavfile->samplerate(); + } +} -- cgit v1.2.3