Sfoglia il codice sorgente

cmAudioPort.h/c: Added cmApDeviceLabelToIndex().

master
kevin 11 anni fa
parent
commit
4933586ef7
2 ha cambiato i file con 18 aggiunte e 1 eliminazioni
  1. 15
    1
      cmAudioPort.c
  2. 3
    0
      cmAudioPort.h

+ 15
- 1
cmAudioPort.c Vedi File

202
 unsigned cmApDeviceCount()
202
 unsigned cmApDeviceCount()
203
 { return _ap->devCnt; }
203
 { return _ap->devCnt; }
204
 
204
 
205
-const char*   cmApDeviceLabel(          unsigned devIdx )
205
+const char*   cmApDeviceLabel( unsigned devIdx )
206
 {
206
 {
207
   cmApDriver_t* dp;
207
   cmApDriver_t* dp;
208
   unsigned      di;
208
   unsigned      di;
217
   return dp->deviceLabel(di);
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
 unsigned      cmApDeviceChannelCount(   unsigned devIdx, bool inputFl )
234
 unsigned      cmApDeviceChannelCount(   unsigned devIdx, bool inputFl )
221
 {
235
 {
222
   cmApDriver_t* dp;
236
   cmApDriver_t* dp;

+ 3
- 0
cmAudioPort.h Vedi File

95
   /// Get a textual description of the device at index 'devIdx'.
95
   /// Get a textual description of the device at index 'devIdx'.
96
   const char*   cmApDeviceLabel(          unsigned devIdx );
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
   /// Get the count of audio input or output channesl on device at index 'devIdx'.
101
   /// Get the count of audio input or output channesl on device at index 'devIdx'.
99
   unsigned      cmApDeviceChannelCount(   unsigned devIdx, bool inputFl );
102
   unsigned      cmApDeviceChannelCount(   unsigned devIdx, bool inputFl );
100
 
103
 

Loading…
Annulla
Salva