Bläddra i källkod

cmAudioPort.h/c: Added cmApDeviceLabelToIndex().

master
kevin 11 år sedan
förälder
incheckning
4933586ef7
2 ändrade filer med 18 tillägg och 1 borttagningar
  1. 15
    1
      cmAudioPort.c
  2. 3
    0
      cmAudioPort.h

+ 15
- 1
cmAudioPort.c Visa fil

@@ -202,7 +202,7 @@ cmApRC_t      cmApFinalize()
202 202
 unsigned cmApDeviceCount()
203 203
 { return _ap->devCnt; }
204 204
 
205
-const char*   cmApDeviceLabel(          unsigned devIdx )
205
+const char*   cmApDeviceLabel( unsigned devIdx )
206 206
 {
207 207
   cmApDriver_t* dp;
208 208
   unsigned      di;
@@ -217,6 +217,20 @@ const char*   cmApDeviceLabel(          unsigned devIdx )
217 217
   return dp->deviceLabel(di);
218 218
 }
219 219
 
220
+unsigned      cmApDeviceLabelToIndex( const cmChar_t* label )
221
+{
222
+  unsigned n = cmApDeviceCount();
223
+  unsigned i;
224
+  for(i=0; i<n; ++i)
225
+  {
226
+    const cmChar_t* s = cmApDeviceLabel(i);
227
+    if( s!=NULL && strcmp(s,label)==0)
228
+      return i;
229
+  }
230
+  return cmInvalidIdx;
231
+}
232
+
233
+
220 234
 unsigned      cmApDeviceChannelCount(   unsigned devIdx, bool inputFl )
221 235
 {
222 236
   cmApDriver_t* dp;

+ 3
- 0
cmAudioPort.h Visa fil

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

Laddar…
Avbryt
Spara