/[svn]/liblscp/trunk/src/device.c
ViewVC logotype

Diff of /liblscp/trunk/src/device.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 107 by capela, Fri Jun 4 21:06:59 2004 UTC revision 132 by capela, Fri Jun 18 14:19:19 2004 UTC
# Line 40  static lscp_driver_info_t *_lscp_driver_ Line 40  static lscp_driver_info_t *_lscp_driver_
40      char *pszToken;      char *pszToken;
41      char *pch;      char *pch;
42    
43      lscp_driver_info_reset(pDriverInfo);      // Lock this section up.
44        lscp_mutex_lock(pClient->mutex);
     if (lscp_client_query(pClient, pszQuery) != LSCP_OK)  
         return NULL;  
45    
46      pszResult = lscp_client_get_result(pClient);      lscp_driver_info_reset(pDriverInfo);
47      pszToken = lscp_strtok(pszResult, pszSeps, &(pch));      if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
48      while (pszToken) {          pszResult = lscp_client_get_result(pClient);
49          if (strcasecmp(pszToken, "DESCRIPTION") == 0) {          pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
50              pszToken = lscp_strtok(NULL, pszCrlf, &(pch));          while (pszToken) {
51              if (pszToken)              if (strcasecmp(pszToken, "DESCRIPTION") == 0) {
52                  pDriverInfo->description = lscp_unquote(&pszToken, 1);                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
53          }                  if (pszToken)
54          else if (strcasecmp(pszToken, "VERSION") == 0) {                      pDriverInfo->description = lscp_unquote(&pszToken, 1);
55              pszToken = lscp_strtok(NULL, pszCrlf, &(pch));              }
56              if (pszToken)              else if (strcasecmp(pszToken, "VERSION") == 0) {
57                  pDriverInfo->version = lscp_unquote(&pszToken, 1);                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
58          }                  if (pszToken)
59          else if (strcasecmp(pszToken, "PARAMETERS") == 0) {                      pDriverInfo->version = lscp_unquote(&pszToken, 1);
60              pszToken = lscp_strtok(NULL, pszCrlf, &(pch));              }
61              if (pszToken)              else if (strcasecmp(pszToken, "PARAMETERS") == 0) {
62                  pDriverInfo->parameters = lscp_szsplit_create(pszToken, ",");                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
63                    if (pszToken)
64                        pDriverInfo->parameters = lscp_szsplit_create(pszToken, ",");
65                }
66                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
67          }          }
         pszToken = lscp_strtok(NULL, pszSeps, &(pch));  
68      }      }
69        
70        // Unlock this section down.
71        lscp_mutex_unlock(pClient->mutex);
72    
73      return pDriverInfo;      return pDriverInfo;
74  }  }
# Line 86  const char ** lscp_get_available_audio_d Line 90  const char ** lscp_get_available_audio_d
90  {  {
91      const char *pszSeps = ",";      const char *pszSeps = ",";
92    
93        // Lock this section up.
94        lscp_mutex_lock(pClient->mutex);
95    
96      if (pClient->audio_drivers) {      if (pClient->audio_drivers) {
97          lscp_szsplit_destroy(pClient->audio_drivers);          lscp_szsplit_destroy(pClient->audio_drivers);
98          pClient->audio_drivers = NULL;          pClient->audio_drivers = NULL;
99      }      }
100    
101      if (lscp_client_query(pClient, "GET AVAILABLE_AUDIO_OUTPUT_DRIVERS\r\n") == LSCP_OK)      if (lscp_client_call(pClient, "GET AVAILABLE_AUDIO_OUTPUT_DRIVERS\r\n") == LSCP_OK)
102          pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);          pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);
103    
104        // Unlock this section down.
105        lscp_mutex_unlock(pClient->mutex);
106    
107      return (const char **) pClient->audio_drivers;      return (const char **) pClient->audio_drivers;
108  }  }
109    
# Line 201  lscp_status_t lscp_destroy_audio_device Line 211  lscp_status_t lscp_destroy_audio_device
211    
212    
213  /**  /**
214   *  Getting all created audio output devices.   *  Getting all created audio output device count.
215   *  GET AUDIO_OUTPUT_DEVICES   *  GET AUDIO_OUTPUT_DEVICES
216   *   *
217   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
218   *   *
219     *  @returns The current total number of audio devices on success,
220     *  -1 otherwise.
221     */
222    int lscp_get_audio_devices ( lscp_client_t *pClient )
223    {
224        int iAudioDevices = -1;
225    
226        // Lock this section up.
227        lscp_mutex_lock(pClient->mutex);
228    
229        if (lscp_client_call(pClient, "GET AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK)
230            iAudioDevices = atoi(lscp_client_get_result(pClient));
231    
232        // Unlock this section down.
233        lscp_mutex_unlock(pClient->mutex);
234    
235        return iAudioDevices;
236    }
237    
238    
239    /**
240     *  Getting all created audio output device list.
241     *  LIST AUDIO_OUTPUT_DEVICES
242     *
243     *  @param pClient  Pointer to client instance structure.
244     *
245   *  @returns An array of audio device number identifiers,   *  @returns An array of audio device number identifiers,
246   *  terminated with -1 on success, or NULL in case of failure.   *  terminated with -1 on success, or NULL in case of failure.
247   */   */
248  int *lscp_get_audio_devices ( lscp_client_t *pClient )  int *lscp_list_audio_devices ( lscp_client_t *pClient )
249  {  {
250      int *piAudioDevices = NULL;      const char *pszSeps = ",";
251    
252      if (pClient == NULL)      if (pClient == NULL)
253          return NULL;          return NULL;
254    
255      return piAudioDevices;      // Lock this section up.
256        lscp_mutex_lock(pClient->mutex);
257    
258        if (pClient->audio_devices) {
259            lscp_isplit_destroy(pClient->audio_devices);
260            pClient->audio_devices = NULL;
261        }
262    
263        if (lscp_client_call(pClient, "LIST AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK)
264            pClient->audio_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
265    
266        // Unlock this section down.
267        lscp_mutex_unlock(pClient->mutex);
268    
269        return pClient->audio_devices;
270  }  }
271    
272    
# Line 367  const char** lscp_get_available_midi_dri Line 417  const char** lscp_get_available_midi_dri
417  {  {
418      const char *pszSeps = ",";      const char *pszSeps = ",";
419    
420        // Lock this section up.
421        lscp_mutex_lock(pClient->mutex);
422    
423      if (pClient->midi_drivers) {      if (pClient->midi_drivers) {
424          lscp_szsplit_destroy(pClient->midi_drivers);          lscp_szsplit_destroy(pClient->midi_drivers);
425          pClient->midi_drivers = NULL;          pClient->midi_drivers = NULL;
426      }      }
427    
428      if (lscp_client_query(pClient, "GET AVAILABLE_MIDI_INPUT_DRIVERS\r\n") == LSCP_OK)      if (lscp_client_call(pClient, "GET AVAILABLE_MIDI_INPUT_DRIVERS\r\n") == LSCP_OK)
429          pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);          pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);
430    
431        // Unlock this section up.
432        lscp_mutex_unlock(pClient->mutex);
433    
434      return (const char **) pClient->midi_drivers;      return (const char **) pClient->midi_drivers;
435  }  }
436    
# Line 484  lscp_status_t lscp_destroy_midi_device ( Line 540  lscp_status_t lscp_destroy_midi_device (
540    
541    
542  /**  /**
543   *  Getting all created MIDI input devices.   *  Getting all created MIDI intput device count.
544   *  GET MIDI_INPUT_DEVICES   *  GET MIDI_INPUT_DEVICES
545   *   *
546   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
547   *   *
548     *  @returns The current total number of MIDI devices on success,
549     *  -1 otherwise.
550     */
551    int lscp_get_midi_devices ( lscp_client_t *pClient )
552    {
553        int iMidiDevices = -1;
554    
555        // Lock this section up.
556        lscp_mutex_lock(pClient->mutex);
557    
558        if (lscp_client_call(pClient, "GET MIDI_INPUT_DEVICES\r\n") == LSCP_OK)
559            iMidiDevices = atoi(lscp_client_get_result(pClient));
560            
561        // Unlock this section down.
562        lscp_mutex_unlock(pClient->mutex);
563    
564        return iMidiDevices;
565    }
566    
567    
568    /**
569     *  Getting all created MIDI intput device list.
570     *  LIST MIDI_INPUT_DEVICES
571     *
572     *  @param pClient  Pointer to client instance structure.
573     *
574   *  @returns An array of MIDI device number identifiers,   *  @returns An array of MIDI device number identifiers,
575   *  terminated with -1 on success, or NULL in case of failure.   *  terminated with -1 on success, or NULL in case of failure.
576   */   */
577  int *lscp_get_midi_devices ( lscp_client_t *pClient )  int *lscp_list_midi_devices ( lscp_client_t *pClient )
578  {  {
579      int *piMidiDevices = NULL;      const char *pszSeps = ",";
580    
581      if (pClient == NULL)      if (pClient == NULL)
582          return NULL;          return NULL;
583    
584      return piMidiDevices;      // Lock this section up.
585        lscp_mutex_lock(pClient->mutex);
586    
587        if (pClient->midi_devices) {
588            lscp_isplit_destroy(pClient->midi_devices);
589            pClient->midi_devices = NULL;
590        }
591    
592        if (lscp_client_call(pClient, "LIST MIDI_INPUT_DEVICES\r\n") == LSCP_OK)
593            pClient->midi_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
594    
595        // Unlock this section down.
596        lscp_mutex_unlock(pClient->mutex);
597    
598        return pClient->midi_devices;
599  }  }
600    
601    

Legend:
Removed from v.107  
changed lines
  Added in v.132

  ViewVC Help
Powered by ViewVC