cmAudioPort.h/c: Added cmApDeviceLabelToIndex().

This commit is contained in:
kevin 2013-03-26 12:37:17 -07:00
parent 2bc819afb9
commit 4933586ef7
2 changed files with 18 additions and 1 deletions

View File

@ -202,7 +202,7 @@ cmApRC_t cmApFinalize()
unsigned cmApDeviceCount() unsigned cmApDeviceCount()
{ return _ap->devCnt; } { return _ap->devCnt; }
const char* cmApDeviceLabel( unsigned devIdx ) const char* cmApDeviceLabel( unsigned devIdx )
{ {
cmApDriver_t* dp; cmApDriver_t* dp;
unsigned di; unsigned di;
@ -217,6 +217,20 @@ const char* cmApDeviceLabel( unsigned devIdx )
return dp->deviceLabel(di); return dp->deviceLabel(di);
} }
unsigned cmApDeviceLabelToIndex( const cmChar_t* label )
{
unsigned n = cmApDeviceCount();
unsigned i;
for(i=0; i<n; ++i)
{
const cmChar_t* s = cmApDeviceLabel(i);
if( s!=NULL && strcmp(s,label)==0)
return i;
}
return cmInvalidIdx;
}
unsigned cmApDeviceChannelCount( unsigned devIdx, bool inputFl ) unsigned cmApDeviceChannelCount( unsigned devIdx, bool inputFl )
{ {
cmApDriver_t* dp; cmApDriver_t* dp;

View File

@ -95,6 +95,9 @@ extern "C" {
/// Get a textual description of the device at index 'devIdx'. /// Get a textual description of the device at index 'devIdx'.
const char* cmApDeviceLabel( unsigned devIdx ); const char* cmApDeviceLabel( unsigned devIdx );
/// Given an audio device label return the associated device index.
unsigned cmApDeviceLabelToIndex( const cmChar_t* label );
/// Get the count of audio input or output channesl on device at index 'devIdx'. /// Get the count of audio input or output channesl on device at index 'devIdx'.
unsigned cmApDeviceChannelCount( unsigned devIdx, bool inputFl ); unsigned cmApDeviceChannelCount( unsigned devIdx, bool inputFl );