/[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 171 by capela, Mon Jul 5 16:26:44 2004 UTC
# Line 25  Line 25 
25    
26  // Local prototypes.  // Local prototypes.
27    
28  static lscp_driver_info_t *_lscp_driver_info_query (lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, const char *pszQuery);  static lscp_driver_info_t *_lscp_driver_info_query (lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, char *pszQuery);
29    static lscp_device_info_t *_lscp_device_info_query (lscp_client_t *pClient, lscp_device_info_t *pDeviceInfo, char *pszQuery);
30    static lscp_param_info_t  *_lscp_param_info_query  (lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, int cchMaxQuery, lscp_param_t *pDepList);
31    
32    static lscp_device_port_info_t *_lscp_device_port_info_query (lscp_client_t *pClient, lscp_device_port_info_t *pDevicePortInfo, char *pszQuery);
33    
34    
35  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
36  // Local funtions.  // Local funtions.
37    
38  // Common driver type query command.  // Common driver type query command.
39  static lscp_driver_info_t *_lscp_driver_info_query ( lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, const char *pszQuery )  static lscp_driver_info_t *_lscp_driver_info_query ( lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, char *pszQuery )
40  {  {
41      const char *pszResult;      const char *pszResult;
42      const char *pszSeps = ":";      const char *pszSeps = ":";
# Line 40  static lscp_driver_info_t *_lscp_driver_ Line 44  static lscp_driver_info_t *_lscp_driver_
44      char *pszToken;      char *pszToken;
45      char *pch;      char *pch;
46    
47        // Lock this section up.
48        lscp_mutex_lock(pClient->mutex);
49    
50      lscp_driver_info_reset(pDriverInfo);      lscp_driver_info_reset(pDriverInfo);
51        if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
52            pszResult = lscp_client_get_result(pClient);
53            pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
54            while (pszToken) {
55                if (strcasecmp(pszToken, "DESCRIPTION") == 0) {
56                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
57                    if (pszToken)
58                        pDriverInfo->description = lscp_unquote(&pszToken, 1);
59                }
60                else if (strcasecmp(pszToken, "VERSION") == 0) {
61                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
62                    if (pszToken)
63                        pDriverInfo->version = lscp_unquote(&pszToken, 1);
64                }
65                else if (strcasecmp(pszToken, "PARAMETERS") == 0) {
66                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
67                    if (pszToken)
68                        pDriverInfo->parameters = lscp_szsplit_create(pszToken, ",");
69                }
70                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
71            }
72        }
73        
74        // Unlock this section down.
75        lscp_mutex_unlock(pClient->mutex);
76    
77      if (lscp_client_query(pClient, pszQuery) != LSCP_OK)      return pDriverInfo;
78          return NULL;  }
79    
80    
81    // Common device info query command.
82    static lscp_device_info_t *_lscp_device_info_query ( lscp_client_t *pClient, lscp_device_info_t *pDeviceInfo, char *pszQuery )
83    {
84        const char *pszResult;
85        const char *pszSeps = ":";
86        const char *pszCrlf = "\r\n";
87        char *pszToken;
88        char *pch;
89        char *pszKey;
90    
91        // Lock this section up.
92        lscp_mutex_lock(pClient->mutex);
93    
94      pszResult = lscp_client_get_result(pClient);      lscp_device_info_reset(pDeviceInfo);
95      pszToken = lscp_strtok(pszResult, pszSeps, &(pch));      if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
96      while (pszToken) {          pszResult = lscp_client_get_result(pClient);
97          if (strcasecmp(pszToken, "DESCRIPTION") == 0) {          pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
98              pszToken = lscp_strtok(NULL, pszCrlf, &(pch));          while (pszToken) {
99              if (pszToken)              if (strcasecmp(pszToken, "DRIVER") == 0) {
100                  pDriverInfo->description = lscp_unquote(&pszToken, 1);                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
101                    if (pszToken)
102                        pDeviceInfo->driver = lscp_unquote(&pszToken, 1);
103                }
104                else {
105                    pszKey = pszToken;
106                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
107                    if (pszToken)
108                        lscp_plist_append(&(pDeviceInfo->params), pszKey, lscp_unquote(&pszToken, 0));
109                }
110                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
111          }          }
112          else if (strcasecmp(pszToken, "VERSION") == 0) {      }
113              pszToken = lscp_strtok(NULL, pszCrlf, &(pch));  
114              if (pszToken)      // Unlock this section down.
115                  pDriverInfo->version = lscp_unquote(&pszToken, 1);      lscp_mutex_unlock(pClient->mutex);
116    
117        return pDeviceInfo;
118    }
119    
120    
121    // Common device channel/port info query command.
122    static lscp_device_port_info_t *_lscp_device_port_info_query ( lscp_client_t *pClient, lscp_device_port_info_t *pDevicePortInfo, char *pszQuery )
123    {
124        const char *pszResult;
125        const char *pszSeps = ":";
126        const char *pszCrlf = "\r\n";
127        char *pszToken;
128        char *pch;
129        char *pszKey;
130    
131        // Lock this section up.
132        lscp_mutex_lock(pClient->mutex);
133    
134        lscp_device_port_info_reset(pDevicePortInfo);
135        if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
136            pszResult = lscp_client_get_result(pClient);
137            pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
138            while (pszToken) {
139                if (strcasecmp(pszToken, "NAME") == 0) {
140                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
141                    if (pszToken)
142                        pDevicePortInfo->name = lscp_unquote(&pszToken, 1);
143                }
144                else {
145                    pszKey = pszToken;
146                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
147                    if (pszToken)
148                        lscp_plist_append(&(pDevicePortInfo->params), pszKey, lscp_unquote(&pszToken, 0));
149                }
150                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
151          }          }
152          else if (strcasecmp(pszToken, "PARAMETERS") == 0) {      }
153              pszToken = lscp_strtok(NULL, pszCrlf, &(pch));  
154              if (pszToken)      // Unlock this section down.
155                  pDriverInfo->parameters = lscp_szsplit_create(pszToken, ",");      lscp_mutex_unlock(pClient->mutex);
156    
157        return pDevicePortInfo;
158    }
159    
160    
161    // Common parameter info query command.
162    static lscp_param_info_t *_lscp_param_info_query ( lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, int cchMaxQuery, lscp_param_t *pDepList )
163    {
164        const char *pszResult;
165        const char *pszSeps = ":";
166        const char *pszCrlf = "\r\n";
167        char *pszToken;
168        char *pch;
169    
170        // Lock this section up.
171        lscp_mutex_lock(pClient->mutex);
172    
173        lscp_param_info_reset(pParamInfo);
174        lscp_param_concat(pszQuery, cchMaxQuery, pDepList);
175        if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
176            pszResult = lscp_client_get_result(pClient);
177            pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
178            while (pszToken) {
179                if (strcasecmp(pszToken, "TYPE") == 0) {
180                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
181                    if (pszToken) {
182                        pszToken = lscp_unquote(&pszToken, 0);
183                        if (strcasecmp(pszToken, "BOOL") == 0)
184                            pParamInfo->type = LSCP_TYPE_BOOL;
185                        else if (strcasecmp(pszToken, "INT") == 0)
186                            pParamInfo->type = LSCP_TYPE_INT;
187                        else if (strcasecmp(pszToken, "FLOAT") == 0)
188                            pParamInfo->type = LSCP_TYPE_FLOAT;
189                        else if (strcasecmp(pszToken, "STRING") == 0)
190                            pParamInfo->type = LSCP_TYPE_STRING;
191                    }
192                }
193                else if (strcasecmp(pszToken, "DESCRIPTION") == 0) {
194                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
195                    if (pszToken)
196                        pParamInfo->description = lscp_unquote(&pszToken, 1);
197                }
198                else if (strcasecmp(pszToken, "MANDATORY") == 0) {
199                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
200                    if (pszToken)
201                        pParamInfo->mandatory = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0);
202                }
203                else if (strcasecmp(pszToken, "FIX") == 0) {
204                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
205                    if (pszToken)
206                        pParamInfo->fix = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0);
207                }
208                else if (strcasecmp(pszToken, "MULTIPLICITY") == 0) {
209                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
210                    if (pszToken)
211                        pParamInfo->multiplicity = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0);
212                }
213                else if (strcasecmp(pszToken, "DEPENDS") == 0) {
214                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
215                    if (pszToken)
216                        pParamInfo->depends = lscp_szsplit_create(pszToken, ",");
217                }
218                else if (strcasecmp(pszToken, "DEFAULT") == 0) {
219                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
220                    if (pszToken)
221                        pParamInfo->defaultv = lscp_unquote(&pszToken, 1);
222                }
223                else if (strcasecmp(pszToken, "RANGE_MIN") == 0) {
224                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
225                    if (pszToken)
226                        pParamInfo->range_min = lscp_unquote(&pszToken, 1);
227                }
228                else if (strcasecmp(pszToken, "RANGE_MAX") == 0) {
229                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
230                    if (pszToken)
231                        pParamInfo->range_max = lscp_unquote(&pszToken, 1);
232                }
233                else if (strcasecmp(pszToken, "POSSIBILITIES") == 0) {
234                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
235                    if (pszToken)
236                        pParamInfo->possibilities = lscp_szsplit_create(pszToken, ",");
237                }
238                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
239          }          }
         pszToken = lscp_strtok(NULL, pszSeps, &(pch));  
240      }      }
241    
242      return pDriverInfo;      // Unlock this section down.
243        lscp_mutex_unlock(pClient->mutex);
244    
245        return pParamInfo;
246  }  }
247    
248    
# Line 86  const char ** lscp_get_available_audio_d Line 262  const char ** lscp_get_available_audio_d
262  {  {
263      const char *pszSeps = ",";      const char *pszSeps = ",";
264    
265        // Lock this section up.
266        lscp_mutex_lock(pClient->mutex);
267    
268      if (pClient->audio_drivers) {      if (pClient->audio_drivers) {
269          lscp_szsplit_destroy(pClient->audio_drivers);          lscp_szsplit_destroy(pClient->audio_drivers);
270          pClient->audio_drivers = NULL;          pClient->audio_drivers = NULL;
271      }      }
272    
273      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)
274          pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);          pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);
275    
276        // Unlock this section down.
277        lscp_mutex_unlock(pClient->mutex);
278    
279      return (const char **) pClient->audio_drivers;      return (const char **) pClient->audio_drivers;
280  }  }
281    
# Line 116  lscp_driver_info_t* lscp_get_audio_drive Line 298  lscp_driver_info_t* lscp_get_audio_drive
298          return NULL;          return NULL;
299    
300      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver);      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver);
301      return _lscp_driver_info_query(pClient, &(pClient->audio_info), szQuery);      return _lscp_driver_info_query(pClient, &(pClient->audio_driver_info), szQuery);
302  }  }
303    
304    
# Line 134  lscp_driver_info_t* lscp_get_audio_drive Line 316  lscp_driver_info_t* lscp_get_audio_drive
316   */   */
317  lscp_param_info_t *lscp_get_audio_driver_param_info ( lscp_client_t *pClient, const char *pszAudioDriver, const char *pszParam, lscp_param_t *pDepList )  lscp_param_info_t *lscp_get_audio_driver_param_info ( lscp_client_t *pClient, const char *pszAudioDriver, const char *pszParam, lscp_param_t *pDepList )
318  {  {
319      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
320    
321      if (pClient == NULL)      if (pClient == NULL)
322          return NULL;          return NULL;
# Line 142  lscp_param_info_t *lscp_get_audio_driver Line 324  lscp_param_info_t *lscp_get_audio_driver
324          return NULL;          return NULL;
325      if (pszParam == NULL)      if (pszParam == NULL)
326          return NULL;          return NULL;
     if (pDepList == NULL)  
         return NULL;  
327    
328      return pParamInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO %s %s", pszAudioDriver, pszParam);
329        return _lscp_param_info_query(pClient, &(pClient->audio_param_info), szQuery, sizeof(szQuery), pDepList);
330  }  }
331    
332    
# Line 165  lscp_param_info_t *lscp_get_audio_driver Line 346  lscp_param_info_t *lscp_get_audio_driver
346   */   */
347  int lscp_create_audio_device ( lscp_client_t *pClient, const char *pszAudioDriver, lscp_param_t *pParams )  int lscp_create_audio_device ( lscp_client_t *pClient, const char *pszAudioDriver, lscp_param_t *pParams )
348  {  {
349        char szQuery[LSCP_BUFSIZ];
350      int iAudioDevice = -1;      int iAudioDevice = -1;
351    
352      if (pClient == NULL)      if (pClient == NULL)
353          return -1;          return iAudioDevice;
354      if (pszAudioDriver == NULL)      if (pszAudioDriver == NULL)
355          return -1;          return iAudioDevice;
356      if (pParams == NULL)  
357          return -1;      // Lock this section up.
358        lscp_mutex_lock(pClient->mutex);
359    
360        sprintf(szQuery, "CREATE AUDIO_OUTPUT_DEVICE %s", pszAudioDriver);
361        lscp_param_concat(szQuery, sizeof(szQuery), pParams);
362        if (lscp_client_call(pClient, szQuery) == LSCP_OK)
363            iAudioDevice = atoi(lscp_client_get_result(pClient));
364    
365        // Unlock this section down.
366        lscp_mutex_unlock(pClient->mutex);
367    
368      return iAudioDevice;      return iAudioDevice;
369  }  }
# Line 190  int lscp_create_audio_device ( lscp_clie Line 381  int lscp_create_audio_device ( lscp_clie
381  lscp_status_t lscp_destroy_audio_device ( lscp_client_t *pClient, int iAudioDevice )  lscp_status_t lscp_destroy_audio_device ( lscp_client_t *pClient, int iAudioDevice )
382  {  {
383      lscp_status_t ret = LSCP_FAILED;      lscp_status_t ret = LSCP_FAILED;
384        char szQuery[LSCP_BUFSIZ];
385    
386      if (pClient == NULL)      if (pClient == NULL)
387          return ret;          return ret;
388      if (iAudioDevice < 0)      if (iAudioDevice < 0)
389          return ret;          return ret;
390    
391      return ret;      sprintf(szQuery, "DESTROY AUDIO_OUTPUT_DEVICE %d\r\n", iAudioDevice);
392        return lscp_client_query(pClient, szQuery);
393  }  }
394    
395    
396  /**  /**
397   *  Getting all created audio output devices.   *  Getting all created audio output device count.
398   *  GET AUDIO_OUTPUT_DEVICES   *  GET AUDIO_OUTPUT_DEVICES
399   *   *
400   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
401   *   *
402     *  @returns The current total number of audio devices on success,
403     *  -1 otherwise.
404     */
405    int lscp_get_audio_devices ( lscp_client_t *pClient )
406    {
407        int iAudioDevices = -1;
408    
409        // Lock this section up.
410        lscp_mutex_lock(pClient->mutex);
411    
412        if (lscp_client_call(pClient, "GET AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK)
413            iAudioDevices = atoi(lscp_client_get_result(pClient));
414    
415        // Unlock this section down.
416        lscp_mutex_unlock(pClient->mutex);
417    
418        return iAudioDevices;
419    }
420    
421    
422    /**
423     *  Getting all created audio output device list.
424     *  LIST AUDIO_OUTPUT_DEVICES
425     *
426     *  @param pClient  Pointer to client instance structure.
427     *
428   *  @returns An array of audio device number identifiers,   *  @returns An array of audio device number identifiers,
429   *  terminated with -1 on success, or NULL in case of failure.   *  terminated with -1 on success, or NULL in case of failure.
430   */   */
431  int *lscp_get_audio_devices ( lscp_client_t *pClient )  int *lscp_list_audio_devices ( lscp_client_t *pClient )
432  {  {
433      int *piAudioDevices = NULL;      const char *pszSeps = ",";
434    
435      if (pClient == NULL)      if (pClient == NULL)
436          return NULL;          return NULL;
437    
438      return piAudioDevices;      // Lock this section up.
439        lscp_mutex_lock(pClient->mutex);
440    
441        if (pClient->audio_devices) {
442            lscp_isplit_destroy(pClient->audio_devices);
443            pClient->audio_devices = NULL;
444        }
445    
446        if (lscp_client_call(pClient, "LIST AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK)
447            pClient->audio_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
448    
449        // Unlock this section down.
450        lscp_mutex_unlock(pClient->mutex);
451    
452        return pClient->audio_devices;
453  }  }
454    
455    
# Line 232  int *lscp_get_audio_devices ( lscp_clien Line 465  int *lscp_get_audio_devices ( lscp_clien
465   */   */
466  lscp_device_info_t *lscp_get_audio_device_info ( lscp_client_t *pClient, int iAudioDevice )  lscp_device_info_t *lscp_get_audio_device_info ( lscp_client_t *pClient, int iAudioDevice )
467  {  {
468      lscp_device_info_t *pDeviceInfo = NULL;      char szQuery[LSCP_BUFSIZ];
469    
470      if (pClient == NULL)      if (pClient == NULL)
471          return NULL;          return NULL;
472      if (iAudioDevice < 0)      if (iAudioDevice < 0)
473          return NULL;          return NULL;
474    
475      return pDeviceInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_DEVICE INFO %d\r\n", iAudioDevice);
476        return _lscp_device_info_query(pClient, &(pClient->audio_device_info), szQuery);
477  }  }
478    
479    
480  /**  /**
481   *  Changing settings of audio output devices.   *  Changing settings of audio output devices.
482   *  SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param> <value>   *  SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param>=<value>
483   *   *
484   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
485   *  @param iAudioDevice Audio device number identifier.   *  @param iAudioDevice Audio device number identifier.
# Line 255  lscp_device_info_t *lscp_get_audio_devic Line 489  lscp_device_info_t *lscp_get_audio_devic
489   */   */
490  lscp_status_t lscp_set_audio_device_param ( lscp_client_t *pClient, int iAudioDevice, lscp_param_t *pParam )  lscp_status_t lscp_set_audio_device_param ( lscp_client_t *pClient, int iAudioDevice, lscp_param_t *pParam )
491  {  {
492      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
493    
494      if (pClient == NULL)      if (pClient == NULL)
495          return ret;          return LSCP_FAILED;
496      if (iAudioDevice < 0)      if (iAudioDevice < 0)
497          return ret;          return LSCP_FAILED;
498      if (pParam == NULL)      if (pParam == NULL)
499          return ret;          return LSCP_FAILED;
500    
501      return ret;      sprintf(szQuery, "SET AUDIO_OUTPUT_DEVICE_PARAMETER %d", iAudioDevice);
502        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
503        return lscp_client_query(pClient, szQuery);
504  }  }
505    
506    
# Line 276  lscp_status_t lscp_set_audio_device_para Line 512  lscp_status_t lscp_set_audio_device_para
512   *  @param iAudioDevice     Audio device number identifier.   *  @param iAudioDevice     Audio device number identifier.
513   *  @param iAudioChannel    Audio channel number.   *  @param iAudioChannel    Audio channel number.
514   *   *
515   *  @returns A pointer to a @ref lscp_device_channel_info_t structure,   *  @returns A pointer to a @ref lscp_device_port_info_t structure,
516   *  with the given audio channel information, or NULL in case of failure.   *  with the given audio channel information, or NULL in case of failure.
517   */   */
518  lscp_device_channel_info_t* lscp_get_audio_channel_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel )  lscp_device_port_info_t* lscp_get_audio_channel_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel )
519  {  {
520      lscp_device_channel_info_t *pDevChannelInfo = NULL;      char szQuery[LSCP_BUFSIZ];
521    
522      if (pClient == NULL)      if (pClient == NULL)
523          return NULL;          return NULL;
# Line 290  lscp_device_channel_info_t* lscp_get_aud Line 526  lscp_device_channel_info_t* lscp_get_aud
526      if (iAudioChannel < 0)      if (iAudioChannel < 0)
527          return NULL;          return NULL;
528    
529      return pDevChannelInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL INFO %d %d\r\n", iAudioDevice, iAudioChannel);
530        return _lscp_device_port_info_query(pClient, &(pClient->audio_channel_info), szQuery);
531  }  }
532    
533    
# Line 308  lscp_device_channel_info_t* lscp_get_aud Line 545  lscp_device_channel_info_t* lscp_get_aud
545   */   */
546  lscp_param_info_t* lscp_get_audio_channel_param_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, const char *pszParam )  lscp_param_info_t* lscp_get_audio_channel_param_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, const char *pszParam )
547  {  {
548      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
549    
550      if (pClient == NULL)      if (pClient == NULL)
551          return NULL;          return NULL;
# Line 319  lscp_param_info_t* lscp_get_audio_channe Line 556  lscp_param_info_t* lscp_get_audio_channe
556      if (pszParam == NULL)      if (pszParam == NULL)
557          return NULL;          return NULL;
558    
559      return pParamInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO %d %d %s", iAudioDevice, iAudioChannel, pszParam);
560        return _lscp_param_info_query(pClient, &(pClient->audio_channel_param_info), szQuery, sizeof(szQuery), NULL);
561  }  }
562    
563    
# Line 336  lscp_param_info_t* lscp_get_audio_channe Line 574  lscp_param_info_t* lscp_get_audio_channe
574   */   */
575  lscp_status_t lscp_set_audio_channel_param ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, lscp_param_t *pParam )  lscp_status_t lscp_set_audio_channel_param ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, lscp_param_t *pParam )
576  {  {
577      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
578    
579      if (pClient == NULL)      if (pClient == NULL)
580          return ret;          return LSCP_FAILED;
581      if (iAudioDevice < 0)      if (iAudioDevice < 0)
582          return ret;          return LSCP_FAILED;
583      if (iAudioChannel < 0)      if (iAudioChannel < 0)
584          return ret;          return LSCP_FAILED;
585      if (pParam == NULL)      if (pParam == NULL)
586          return ret;          return LSCP_FAILED;
587    
588      return ret;      sprintf(szQuery, "SET AUDIO_OUTPUT_CHANNEL_PARAMETER %d %d", iAudioDevice, iAudioChannel);
589        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
590        return lscp_client_query(pClient, szQuery);
591  }  }
592    
593    
# Line 367  const char** lscp_get_available_midi_dri Line 607  const char** lscp_get_available_midi_dri
607  {  {
608      const char *pszSeps = ",";      const char *pszSeps = ",";
609    
610        // Lock this section up.
611        lscp_mutex_lock(pClient->mutex);
612    
613      if (pClient->midi_drivers) {      if (pClient->midi_drivers) {
614          lscp_szsplit_destroy(pClient->midi_drivers);          lscp_szsplit_destroy(pClient->midi_drivers);
615          pClient->midi_drivers = NULL;          pClient->midi_drivers = NULL;
616      }      }
617    
618      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)
619          pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);          pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps);
620    
621        // Unlock this section up.
622        lscp_mutex_unlock(pClient->mutex);
623    
624      return (const char **) pClient->midi_drivers;      return (const char **) pClient->midi_drivers;
625  }  }
626    
# Line 397  lscp_driver_info_t* lscp_get_midi_driver Line 643  lscp_driver_info_t* lscp_get_midi_driver
643          return NULL;          return NULL;
644    
645      sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver);      sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver);
646      return _lscp_driver_info_query(pClient, &(pClient->midi_info), szQuery);      return _lscp_driver_info_query(pClient, &(pClient->midi_driver_info), szQuery);
647  }  }
648    
649    
# Line 417  lscp_driver_info_t* lscp_get_midi_driver Line 663  lscp_driver_info_t* lscp_get_midi_driver
663   */   */
664  lscp_param_info_t *lscp_get_midi_driver_param_info ( lscp_client_t *pClient, const char *pszMidiDriver, const char *pszParam, lscp_param_t *pDepList )  lscp_param_info_t *lscp_get_midi_driver_param_info ( lscp_client_t *pClient, const char *pszMidiDriver, const char *pszParam, lscp_param_t *pDepList )
665  {  {
666      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
667    
668      if (pClient == NULL)      if (pClient == NULL)
669          return NULL;          return NULL;
# Line 425  lscp_param_info_t *lscp_get_midi_driver_ Line 671  lscp_param_info_t *lscp_get_midi_driver_
671          return NULL;          return NULL;
672      if (pszParam == NULL)      if (pszParam == NULL)
673          return NULL;          return NULL;
     if (pDepList == NULL)  
         return NULL;  
674    
675      return pParamInfo;      sprintf(szQuery, "GET MIDI_INPUT_DRIVER_PARAMETER INFO %s %s", pszMidiDriver, pszParam);
676        return _lscp_param_info_query(pClient, &(pClient->midi_param_info), szQuery, sizeof(szQuery), pDepList);
677  }  }
678    
679    
# Line 448  lscp_param_info_t *lscp_get_midi_driver_ Line 693  lscp_param_info_t *lscp_get_midi_driver_
693   */   */
694  int lscp_create_midi_device ( lscp_client_t *pClient, const char *pszMidiDriver, lscp_param_t *pParams )  int lscp_create_midi_device ( lscp_client_t *pClient, const char *pszMidiDriver, lscp_param_t *pParams )
695  {  {
696        char szQuery[LSCP_BUFSIZ];
697      int iMidiDevice = -1;      int iMidiDevice = -1;
698    
699      if (pClient == NULL)      if (pClient == NULL)
700          return -1;          return iMidiDevice;
701      if (pszMidiDriver == NULL)      if (pszMidiDriver == NULL)
702          return -1;          return iMidiDevice;
703      if (pParams == NULL)  
704          return -1;      // Lock this section up.
705        lscp_mutex_lock(pClient->mutex);
706    
707        sprintf(szQuery, "CREATE MIDI_INPUT_DEVICE %s", pszMidiDriver);
708        lscp_param_concat(szQuery, sizeof(szQuery), pParams);
709        if (lscp_client_call(pClient, szQuery) == LSCP_OK)
710            iMidiDevice = atoi(lscp_client_get_result(pClient));
711    
712        // Unlock this section down.
713        lscp_mutex_unlock(pClient->mutex);
714    
715      return iMidiDevice;      return iMidiDevice;
716  }  }
# Line 473  int lscp_create_midi_device ( lscp_clien Line 728  int lscp_create_midi_device ( lscp_clien
728  lscp_status_t lscp_destroy_midi_device ( lscp_client_t *pClient, int iMidiDevice )  lscp_status_t lscp_destroy_midi_device ( lscp_client_t *pClient, int iMidiDevice )
729  {  {
730      lscp_status_t ret = LSCP_FAILED;      lscp_status_t ret = LSCP_FAILED;
731        char szQuery[LSCP_BUFSIZ];
732    
733      if (pClient == NULL)      if (pClient == NULL)
734          return ret;          return ret;
735      if (iMidiDevice < 0)      if (iMidiDevice < 0)
736          return ret;          return ret;
737    
738      return ret;      sprintf(szQuery, "DESTROY MIDI_INPUT_DEVICE %d\r\n", iMidiDevice);
739        return lscp_client_query(pClient, szQuery);
740  }  }
741    
742    
743  /**  /**
744   *  Getting all created MIDI input devices.   *  Getting all created MIDI intput device count.
745   *  GET MIDI_INPUT_DEVICES   *  GET MIDI_INPUT_DEVICES
746   *   *
747   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
748   *   *
749     *  @returns The current total number of MIDI devices on success,
750     *  -1 otherwise.
751     */
752    int lscp_get_midi_devices ( lscp_client_t *pClient )
753    {
754        int iMidiDevices = -1;
755    
756        // Lock this section up.
757        lscp_mutex_lock(pClient->mutex);
758    
759        if (lscp_client_call(pClient, "GET MIDI_INPUT_DEVICES\r\n") == LSCP_OK)
760            iMidiDevices = atoi(lscp_client_get_result(pClient));
761            
762        // Unlock this section down.
763        lscp_mutex_unlock(pClient->mutex);
764    
765        return iMidiDevices;
766    }
767    
768    
769    /**
770     *  Getting all created MIDI intput device list.
771     *  LIST MIDI_INPUT_DEVICES
772     *
773     *  @param pClient  Pointer to client instance structure.
774     *
775   *  @returns An array of MIDI device number identifiers,   *  @returns An array of MIDI device number identifiers,
776   *  terminated with -1 on success, or NULL in case of failure.   *  terminated with -1 on success, or NULL in case of failure.
777   */   */
778  int *lscp_get_midi_devices ( lscp_client_t *pClient )  int *lscp_list_midi_devices ( lscp_client_t *pClient )
779  {  {
780      int *piMidiDevices = NULL;      const char *pszSeps = ",";
781    
782      if (pClient == NULL)      if (pClient == NULL)
783          return NULL;          return NULL;
784    
785      return piMidiDevices;      // Lock this section up.
786        lscp_mutex_lock(pClient->mutex);
787    
788        if (pClient->midi_devices) {
789            lscp_isplit_destroy(pClient->midi_devices);
790            pClient->midi_devices = NULL;
791        }
792    
793        if (lscp_client_call(pClient, "LIST MIDI_INPUT_DEVICES\r\n") == LSCP_OK)
794            pClient->midi_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
795    
796        // Unlock this section down.
797        lscp_mutex_unlock(pClient->mutex);
798    
799        return pClient->midi_devices;
800  }  }
801    
802    
# Line 515  int *lscp_get_midi_devices ( lscp_client Line 812  int *lscp_get_midi_devices ( lscp_client
812   */   */
813  lscp_device_info_t* lscp_get_midi_device_info ( lscp_client_t *pClient, int iMidiDevice )  lscp_device_info_t* lscp_get_midi_device_info ( lscp_client_t *pClient, int iMidiDevice )
814  {  {
815      lscp_device_info_t *pDeviceInfo = NULL;      char szQuery[LSCP_BUFSIZ];
816    
817      if (pClient == NULL)      if (pClient == NULL)
818          return NULL;          return NULL;
819      if (iMidiDevice < 0)      if (iMidiDevice < 0)
820          return NULL;          return NULL;
821    
822      return pDeviceInfo;      sprintf(szQuery, "GET MIDI_INPUT_DEVICE INFO %d\r\n", iMidiDevice);
823        return _lscp_device_info_query(pClient, &(pClient->midi_device_info), szQuery);
824  }  }
825    
826    
827  /**  /**
828   *  Changing settings of MIDI input devices.   *  Changing settings of MIDI input devices.
829   *  SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param> <value>   *  SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param>=<value>
830   *   *
831   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
832   *  @param iMidiDevice  MIDI device number identifier.   *  @param iMidiDevice  MIDI device number identifier.
# Line 538  lscp_device_info_t* lscp_get_midi_device Line 836  lscp_device_info_t* lscp_get_midi_device
836   */   */
837  lscp_status_t lscp_set_midi_device_param ( lscp_client_t *pClient, int iMidiDevice, lscp_param_t *pParam )  lscp_status_t lscp_set_midi_device_param ( lscp_client_t *pClient, int iMidiDevice, lscp_param_t *pParam )
838  {  {
839      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
840    
841      if (pClient == NULL)      if (pClient == NULL)
842          return ret;          return LSCP_FAILED;
843      if (iMidiDevice < 0)      if (iMidiDevice < 0)
844          return ret;          return LSCP_FAILED;
845      if (pParam == NULL)      if (pParam == NULL)
846          return ret;          return LSCP_FAILED;
847    
848      return ret;      sprintf(szQuery, "SET MIDI_INPUT_DEVICE_PARAMETER %d", iMidiDevice);
849        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
850        return lscp_client_query(pClient, szQuery);
851  }  }
852    
853    
# Line 559  lscp_status_t lscp_set_midi_device_param Line 859  lscp_status_t lscp_set_midi_device_param
859   *  @param iMidiDevice  MIDI device number identifier.   *  @param iMidiDevice  MIDI device number identifier.
860   *  @param iMidiPort    MIDI port number.   *  @param iMidiPort    MIDI port number.
861   *   *
862   *  @returns A pointer to a @ref lscp_device_channel_info_t structure,   *  @returns A pointer to a @ref lscp_device_port_info_t structure,
863   *  with the given MIDI port information, or NULL in case of failure.   *  with the given MIDI port information, or NULL in case of failure.
864   */   */
865  lscp_device_channel_info_t* lscp_get_midi_port_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort )  lscp_device_port_info_t* lscp_get_midi_port_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort )
866  {  {
867      lscp_device_channel_info_t *pDevChannelInfo = NULL;      char szQuery[LSCP_BUFSIZ];
868    
869      if (pClient == NULL)      if (pClient == NULL)
870          return NULL;          return NULL;
# Line 573  lscp_device_channel_info_t* lscp_get_mid Line 873  lscp_device_channel_info_t* lscp_get_mid
873      if (iMidiPort < 0)      if (iMidiPort < 0)
874          return NULL;          return NULL;
875    
876      return pDevChannelInfo;      sprintf(szQuery, "GET MIDI_INPUT_PORT INFO %d %d\r\n", iMidiDevice, iMidiPort);
877        return _lscp_device_port_info_query(pClient, &(pClient->midi_port_info), szQuery);
878  }  }
879    
880    
# Line 591  lscp_device_channel_info_t* lscp_get_mid Line 892  lscp_device_channel_info_t* lscp_get_mid
892   */   */
893  lscp_param_info_t* lscp_get_midi_port_param_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, const char *pszParam )  lscp_param_info_t* lscp_get_midi_port_param_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, const char *pszParam )
894  {  {
895      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
896    
897      if (pClient == NULL)      if (pClient == NULL)
898          return NULL;          return NULL;
# Line 602  lscp_param_info_t* lscp_get_midi_port_pa Line 903  lscp_param_info_t* lscp_get_midi_port_pa
903      if (pszParam == NULL)      if (pszParam == NULL)
904          return NULL;          return NULL;
905    
906      return pParamInfo;      sprintf(szQuery, "GET MIDI_INPUT_PORT_PARAMETER INFO %d %d %s", iMidiDevice, iMidiPort, pszParam);
907        return _lscp_param_info_query(pClient, &(pClient->midi_port_param_info), szQuery, sizeof(szQuery), NULL);
908  }  }
909    
910    
# Line 619  lscp_param_info_t* lscp_get_midi_port_pa Line 921  lscp_param_info_t* lscp_get_midi_port_pa
921   */   */
922  lscp_status_t lscp_set_midi_port_param ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, lscp_param_t *pParam )  lscp_status_t lscp_set_midi_port_param ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, lscp_param_t *pParam )
923  {  {
924      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
925    
926      if (pClient == NULL)      if (pClient == NULL)
927          return ret;          return LSCP_FAILED;
928      if (iMidiDevice < 0)      if (iMidiDevice < 0)
929          return ret;          return LSCP_FAILED;
930      if (iMidiPort < 0)      if (iMidiPort < 0)
931          return ret;          return LSCP_FAILED;
932      if (pParam == NULL)      if (pParam == NULL)
933          return ret;          return LSCP_FAILED;
934    
935      return ret;      sprintf(szQuery, "SET MIDI_INPUT_PORT_PARAMETER %d %d", iMidiDevice, iMidiPort);
936        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
937        return lscp_client_query(pClient, szQuery);
938  }  }
939    
940  // end of device.c  // end of device.c

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

  ViewVC Help
Powered by ViewVC