cwIo.h/cpp : Added serial/midi/audio/socket/uiIsEnabled() functions.

This commit is contained in:
kevin 2024-06-10 16:34:52 -04:00
parent 2ee3c989de
commit 0edab4a76c
2 changed files with 33 additions and 5 deletions

View File

@ -976,7 +976,6 @@ namespace cw
goto errLabel; goto errLabel;
} }
if((rc = audio::device::alsa::destroy(p->alsaH)) != kOkRC ) if((rc = audio::device::alsa::destroy(p->alsaH)) != kOkRC )
{ {
rc = cwLogError(rc,"ALSA sub-system shutdown failed."); rc = cwLogError(rc,"ALSA sub-system shutdown failed.");
@ -989,7 +988,6 @@ namespace cw
goto errLabel; goto errLabel;
} }
if((rc = audio::device::destroy(p->audioH)) != kOkRC ) if((rc = audio::device::destroy(p->audioH)) != kOkRC )
{ {
rc = cwLogError(rc,"Audio device sub-system shutdown failed."); rc = cwLogError(rc,"Audio device sub-system shutdown failed.");
@ -2669,6 +2667,11 @@ cw::rc_t cw::io::timerStop( handle_t h, unsigned timerIdx )
// //
// Serial // Serial
// //
bool cw::io::serialIsEnabled( handle_t h )
{
io_t* p = _handleToPtr(h);
return p->serialN != 0;
}
unsigned cw::io::serialDeviceCount( handle_t h ) unsigned cw::io::serialDeviceCount( handle_t h )
{ {
@ -2719,9 +2722,18 @@ cw::rc_t cw::io::serialDeviceSend( handle_t h, unsigned devIdx, const void* byt
// MIDI // MIDI
// //
bool cw::io::midiIsEnabled( handle_t h )
{
io_t* p = _handleToPtr(h);
return p->midiH.isValid();
}
unsigned cw::io::midiDeviceCount( handle_t h ) unsigned cw::io::midiDeviceCount( handle_t h )
{ {
io_t* p = _handleToPtr(h); io_t* p = _handleToPtr(h);
if( !p->midiH.isValid() )
return 0;
return midi::device::count(p->midiH); return midi::device::count(p->midiH);
} }
@ -3222,6 +3234,11 @@ unsigned cw::io::audioGroupDeviceIndex( handle_t h, unsigned groupIdx, unsigned
// Socket // Socket
// //
bool cw::io::socketIsEnabled( handle_t h )
{
io_t* p = _handleToPtr(h);
return p->sockN != 0;
}
unsigned cw::io::socketCount( handle_t h ) unsigned cw::io::socketCount( handle_t h )
{ {
@ -3369,6 +3386,13 @@ cw::rc_t cw::io::socketSend( handle_t h, unsigned sockIdx, const void* data,
// //
// UI // UI
// //
bool cw::io::uiIsEnabled( handle_t h )
{
io_t* p = _handleToPtr(h);
return p->wsUiH.isValid();
}
unsigned cw::io::parentAndNameToAppId( handle_t h, unsigned parentAppId, const char* eleName ) unsigned cw::io::parentAndNameToAppId( handle_t h, unsigned parentAppId, const char* eleName )
{ {
rc_t rc; rc_t rc;

4
cwIo.h
View File

@ -211,6 +211,7 @@ namespace cw
// Serial // Serial
// //
bool serialIsEnabled( handle_t h );
unsigned serialDeviceCount( handle_t h ); unsigned serialDeviceCount( handle_t h );
unsigned serialDeviceIndex( handle_t h, const char* label ); unsigned serialDeviceIndex( handle_t h, const char* label );
const char* serialDeviceLabel( handle_t h, unsigned devIdx ); const char* serialDeviceLabel( handle_t h, unsigned devIdx );
@ -224,6 +225,7 @@ namespace cw
// MIDI // MIDI
// //
bool midiIsEnabled( handle_t h );
unsigned midiDeviceCount( handle_t h ); unsigned midiDeviceCount( handle_t h );
const char* midiDeviceName( handle_t h, unsigned devIdx ); const char* midiDeviceName( handle_t h, unsigned devIdx );
unsigned midiDeviceIndex( handle_t h, const char* devName ); unsigned midiDeviceIndex( handle_t h, const char* devName );
@ -295,6 +297,7 @@ namespace cw
// Socket // Socket
// //
bool socketIsEnabled( handle_t h );
unsigned socketCount( handle_t h ); unsigned socketCount( handle_t h );
unsigned socketLabelToIndex( handle_t h, const char* label ); unsigned socketLabelToIndex( handle_t h, const char* label );
unsigned socketUserId( handle_t h, unsigned sockIdx ); unsigned socketUserId( handle_t h, unsigned sockIdx );
@ -328,6 +331,7 @@ namespace cw
// UI // UI
// //
bool uiIsEnabled( handle_t h );
// Find id's associated with elements. // Find id's associated with elements.
unsigned parentAndNameToAppId( handle_t h, unsigned parentAppId, const char* eleName ); unsigned parentAndNameToAppId( handle_t h, unsigned parentAppId, const char* eleName );