cwMidiAlsa.h/cpp,cwMidiPort.h : Updated MIDI system to remove global manager variable.
This commit is contained in:
parent
68b8a15714
commit
59507913e0
284
cwMidiAlsa.cpp
284
cwMidiAlsa.cpp
@ -31,41 +31,33 @@ namespace cw
|
||||
{
|
||||
char* nameStr; // string label for this device
|
||||
unsigned iPortCnt; // input ports on this device
|
||||
port_t* iPortArray;
|
||||
port_t* iPortArray; //
|
||||
unsigned oPortCnt; // output ports on this device
|
||||
port_t* oPortArray;
|
||||
port_t* oPortArray; //
|
||||
unsigned char clientId; // ALSA client id (all ports on this device use use this client id in their address)
|
||||
|
||||
} dev_t;
|
||||
|
||||
typedef struct
|
||||
typedef struct device_str
|
||||
{
|
||||
unsigned devCnt; // MIDI devices attached to this computer
|
||||
dev_t* devArray;
|
||||
|
||||
cbFunc_t cbFunc; // MIDI input application callback
|
||||
void* cbDataPtr;
|
||||
|
||||
snd_seq_t* h; // ALSA system sequencer handle
|
||||
|
||||
snd_seq_addr_t alsa_addr; // ALSA client/port address representing the application
|
||||
int alsa_queue; // ALSA device queue
|
||||
thread::handle_t thH; // MIDI input listening thread
|
||||
|
||||
int alsa_fdCnt; // MIDI input driver file descriptor array
|
||||
struct pollfd* alsa_fd;
|
||||
|
||||
dev_t* prvRcvDev; // the last device and port to rcv MIDI
|
||||
port_t* prvRcvPort;
|
||||
|
||||
unsigned prvTimeMicroSecs; // time of last recognized event in microseconds
|
||||
unsigned eventCnt; // count of recognized events
|
||||
|
||||
time::spec_t baseTimeStamp;
|
||||
} device_t;
|
||||
|
||||
} cmMpRoot_t;
|
||||
|
||||
cmMpRoot_t* _cmMpRoot = NULL;
|
||||
device_t* _handleToPtr( handle_t h ){ return handleToPtr<handle_t,device_t>(h); }
|
||||
|
||||
rc_t _cmMpErrMsgV(rc_t rc, int alsaRc, const char* fmt, va_list vl )
|
||||
{
|
||||
@ -97,9 +89,8 @@ namespace cw
|
||||
return i;
|
||||
}
|
||||
|
||||
dev_t* _cmMpClientIdToDev( int clientId )
|
||||
dev_t* _cmMpClientIdToDev( device_t* p, int clientId )
|
||||
{
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
unsigned i;
|
||||
for(i=0; i<p->devCnt; ++i)
|
||||
if( p->devArray[i].clientId == clientId )
|
||||
@ -126,10 +117,9 @@ namespace cw
|
||||
*d1 = v & 0x7f;
|
||||
}
|
||||
|
||||
rc_t cmMpPoll()
|
||||
rc_t _cmMpPoll(device_t* p)
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
int timeOutMs = 50;
|
||||
|
||||
snd_seq_event_t *ev;
|
||||
@ -152,7 +142,7 @@ namespace cw
|
||||
|
||||
// get the device this event arrived from
|
||||
if( p->prvRcvDev==NULL || p->prvRcvDev->clientId != ev->source.client )
|
||||
p->prvRcvDev = _cmMpClientIdToDev(ev->source.client);
|
||||
p->prvRcvDev = _cmMpClientIdToDev(p,ev->source.client);
|
||||
|
||||
// get the port this event arrived from
|
||||
if( p->prvRcvDev != NULL && (p->prvRcvPort==NULL || p->prvRcvPort->alsa_addr.port != ev->source.port) )
|
||||
@ -281,13 +271,14 @@ namespace cw
|
||||
}
|
||||
|
||||
|
||||
bool _threadCbFunc(void* param)
|
||||
bool _threadCbFunc(void* arg)
|
||||
{
|
||||
cmMpPoll();
|
||||
device_t* p = static_cast<device_t*>(arg);
|
||||
_cmMpPoll(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
rc_t _cmMpAllocStruct( cmMpRoot_t* p, const char* appNameStr, cbFunc_t cbFunc, void* cbDataPtr, unsigned parserBufByteCnt )
|
||||
rc_t _cmMpAllocStruct( device_t* p, const char* appNameStr, cbFunc_t cbFunc, void* cbDataPtr, unsigned parserBufByteCnt )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
snd_seq_client_info_t* cip = NULL;
|
||||
@ -499,85 +490,11 @@ namespace cw
|
||||
|
||||
}
|
||||
|
||||
} // device
|
||||
} // midi
|
||||
} // cw
|
||||
|
||||
cw::rc_t cw::midi::device::initialize( cbFunc_t cbFunc, void* cbArg, unsigned parserBufByteCnt, const char* appNameStr )
|
||||
rc_t _destroy( device_t* p )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
int arc = 0;
|
||||
cmMpRoot_t* p = NULL;
|
||||
|
||||
if((rc = finalize()) != kOkRC )
|
||||
return rc;
|
||||
|
||||
// allocate the global root object
|
||||
_cmMpRoot = p = mem::allocZ<cmMpRoot_t>(1);
|
||||
p->h = NULL;
|
||||
p->alsa_queue = -1;
|
||||
|
||||
|
||||
// create the listening thread
|
||||
if((rc = thread::create( p->thH, _threadCbFunc, NULL)) != kOkRC )
|
||||
{
|
||||
rc = _cmMpErrMsg(rc,0,"Thread initialization failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// initialize the ALSA sequencer
|
||||
if((arc = snd_seq_open(&p->h, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK )) < 0 )
|
||||
{
|
||||
rc = _cmMpErrMsg(kOpFailRC,arc,"ALSA Sequencer open failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// prevent valgrind from report memory leaks in libasound (https://stackoverflow.com/questions/13478861/alsa-mem-leak)
|
||||
snd_config_update_free_global();
|
||||
|
||||
// setup the device and port structures
|
||||
if((rc = _cmMpAllocStruct(p,appNameStr,cbFunc,cbArg,parserBufByteCnt)) != kOkRC )
|
||||
goto errLabel;
|
||||
|
||||
// allocate the file descriptors used for polling
|
||||
p->alsa_fdCnt = snd_seq_poll_descriptors_count(p->h, POLLIN);
|
||||
p->alsa_fd = mem::allocZ<struct pollfd>(p->alsa_fdCnt);
|
||||
snd_seq_poll_descriptors(p->h, p->alsa_fd, p->alsa_fdCnt, POLLIN);
|
||||
|
||||
p->cbFunc = cbFunc;
|
||||
p->cbDataPtr = cbArg;
|
||||
|
||||
// start the sequencer queue
|
||||
if((arc = snd_seq_start_queue(p->h, p->alsa_queue, NULL)) < 0 )
|
||||
{
|
||||
rc = _cmMpErrMsg(kOpFailRC,arc,"ALSA queue start failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// send any pending commands to the driver
|
||||
snd_seq_drain_output(p->h);
|
||||
|
||||
// all time stamps will be an offset from this time stamp
|
||||
clock_gettime(CLOCK_MONOTONIC,&p->baseTimeStamp);
|
||||
|
||||
if((rc = thread::unpause(p->thH)) != kOkRC )
|
||||
rc = _cmMpErrMsg(rc,0,"Thread start failed.");
|
||||
|
||||
errLabel:
|
||||
|
||||
if( rc != kOkRC )
|
||||
finalize();
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
cw::rc_t cw::midi::device::finalize()
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
|
||||
if( _cmMpRoot != NULL )
|
||||
if( p != NULL )
|
||||
{
|
||||
int arc;
|
||||
|
||||
@ -638,65 +555,166 @@ cw::rc_t cw::midi::device::finalize()
|
||||
|
||||
mem::free(p->alsa_fd);
|
||||
|
||||
mem::release(_cmMpRoot);
|
||||
mem::release(p);
|
||||
|
||||
}
|
||||
|
||||
errLabel:
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool cw::midi::device::isInitialized()
|
||||
{ return _cmMpRoot!=NULL; }
|
||||
|
||||
unsigned cw::midi::device::count()
|
||||
{ return _cmMpRoot==NULL ? 0 : _cmMpRoot->devCnt; }
|
||||
} // device
|
||||
} // midi
|
||||
} // cw
|
||||
|
||||
const char* cw::midi::device::name( unsigned devIdx )
|
||||
|
||||
cw::rc_t cw::midi::device::create( handle_t& h, cbFunc_t cbFunc, void* cbArg, unsigned parserBufByteCnt, const char* appNameStr )
|
||||
{
|
||||
if( _cmMpRoot==NULL || devIdx>=_cmMpRoot->devCnt)
|
||||
rc_t rc = kOkRC;
|
||||
int arc = 0;
|
||||
|
||||
if((rc = destroy(h)) != kOkRC )
|
||||
return rc;
|
||||
|
||||
device_t* p = mem::allocZ<device_t>(1);
|
||||
p->h = NULL;
|
||||
p->alsa_queue = -1;
|
||||
|
||||
|
||||
// create the listening thread
|
||||
if((rc = thread::create( p->thH, _threadCbFunc, p)) != kOkRC )
|
||||
{
|
||||
rc = _cmMpErrMsg(rc,0,"Thread initialization failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// initialize the ALSA sequencer
|
||||
if((arc = snd_seq_open(&p->h, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK )) < 0 )
|
||||
{
|
||||
rc = _cmMpErrMsg(kOpFailRC,arc,"ALSA Sequencer open failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// prevent valgrind from report memory leaks in libasound (https://stackoverflow.com/questions/13478861/alsa-mem-leak)
|
||||
snd_config_update_free_global();
|
||||
|
||||
// setup the device and port structures
|
||||
if((rc = _cmMpAllocStruct(p,appNameStr,cbFunc,cbArg,parserBufByteCnt)) != kOkRC )
|
||||
goto errLabel;
|
||||
|
||||
// allocate the file descriptors used for polling
|
||||
p->alsa_fdCnt = snd_seq_poll_descriptors_count(p->h, POLLIN);
|
||||
p->alsa_fd = mem::allocZ<struct pollfd>(p->alsa_fdCnt);
|
||||
snd_seq_poll_descriptors(p->h, p->alsa_fd, p->alsa_fdCnt, POLLIN);
|
||||
|
||||
p->cbFunc = cbFunc;
|
||||
p->cbDataPtr = cbArg;
|
||||
|
||||
// start the sequencer queue
|
||||
if((arc = snd_seq_start_queue(p->h, p->alsa_queue, NULL)) < 0 )
|
||||
{
|
||||
rc = _cmMpErrMsg(kOpFailRC,arc,"ALSA queue start failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// send any pending commands to the driver
|
||||
snd_seq_drain_output(p->h);
|
||||
|
||||
// all time stamps will be an offset from this time stamp
|
||||
clock_gettime(CLOCK_MONOTONIC,&p->baseTimeStamp);
|
||||
|
||||
if((rc = thread::unpause(p->thH)) != kOkRC )
|
||||
rc = _cmMpErrMsg(rc,0,"Thread start failed.");
|
||||
|
||||
h.set(p);
|
||||
|
||||
errLabel:
|
||||
|
||||
if( rc != kOkRC )
|
||||
_destroy(p);
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
|
||||
cw::rc_t cw::midi::device::destroy( handle_t& h )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
|
||||
if( !h.isValid() )
|
||||
return rc;
|
||||
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
if((rc = _destroy(p)) != kOkRC )
|
||||
return rc;
|
||||
|
||||
h.clear();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool cw::midi::device::isInitialized(handle_t h)
|
||||
{ return h.isValid(); }
|
||||
|
||||
unsigned cw::midi::device::count(handle_t h)
|
||||
{
|
||||
device_t* p = _handleToPtr(h);
|
||||
return p->devCnt;
|
||||
}
|
||||
|
||||
const char* cw::midi::device::name( handle_t h, unsigned devIdx )
|
||||
{
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
if( p==NULL || devIdx>=p->devCnt)
|
||||
return NULL;
|
||||
|
||||
return _cmMpRoot->devArray[devIdx].nameStr;
|
||||
return p->devArray[devIdx].nameStr;
|
||||
}
|
||||
|
||||
unsigned cw::midi::device::portCount( unsigned devIdx, unsigned flags )
|
||||
unsigned cw::midi::device::portCount( handle_t h, unsigned devIdx, unsigned flags )
|
||||
{
|
||||
if( _cmMpRoot==NULL || devIdx>=_cmMpRoot->devCnt)
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
if( p==NULL || devIdx>=p->devCnt)
|
||||
return 0;
|
||||
|
||||
if( cwIsFlag(flags,kInMpFl) )
|
||||
return _cmMpRoot->devArray[devIdx].iPortCnt;
|
||||
return p->devArray[devIdx].iPortCnt;
|
||||
|
||||
return _cmMpRoot->devArray[devIdx].oPortCnt;
|
||||
return p->devArray[devIdx].oPortCnt;
|
||||
}
|
||||
|
||||
const char* cw::midi::device::portName( unsigned devIdx, unsigned flags, unsigned portIdx )
|
||||
const char* cw::midi::device::portName( handle_t h, unsigned devIdx, unsigned flags, unsigned portIdx )
|
||||
{
|
||||
if( _cmMpRoot==NULL || devIdx>=_cmMpRoot->devCnt)
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
if( p==NULL || devIdx>=p->devCnt)
|
||||
return 0;
|
||||
|
||||
if( cwIsFlag(flags,kInMpFl) )
|
||||
{
|
||||
if( portIdx >= _cmMpRoot->devArray[devIdx].iPortCnt )
|
||||
if( portIdx >= p->devArray[devIdx].iPortCnt )
|
||||
return 0;
|
||||
|
||||
return _cmMpRoot->devArray[devIdx].iPortArray[portIdx].nameStr;
|
||||
return p->devArray[devIdx].iPortArray[portIdx].nameStr;
|
||||
}
|
||||
|
||||
if( portIdx >= _cmMpRoot->devArray[devIdx].oPortCnt )
|
||||
if( portIdx >= p->devArray[devIdx].oPortCnt )
|
||||
return 0;
|
||||
|
||||
return _cmMpRoot->devArray[devIdx].oPortArray[portIdx].nameStr;
|
||||
return p->devArray[devIdx].oPortArray[portIdx].nameStr;
|
||||
}
|
||||
|
||||
|
||||
cw::rc_t cw::midi::device::send( unsigned devIdx, unsigned portIdx, byte_t status, byte_t d0, byte_t d1 )
|
||||
cw::rc_t cw::midi::device::send( handle_t h, unsigned devIdx, unsigned portIdx, byte_t status, byte_t d0, byte_t d1 )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
snd_seq_event_t ev;
|
||||
int arc;
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
assert( p!=NULL && devIdx < p->devCnt && portIdx < p->devArray[devIdx].oPortCnt );
|
||||
|
||||
@ -779,23 +797,23 @@ cw::rc_t cw::midi::device::send( unsigned devIdx, unsigned portIdx, byte_t stat
|
||||
return rc;
|
||||
}
|
||||
|
||||
cw::rc_t cw::midi::device::sendData( unsigned devIdx, unsigned portIdx, const byte_t* dataPtr, unsigned byteCnt )
|
||||
cw::rc_t cw::midi::device::sendData( handle_t h, unsigned devIdx, unsigned portIdx, const byte_t* dataPtr, unsigned byteCnt )
|
||||
{
|
||||
return cwLogError(kInvalidOpRC,"cmMpDeviceSendData() has not yet been implemented for ALSA.");
|
||||
}
|
||||
|
||||
cw::rc_t cw::midi::device::installCallback( unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr )
|
||||
cw::rc_t cw::midi::device::installCallback( handle_t h, unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
unsigned di;
|
||||
unsigned dn = count();
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
unsigned dn = count(h);
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
for(di=0; di<dn; ++di)
|
||||
if( di==devIdx || devIdx == kInvalidIdx )
|
||||
{
|
||||
unsigned pi;
|
||||
unsigned pn = portCount(di,kInMpFl);
|
||||
unsigned pn = portCount(h,di,kInMpFl);
|
||||
|
||||
for(pi=0; pi<pn; ++pi)
|
||||
if( pi==portIdx || portIdx == kInvalidIdx )
|
||||
@ -807,19 +825,19 @@ cw::rc_t cw::midi::device::installCallback( unsigned devIdx, unsigned portIdx
|
||||
return rc;
|
||||
}
|
||||
|
||||
cw::rc_t cw::midi::device::removeCallback( unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr )
|
||||
cw::rc_t cw::midi::device::removeCallback( handle_t h, unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
unsigned di;
|
||||
unsigned dn = count();
|
||||
unsigned dn = count(h);
|
||||
unsigned remCnt = 0;
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
for(di=0; di<dn; ++di)
|
||||
if( di==devIdx || devIdx == kInvalidIdx )
|
||||
{
|
||||
unsigned pi;
|
||||
unsigned pn = portCount(di,kInMpFl);
|
||||
unsigned pn = portCount(h,di,kInMpFl);
|
||||
|
||||
for(pi=0; pi<pn; ++pi)
|
||||
if( pi==portIdx || portIdx == kInvalidIdx )
|
||||
@ -839,17 +857,17 @@ cw::rc_t cw::midi::device::removeCallback( unsigned devIdx, unsigned portIdx
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool cw::midi::device::usesCallback( unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr )
|
||||
bool cw::midi::device::usesCallback( handle_t h, unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr )
|
||||
{
|
||||
unsigned di;
|
||||
unsigned dn = count();
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
unsigned dn = count(h);
|
||||
device_t* p = _handleToPtr(h);
|
||||
|
||||
for(di=0; di<dn; ++di)
|
||||
if( di==devIdx || devIdx == kInvalidIdx )
|
||||
{
|
||||
unsigned pi;
|
||||
unsigned pn = portCount(di,kInMpFl);
|
||||
unsigned pn = portCount(h,di,kInMpFl);
|
||||
|
||||
for(pi=0; pi<pn; ++pi)
|
||||
if( pi==portIdx || portIdx == kInvalidIdx )
|
||||
@ -862,9 +880,9 @@ bool cw::midi::device::usesCallback( unsigned devIdx, unsigned portIdx
|
||||
|
||||
|
||||
|
||||
void cw::midi::device::report( textBuf::handle_t tbH )
|
||||
void cw::midi::device::report( handle_t h, textBuf::handle_t tbH )
|
||||
{
|
||||
cmMpRoot_t* p = _cmMpRoot;
|
||||
device_t* p = _handleToPtr(h);
|
||||
unsigned i,j;
|
||||
|
||||
textBuf::print( tbH,"Buffer size bytes in:%i out:%i\n",snd_seq_get_input_buffer_size(p->h),snd_seq_get_output_buffer_size(p->h));
|
||||
|
@ -478,23 +478,23 @@ bool cw::midi::parser::hasCallback( handle_t h, cbFunc_t cbFunc, void* cbArg )
|
||||
//
|
||||
//
|
||||
|
||||
unsigned cw::midi::device::nameToIndex(const char* deviceName)
|
||||
unsigned cw::midi::device::nameToIndex(handle_t h, const char* deviceName)
|
||||
{
|
||||
assert(deviceName!=NULL);
|
||||
unsigned i;
|
||||
unsigned n = count();
|
||||
unsigned n = count(h);
|
||||
for(i=0; i<n; ++i)
|
||||
if( strcmp(name(i),deviceName)==0)
|
||||
if( strcmp(name(h,i),deviceName)==0)
|
||||
return i;
|
||||
return kInvalidIdx;
|
||||
}
|
||||
|
||||
unsigned cw::midi::device::portNameToIndex( unsigned devIdx, unsigned flags, const char* portNameStr )
|
||||
unsigned cw::midi::device::portNameToIndex( handle_t h, unsigned devIdx, unsigned flags, const char* portNameStr )
|
||||
{
|
||||
unsigned i;
|
||||
unsigned n = portCount(devIdx,flags);
|
||||
unsigned n = portCount(h,devIdx,flags);
|
||||
for(i=0; i<n; ++i)
|
||||
if( strcmp(portName(devIdx,flags,i),portNameStr)==0)
|
||||
if( strcmp(portName(h,devIdx,flags,i),portNameStr)==0)
|
||||
return i;
|
||||
|
||||
return kInvalidIdx;
|
||||
@ -536,9 +536,10 @@ cw::rc_t cw::midi::device::test()
|
||||
char ch;
|
||||
unsigned parserBufByteCnt = 1024;
|
||||
textBuf::handle_t tbH;
|
||||
handle_t h;
|
||||
|
||||
// initialie the MIDI system
|
||||
if((rc = initialize(testCallback,NULL,parserBufByteCnt,"app")) != kOkRC )
|
||||
if((rc = create(h,testCallback,NULL,parserBufByteCnt,"app")) != kOkRC )
|
||||
return rc;
|
||||
|
||||
// create a text buffer to hold the MIDI system report text
|
||||
@ -546,18 +547,18 @@ cw::rc_t cw::midi::device::test()
|
||||
goto errLabel;
|
||||
|
||||
// generate and print the MIDI system report
|
||||
report(tbH);
|
||||
report(h,tbH);
|
||||
cwLogInfo("%s",textBuf::text(tbH));
|
||||
|
||||
cwLogInfo("any key to send note-on (<q>=quit)\n");
|
||||
|
||||
while((ch = getchar()) != 'q')
|
||||
{
|
||||
send(2,0,0x90,60,60);
|
||||
send(h,2,0,0x90,60,60);
|
||||
}
|
||||
|
||||
errLabel:
|
||||
textBuf::destroy(tbH);
|
||||
finalize();
|
||||
destroy(h);
|
||||
return rc;
|
||||
}
|
||||
|
33
cwMidiPort.h
33
cwMidiPort.h
@ -65,28 +65,31 @@ namespace cw
|
||||
|
||||
namespace device
|
||||
{
|
||||
typedef handle< struct device_str> handle_t;
|
||||
|
||||
// 'cbFunc' and 'cbDataPtr' are optional (they may be set to NULL). In this case
|
||||
// 'cbFunc' and 'cbDataPtr' may be set in a later call to cmMpInstallCallback().
|
||||
rc_t initialize( cbFunc_t cbFunc, void* cbDataPtr, unsigned parserBufByteCnt, const char* appNameStr );
|
||||
rc_t finalize();
|
||||
bool isInitialized();
|
||||
rc_t create( handle_t& h, cbFunc_t cbFunc, void* cbDataPtr, unsigned parserBufByteCnt, const char* appNameStr );
|
||||
rc_t destroy( handle_t& h);
|
||||
bool isInitialized( handle_t h );
|
||||
|
||||
unsigned count();
|
||||
const char* name( unsigned devIdx );
|
||||
unsigned nameToIndex(const char* deviceName);
|
||||
unsigned portCount( unsigned devIdx, unsigned flags );
|
||||
const char* portName( unsigned devIdx, unsigned flags, unsigned portIdx );
|
||||
unsigned portNameToIndex( unsigned devIdx, unsigned flags, const char* portName );
|
||||
rc_t send( unsigned devIdx, unsigned portIdx, byte_t st, byte_t d0, byte_t d1 );
|
||||
rc_t sendData( unsigned devIdx, unsigned portIdx, const byte_t* dataPtr, unsigned byteCnt );
|
||||
unsigned count( handle_t h );
|
||||
const char* name( handle_t h, unsigned devIdx );
|
||||
unsigned nameToIndex(handle_t h, const char* deviceName);
|
||||
unsigned portCount( handle_t h, unsigned devIdx, unsigned flags );
|
||||
const char* portName( handle_t h, unsigned devIdx, unsigned flags, unsigned portIdx );
|
||||
unsigned portNameToIndex( handle_t h, unsigned devIdx, unsigned flags, const char* portName );
|
||||
rc_t send( handle_t h, unsigned devIdx, unsigned portIdx, byte_t st, byte_t d0, byte_t d1 );
|
||||
rc_t sendData( handle_t h, unsigned devIdx, unsigned portIdx, const byte_t* dataPtr, unsigned byteCnt );
|
||||
|
||||
// Set devIdx to -1 to assign the callback to all devices.
|
||||
// Set portIdx to -1 to assign the callback to all ports on the specified devices.
|
||||
//
|
||||
rc_t installCallback( unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr );
|
||||
rc_t removeCallback( unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr );
|
||||
bool usesCallback( unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr );
|
||||
void report( textBuf::handle_t h);
|
||||
rc_t installCallback( handle_t h, unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr );
|
||||
rc_t removeCallback( handle_t h, unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr );
|
||||
bool usesCallback( handle_t h, unsigned devIdx, unsigned portIdx, cbFunc_t cbFunc, void* cbDataPtr );
|
||||
|
||||
void report( handle_t h, textBuf::handle_t tbH);
|
||||
|
||||
rc_t test();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user