Ver código fonte

cmAudioPort.h/c: Added cmApDeviceLabelToIndex().

master
kevin 11 anos atrás
pai
commit
4933586ef7
2 arquivos alterados com 18 adições e 1 exclusões
  1. 15
    1
      cmAudioPort.c
  2. 3
    0
      cmAudioPort.h

+ 15
- 1
cmAudioPort.c Ver arquivo

@@ -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 Ver arquivo

@@ -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
 

Carregando…
Cancelar
Salvar