cwMidiAlsa.cpp : Ports that do not qualify based on READ/WRITE attributes are now dropped.

Ports without names are now given the default name '<None>'.
This commit is contained in:
kevin 2024-04-06 16:02:52 -04:00
parent a6f518ed54
commit 3526b2c807

View File

@ -283,6 +283,7 @@ namespace cw
time::spec_t ts;
ts.tv_sec = ev->time.time.tv_sec;
ts.tv_nsec = ev->time.time.tv_nsec;
parser::midiTriple(p->prvRcvPort->parserH, &ts, status | ch, d0, d1 );
p->prvTimeMicroSecs = microSecs1;
@ -439,7 +440,7 @@ namespace cw
{
assert(j<p->devArray[i].iPortCnt);
p->devArray[i].iPortArray[j].inputFl = true;
p->devArray[i].iPortArray[j].nameStr = mem::duplStr(cwStringNullGuard(port));
p->devArray[i].iPortArray[j].nameStr = mem::duplStr(port==nullptr ? "<None>" : port);
p->devArray[i].iPortArray[j].alsa_type = type;
p->devArray[i].iPortArray[j].alsa_cap = caps;
p->devArray[i].iPortArray[j].alsa_addr = addr;
@ -461,7 +462,7 @@ namespace cw
{
assert(k<p->devArray[i].oPortCnt);
p->devArray[i].oPortArray[k].inputFl = false;
p->devArray[i].oPortArray[k].nameStr = mem::duplStr(cwStringNullGuard(port));
p->devArray[i].oPortArray[k].nameStr = mem::duplStr(port==nullptr ? "<None>" : port);
p->devArray[i].oPortArray[k].alsa_type = type;
p->devArray[i].oPortArray[k].alsa_cap = caps;
p->devArray[i].oPortArray[k].alsa_addr = addr;
@ -475,6 +476,11 @@ namespace cw
++k;
}
}
// The capabilities of some ports may not have been as expected
// decrease the in/out port count to account for these ports
p->devArray[i].iPortCnt = j;
p->devArray[i].oPortCnt = k;
}
errLabel:
@ -736,7 +742,7 @@ const char* cw::midi::device::alsa::portName( handle_t h, unsigned devIdx,
if( cwIsFlag(flags,kInMpFl) )
{
if( portIdx >= p->devArray[devIdx].iPortCnt )
return 0;
return nullptr;
return p->devArray[devIdx].iPortArray[portIdx].nameStr;
}
@ -782,7 +788,7 @@ cw::rc_t cw::midi::device::alsa::send( handle_t h, unsigned devIdx, unsigned po
rc_t rc = kOkRC;
snd_seq_event_t ev;
int arc;
alsa_device_t* p = _handleToPtr(h);
alsa_device_t* p = _handleToPtr(h);
assert( p!=NULL && devIdx < p->devCnt && portIdx < p->devArray[devIdx].oPortCnt );
@ -796,8 +802,11 @@ cw::rc_t cw::midi::device::alsa::send( handle_t h, unsigned devIdx, unsigned po
snd_seq_ev_set_direct(&ev);
snd_seq_ev_set_fixed(&ev);
uint8_t status_wo_ch = status;
if( midi::isChStatus(status) )
status_wo_ch = status & 0xf0;
switch( status & 0xf0 )
switch( status_wo_ch )
{
case kNoteOffMdId:
ev.type = SND_SEQ_EVENT_NOTEOFF;
@ -854,8 +863,32 @@ cw::rc_t cw::midi::device::alsa::send( handle_t h, unsigned devIdx, unsigned po
}
break;
case kSysRtClockMdId:
ev.type = SND_SEQ_EVENT_CLOCK;
break;
case kSysRtStartMdId:
ev.type =SND_SEQ_EVENT_START;
break;
case kSysRtContMdId:
ev.type = SND_SEQ_EVENT_CONTINUE;
break;
case kSysRtStopMdId:
ev.type = SND_SEQ_EVENT_STOP;
break;
case kSysRtSenseMdId:
ev.type = SND_SEQ_EVENT_SENSING;
break;
case kSysRtResetMdId:
ev.type = SND_SEQ_EVENT_RESET;
break;
default:
rc = _cmMpErrMsg1(kInvalidArgRC,0,"Cannot send an invalid MIDI status byte:0x%x.",status & 0xf0);
rc = _cmMpErrMsg1(kInvalidArgRC,0,"Cannot send an invalid MIDI status byte:0x%x.",status);
goto errLabel;
}