From 7db4474dd58b75bf43344dbb311728b270f6d192 Mon Sep 17 00:00:00 2001 From: kpl Date: Thu, 13 Feb 2020 11:30:46 -0500 Subject: [PATCH] cwIo.h/cpp/test : Added initial audio implemetation. --- cwIo.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++- cwIo.h | 6 ++++- cwIoTest.cpp | 9 +++++++ 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/cwIo.cpp b/cwIo.cpp index fd4ad33..858b93b 100644 --- a/cwIo.cpp +++ b/cwIo.cpp @@ -15,6 +15,10 @@ #include "cwSerialPort.h" #include "cwSerialPortSrv.h" +#include "cwAudioDevice.h" +#include "cwAudioBuf.h" +#include "cwAudioDeviceAlsa.h" + namespace cw { @@ -41,7 +45,11 @@ namespace cw serialPort_t* serialA; unsigned serialN; - midi::device::handle_t midiH; + midi::device::handle_t midiH; + + audio::device::handle_t audioH; + audio::device::alsa::handle_t alsaH; + } io_t; @@ -215,6 +223,59 @@ namespace cw return rc; } + + void _audioDeviceCallback( void* cbArg, audio::device::audioPacket_t* inPktArray, unsigned inPktCnt, audio::device::audioPacket_t* outPktArray, unsigned outPktCnt ) + { + } + + rc_t _audioDeviceConfig( io_t* p, const object_t* c ) + { + rc_t rc = kOkRC; + + + + return rc; + } + + + rc_t _audioDeviceCreate( io_t* p, const object_t*& c ) + { + rc_t rc = kOkRC; + audio::device::driver_t* audioDrv = nullptr; + + // initialize the audio device interface + if((rc = audio::device::create(p->audioH)) != kOkRC ) + { + cwLogInfo("Initialize failed."); + goto errLabel; + } + + // initialize the ALSA device driver interface + if((rc = audio::device::alsa::create(p->alsaH, audioDrv )) != kOkRC ) + { + cwLogInfo("ALSA initialize failed."); + goto errLabel; + } + + // register the ALSA device driver with the audio interface + if((rc = audio::device::registerDriver( p->audioH, audioDrv )) != kOkRC ) + { + cwLogInfo("ALSA driver registration failed."); + goto errLabel; + } + + // + if((rc = _audioDeviceConfig( p, c )) != kOkRC ) + { + cwLogInfo("Audio device configuration failed."); + goto errLabel; + } + + + errLabel: + return rc; + } + } } @@ -253,6 +314,10 @@ cw::rc_t cw::io::create( handle_t& h, const char* cfgStr, cbFunc_t cbFunc, void* // create the MIDI port device if((rc = _midiPortCreate(p,o)) != kOkRC ) goto errLabel; + + // create the Audio device interface + if((rc = _audioDeviceCreate(p,o)) != kOkRC ) + goto errLabel; // create the the thread if((rc = thread::create( p->threadH, _mainThreadFunc, p)) != kOkRC ) diff --git a/cwIo.h b/cwIo.h index f5e45b3..9a335b7 100644 --- a/cwIo.h +++ b/cwIo.h @@ -43,7 +43,7 @@ namespace cw rc_t create( handle_t& h, - const char* cfgStr, + const char* cfgStr, // configuration information as text cbFunc_t cbFunc, void* cbArg, const char* cfgLabel="io" ); @@ -65,6 +65,10 @@ namespace cw const char* midiDevicePortName( handle_t h, unsigned devIdx, bool inputFl, unsigned portIdx ); unsigned midiDevicePortIndex( handle_t h, unsigned devIdx, bool inputFl, const char* portName ); rc_t midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, midi::byte_t status, midi::byte_t d0, midi::byte_t d1 ); + + + + } } diff --git a/cwIoTest.cpp b/cwIoTest.cpp index bf03280..27d2f31 100644 --- a/cwIoTest.cpp +++ b/cwIoTest.cpp @@ -38,6 +38,15 @@ cw::rc_t cw::io::test() midi: { parserBufByteN: 1024, } + + audio: [ + { + name: "default", + device: "HDA Intel PCH CS4208 Analog", + srate: 48000, + framesPerCycle: 64 + } + ] } })";