diff --git a/cwMidiAlsa.cpp b/cwMidiAlsa.cpp index 7b6c85c..321a358 100644 --- a/cwMidiAlsa.cpp +++ b/cwMidiAlsa.cpp @@ -54,7 +54,8 @@ namespace cw { unsigned devCnt; // MIDI devices attached to this computer dev_t* devArray; - cbFunc_t cbFunc; // MIDI input application callback + cbFunc_t cbFunc; // MIDI input application callback + bool filterRtSenseFl; void* cbDataPtr; snd_seq_t* h; // ALSA system sequencer handle snd_seq_addr_t alsa_addr; // ALSA client/port address representing the application @@ -72,6 +73,7 @@ namespace cw bool latency_meas_enable_in_fl; bool latency_meas_enable_out_fl; latency_meas_result_t latency_meas_result; + } alsa_device_t; @@ -254,7 +256,7 @@ namespace cw case SND_SEQ_EVENT_START: status = kSysRtStartMdId; break; case SND_SEQ_EVENT_CONTINUE: status = kSysRtContMdId; break; case SND_SEQ_EVENT_STOP: status = kSysRtStopMdId; break; - case SND_SEQ_EVENT_SENSING: status = kSysRtSenseMdId; break; + case SND_SEQ_EVENT_SENSING: status = p->filterRtSenseFl ? 0 : kSysRtSenseMdId; break; case SND_SEQ_EVENT_RESET: status = kSysRtResetMdId; break; case SND_SEQ_EVENT_SYSEX: @@ -599,7 +601,12 @@ namespace cw } // cw -cw::rc_t cw::midi::device::alsa::create( handle_t& h, cbFunc_t cbFunc, void* cbArg, unsigned parserBufByteCnt, const char* appNameStr ) +cw::rc_t cw::midi::device::alsa::create( handle_t& h, + cbFunc_t cbFunc, + void* cbArg, + unsigned parserBufByteCnt, + const char* appNameStr, + bool filterRtSenseFl ) { rc_t rc = kOkRC; int arc = 0; @@ -631,8 +638,9 @@ cw::rc_t cw::midi::device::alsa::create( handle_t& h, cbFunc_t cbFunc, void* cb p->alsa_fd = mem::allocZ(p->alsa_fdCnt); snd_seq_poll_descriptors(p->h, p->alsa_fd, p->alsa_fdCnt, POLLIN); - p->cbFunc = cbFunc; - p->cbDataPtr = cbArg; + p->cbFunc = cbFunc; + p->cbDataPtr = cbArg; + p->filterRtSenseFl = filterRtSenseFl; // start the sequencer queue if((arc = snd_seq_start_queue(p->h, p->alsa_queue, NULL)) < 0 ) diff --git a/cwMidiAlsa.h b/cwMidiAlsa.h index 4c74913..fd6f9f6 100644 --- a/cwMidiAlsa.h +++ b/cwMidiAlsa.h @@ -9,7 +9,13 @@ namespace cw typedef handle< struct alsa_device_str> handle_t; - rc_t create( handle_t& h, cbFunc_t cbFunc, void* cbDataPtr, unsigned parserBufByteCnt, const char* appNameStr ); + rc_t create( handle_t& h, + cbFunc_t cbFunc, + void* cbDataPtr, + unsigned parserBufByteCnt, + const char* appNameStr, + bool filterRtSenseFl ); + rc_t destroy( handle_t& h); bool isInitialized( handle_t h ); diff --git a/cwMidiDevice.cpp b/cwMidiDevice.cpp index fc290bf..ef484d9 100644 --- a/cwMidiDevice.cpp +++ b/cwMidiDevice.cpp @@ -60,6 +60,8 @@ namespace cw unsigned bufN; std::atomic buf_ii; std::atomic buf_oi; + + bool filterRtSenseFl; } device_t; @@ -238,7 +240,8 @@ cw::rc_t cw::midi::device::create( handle_t& hRef, unsigned fileDevReadAheadMicros, unsigned parserBufByteCnt, bool enableBufFl, - unsigned bufferMsgCnt ) + unsigned bufferMsgCnt, + bool filterRtSenseFl ) { rc_t rc = kOkRC; rc_t rc1 = kOkRC; @@ -252,7 +255,8 @@ cw::rc_t cw::midi::device::create( handle_t& hRef, enableBufFl ? _callback : cbFunc, enableBufFl ? p : cbArg, parserBufByteCnt, - appNameStr )) != kOkRC ) + appNameStr, + filterRtSenseFl)) != kOkRC ) { rc = cwLogError(rc,"ALSA MIDI device create failed."); goto errLabel; @@ -328,6 +332,7 @@ cw::rc_t cw::midi::device::create( handle_t& h, unsigned bufMsgCnt = 0; const object_t* file_ports = nullptr; const object_t* port = nullptr; + bool filterRtSenseFl = true;; if((rc = args->getv("appNameStr",appNameStr, "fileDevName",fileDevName, @@ -335,7 +340,8 @@ cw::rc_t cw::midi::device::create( handle_t& h, "parseBufByteCnt",parseBufByteCnt, "enableBufFl",enableBufFl, "bufferMsgCnt",bufMsgCnt, - "file_ports",file_ports)) != kOkRC ) + "file_ports",file_ports, + "filterRtSenseFl",filterRtSenseFl)) != kOkRC ) { rc = cwLogError(rc,"MIDI port parse args. failed."); } @@ -361,7 +367,18 @@ cw::rc_t cw::midi::device::create( handle_t& h, } } - rc = create(h,cbFunc,cbArg,labelArray,fpi,appNameStr,fileDevName,fileDevReadAheadMicros,parseBufByteCnt,enableBufFl,bufMsgCnt); + rc = create(h, + cbFunc, + cbArg, + labelArray, + fpi, + appNameStr, + fileDevName, + fileDevReadAheadMicros, + parseBufByteCnt, + enableBufFl, + bufMsgCnt, + filterRtSenseFl); } diff --git a/cwMidiDevice.h b/cwMidiDevice.h index 237052f..a633cd6 100644 --- a/cwMidiDevice.h +++ b/cwMidiDevice.h @@ -32,7 +32,8 @@ namespace cw unsigned fileDevReadAheadMicros = 3000, unsigned parserBufByteCnt = 1024, bool enableBufFl = false, // Enable buffer to hold all incoming msg's until RT thread can pick them up. - unsigned bufferMsgCnt = 4096); // Count of messages in input buffer. + unsigned bufferMsgCnt = 4096, // Count of messages in input buffer. + bool filterRtSenseFl = true); rc_t create( handle_t& h, cbFunc_t cbFunc,