/[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 163 by capela, Wed Jun 30 15:16:03 2004 UTC revision 189 by capela, Thu Jul 8 16:31:47 2004 UTC
# Line 26  Line 26 
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, 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_param_info_t  *_lscp_param_info_query  (lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, lscp_param_t *pDepList);  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  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 52  static lscp_driver_info_t *_lscp_driver_ Line 55  static lscp_driver_info_t *_lscp_driver_
55              if (strcasecmp(pszToken, "DESCRIPTION") == 0) {              if (strcasecmp(pszToken, "DESCRIPTION") == 0) {
56                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
57                  if (pszToken)                  if (pszToken)
58                      pDriverInfo->description = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pDriverInfo->description), &pszToken);
59              }              }
60              else if (strcasecmp(pszToken, "VERSION") == 0) {              else if (strcasecmp(pszToken, "VERSION") == 0) {
61                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
62                  if (pszToken)                  if (pszToken)
63                      pDriverInfo->version = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pDriverInfo->version), &pszToken);
64              }              }
65              else if (strcasecmp(pszToken, "PARAMETERS") == 0) {              else if (strcasecmp(pszToken, "PARAMETERS") == 0) {
66                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
67                  if (pszToken)                  if (pszToken) {
68                        if (pDriverInfo->parameters)
69                            lscp_szsplit_destroy(pDriverInfo->parameters);
70                      pDriverInfo->parameters = lscp_szsplit_create(pszToken, ",");                      pDriverInfo->parameters = lscp_szsplit_create(pszToken, ",");
71                    }
72              }              }
73              pszToken = lscp_strtok(NULL, pszSeps, &(pch));              pszToken = lscp_strtok(NULL, pszSeps, &(pch));
74          }          }
75      }      }
76        else pDriverInfo = NULL;
77            
78      // Unlock this section down.      // Unlock this section down.
79      lscp_mutex_unlock(pClient->mutex);      lscp_mutex_unlock(pClient->mutex);
# Line 75  static lscp_driver_info_t *_lscp_driver_ Line 82  static lscp_driver_info_t *_lscp_driver_
82  }  }
83    
84    
85    // Common device info query command.
86    static lscp_device_info_t *_lscp_device_info_query ( lscp_client_t *pClient, lscp_device_info_t *pDeviceInfo, char *pszQuery )
87    {
88        const char *pszResult;
89        const char *pszSeps = ":";
90        const char *pszCrlf = "\r\n";
91        char *pszToken;
92        char *pch;
93        char *pszKey;
94    
95        // Lock this section up.
96        lscp_mutex_lock(pClient->mutex);
97    
98        lscp_device_info_reset(pDeviceInfo);
99        if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
100            pszResult = lscp_client_get_result(pClient);
101            pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
102            while (pszToken) {
103                if (strcasecmp(pszToken, "DRIVER") == 0) {
104                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
105                    if (pszToken)
106                        lscp_unquote_dup(&(pDeviceInfo->driver), &pszToken);
107                }
108                else {
109                    pszKey = pszToken;
110                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
111                    if (pszToken)
112                        lscp_plist_append(&(pDeviceInfo->params), pszKey, lscp_unquote(&pszToken, 0));
113                }
114                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
115            }
116        }
117        else pDeviceInfo = NULL;
118    
119        // Unlock this section down.
120        lscp_mutex_unlock(pClient->mutex);
121    
122        return pDeviceInfo;
123    }
124    
125    
126    // Common device channel/port info query command.
127    static lscp_device_port_info_t *_lscp_device_port_info_query ( lscp_client_t *pClient, lscp_device_port_info_t *pDevicePortInfo, char *pszQuery )
128    {
129        const char *pszResult;
130        const char *pszSeps = ":";
131        const char *pszCrlf = "\r\n";
132        char *pszToken;
133        char *pch;
134        char *pszKey;
135    
136        // Lock this section up.
137        lscp_mutex_lock(pClient->mutex);
138    
139        lscp_device_port_info_reset(pDevicePortInfo);
140        if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
141            pszResult = lscp_client_get_result(pClient);
142            pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
143            while (pszToken) {
144                if (strcasecmp(pszToken, "NAME") == 0) {
145                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
146                    if (pszToken)
147                        lscp_unquote_dup(&(pDevicePortInfo->name), &pszToken);
148                }
149                else {
150                    pszKey = pszToken;
151                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
152                    if (pszToken)
153                        lscp_plist_append(&(pDevicePortInfo->params), pszKey, lscp_unquote(&pszToken, 0));
154                }
155                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
156            }
157        }
158        else pDevicePortInfo = NULL;
159    
160        // Unlock this section down.
161        lscp_mutex_unlock(pClient->mutex);
162    
163        return pDevicePortInfo;
164    }
165    
166    
167  // Common parameter info query command.  // Common parameter info query command.
168  static lscp_param_info_t *_lscp_param_info_query ( lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, lscp_param_t *pDepList )  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 )
169  {  {
170      const char *pszResult;      const char *pszResult;
171      const char *pszSeps = ":";      const char *pszSeps = ":";
# Line 88  static lscp_param_info_t *_lscp_param_in Line 177  static lscp_param_info_t *_lscp_param_in
177      lscp_mutex_lock(pClient->mutex);      lscp_mutex_lock(pClient->mutex);
178    
179      lscp_param_info_reset(pParamInfo);      lscp_param_info_reset(pParamInfo);
180      lscp_param_concat(pszQuery, LSCP_BUFSIZ, pDepList);      lscp_param_concat(pszQuery, cchMaxQuery, pDepList);
181      if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {      if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
182          pszResult = lscp_client_get_result(pClient);          pszResult = lscp_client_get_result(pClient);
183          pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));          pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
# Line 110  static lscp_param_info_t *_lscp_param_in Line 199  static lscp_param_info_t *_lscp_param_in
199              else if (strcasecmp(pszToken, "DESCRIPTION") == 0) {              else if (strcasecmp(pszToken, "DESCRIPTION") == 0) {
200                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
201                  if (pszToken)                  if (pszToken)
202                      pParamInfo->description = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pParamInfo->description), &pszToken);
203              }              }
204              else if (strcasecmp(pszToken, "MANDATORY") == 0) {              else if (strcasecmp(pszToken, "MANDATORY") == 0) {
205                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
# Line 129  static lscp_param_info_t *_lscp_param_in Line 218  static lscp_param_info_t *_lscp_param_in
218              }              }
219              else if (strcasecmp(pszToken, "DEPENDS") == 0) {              else if (strcasecmp(pszToken, "DEPENDS") == 0) {
220                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
221                  if (pszToken)                  if (pszToken) {
222                        if (pParamInfo->depends)
223                            lscp_szsplit_destroy(pParamInfo->depends);
224                      pParamInfo->depends = lscp_szsplit_create(pszToken, ",");                      pParamInfo->depends = lscp_szsplit_create(pszToken, ",");
225                    }
226              }              }
227              else if (strcasecmp(pszToken, "DEFAULT") == 0) {              else if (strcasecmp(pszToken, "DEFAULT") == 0) {
228                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
229                  if (pszToken)                  if (pszToken)
230                      pParamInfo->defaultv = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pParamInfo->defaultv), &pszToken);
231              }              }
232              else if (strcasecmp(pszToken, "RANGE_MIN") == 0) {              else if (strcasecmp(pszToken, "RANGE_MIN") == 0) {
233                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
234                  if (pszToken)                  if (pszToken)
235                      pParamInfo->range_min = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pParamInfo->range_min), &pszToken);
236              }              }
237              else if (strcasecmp(pszToken, "RANGE_MAX") == 0) {              else if (strcasecmp(pszToken, "RANGE_MAX") == 0) {
238                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
239                  if (pszToken)                  if (pszToken)
240                      pParamInfo->range_max = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pParamInfo->range_max), &pszToken);
241              }              }
242              else if (strcasecmp(pszToken, "POSSIBILITIES") == 0) {              else if (strcasecmp(pszToken, "POSSIBILITIES") == 0) {
243                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
244                  if (pszToken)                  if (pszToken) {
245                        if (pParamInfo->possibilities)
246                            lscp_szsplit_destroy(pParamInfo->possibilities);
247                      pParamInfo->possibilities = lscp_szsplit_create(pszToken, ",");                      pParamInfo->possibilities = lscp_szsplit_create(pszToken, ",");
248                    }
249              }              }
250              pszToken = lscp_strtok(NULL, pszSeps, &(pch));              pszToken = lscp_strtok(NULL, pszSeps, &(pch));
251          }          }
252      }      }
253        else pParamInfo = NULL;
254    
255      // Unlock this section down.      // Unlock this section down.
256      lscp_mutex_unlock(pClient->mutex);      lscp_mutex_unlock(pClient->mutex);
# Line 215  lscp_driver_info_t* lscp_get_audio_drive Line 311  lscp_driver_info_t* lscp_get_audio_drive
311          return NULL;          return NULL;
312    
313      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver);      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver);
314      return _lscp_driver_info_query(pClient, &(pClient->audio_info), szQuery);      return _lscp_driver_info_query(pClient, &(pClient->audio_driver_info), szQuery);
315  }  }
316    
317    
# Line 242  lscp_param_info_t *lscp_get_audio_driver Line 338  lscp_param_info_t *lscp_get_audio_driver
338      if (pszParam == NULL)      if (pszParam == NULL)
339          return NULL;          return NULL;
340    
341      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO %s %s\r\n", pszAudioDriver, pszParam);      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO %s %s", pszAudioDriver, pszParam);
342      return _lscp_param_info_query(pClient, &(pClient->audio_param_info), szQuery, pDepList);      return _lscp_param_info_query(pClient, &(pClient->audio_param_info), szQuery, sizeof(szQuery), pDepList);
343  }  }
344    
345    
# Line 263  lscp_param_info_t *lscp_get_audio_driver Line 359  lscp_param_info_t *lscp_get_audio_driver
359   */   */
360  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 )
361  {  {
362        char szQuery[LSCP_BUFSIZ];
363      int iAudioDevice = -1;      int iAudioDevice = -1;
364    
365      if (pClient == NULL)      if (pClient == NULL)
366          return -1;          return iAudioDevice;
367      if (pszAudioDriver == NULL)      if (pszAudioDriver == NULL)
368          return -1;          return iAudioDevice;
369      if (pParams == NULL)  
370          return -1;      // Lock this section up.
371        lscp_mutex_lock(pClient->mutex);
372    
373        sprintf(szQuery, "CREATE AUDIO_OUTPUT_DEVICE %s", pszAudioDriver);
374        lscp_param_concat(szQuery, sizeof(szQuery), pParams);
375        if (lscp_client_call(pClient, szQuery) == LSCP_OK)
376            iAudioDevice = atoi(lscp_client_get_result(pClient));
377    
378        // Unlock this section down.
379        lscp_mutex_unlock(pClient->mutex);
380    
381      return iAudioDevice;      return iAudioDevice;
382  }  }
# Line 288  int lscp_create_audio_device ( lscp_clie Line 394  int lscp_create_audio_device ( lscp_clie
394  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 )
395  {  {
396      lscp_status_t ret = LSCP_FAILED;      lscp_status_t ret = LSCP_FAILED;
397        char szQuery[LSCP_BUFSIZ];
398    
399      if (pClient == NULL)      if (pClient == NULL)
400          return ret;          return ret;
401      if (iAudioDevice < 0)      if (iAudioDevice < 0)
402          return ret;          return ret;
403    
404      return ret;      sprintf(szQuery, "DESTROY AUDIO_OUTPUT_DEVICE %d\r\n", iAudioDevice);
405        return lscp_client_query(pClient, szQuery);
406  }  }
407    
408    
# Line 370  int *lscp_list_audio_devices ( lscp_clie Line 478  int *lscp_list_audio_devices ( lscp_clie
478   */   */
479  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 )
480  {  {
481      lscp_device_info_t *pDeviceInfo = NULL;      char szQuery[LSCP_BUFSIZ];
482    
483      if (pClient == NULL)      if (pClient == NULL)
484          return NULL;          return NULL;
485      if (iAudioDevice < 0)      if (iAudioDevice < 0)
486          return NULL;          return NULL;
487    
488      return pDeviceInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_DEVICE INFO %d\r\n", iAudioDevice);
489        return _lscp_device_info_query(pClient, &(pClient->audio_device_info), szQuery);
490  }  }
491    
492    
493  /**  /**
494   *  Changing settings of audio output devices.   *  Changing settings of audio output devices.
495   *  SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param> <value>   *  SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param>=<value>
496   *   *
497   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
498   *  @param iAudioDevice Audio device number identifier.   *  @param iAudioDevice Audio device number identifier.
# Line 393  lscp_device_info_t *lscp_get_audio_devic Line 502  lscp_device_info_t *lscp_get_audio_devic
502   */   */
503  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 )
504  {  {
505      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
506    
507      if (pClient == NULL)      if (pClient == NULL)
508          return ret;          return LSCP_FAILED;
509      if (iAudioDevice < 0)      if (iAudioDevice < 0)
510          return ret;          return LSCP_FAILED;
511      if (pParam == NULL)      if (pParam == NULL)
512          return ret;          return LSCP_FAILED;
513    
514      return ret;      sprintf(szQuery, "SET AUDIO_OUTPUT_DEVICE_PARAMETER %d", iAudioDevice);
515        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
516        return lscp_client_query(pClient, szQuery);
517  }  }
518    
519    
# Line 414  lscp_status_t lscp_set_audio_device_para Line 525  lscp_status_t lscp_set_audio_device_para
525   *  @param iAudioDevice     Audio device number identifier.   *  @param iAudioDevice     Audio device number identifier.
526   *  @param iAudioChannel    Audio channel number.   *  @param iAudioChannel    Audio channel number.
527   *   *
528   *  @returns A pointer to a @ref lscp_device_channel_info_t structure,   *  @returns A pointer to a @ref lscp_device_port_info_t structure,
529   *  with the given audio channel information, or NULL in case of failure.   *  with the given audio channel information, or NULL in case of failure.
530   */   */
531  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 )
532  {  {
533      lscp_device_channel_info_t *pDevChannelInfo = NULL;      char szQuery[LSCP_BUFSIZ];
534    
535      if (pClient == NULL)      if (pClient == NULL)
536          return NULL;          return NULL;
# Line 428  lscp_device_channel_info_t* lscp_get_aud Line 539  lscp_device_channel_info_t* lscp_get_aud
539      if (iAudioChannel < 0)      if (iAudioChannel < 0)
540          return NULL;          return NULL;
541    
542      return pDevChannelInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL INFO %d %d\r\n", iAudioDevice, iAudioChannel);
543        return _lscp_device_port_info_query(pClient, &(pClient->audio_channel_info), szQuery);
544  }  }
545    
546    
# Line 446  lscp_device_channel_info_t* lscp_get_aud Line 558  lscp_device_channel_info_t* lscp_get_aud
558   */   */
559  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 )
560  {  {
561      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
562    
563      if (pClient == NULL)      if (pClient == NULL)
564          return NULL;          return NULL;
# Line 457  lscp_param_info_t* lscp_get_audio_channe Line 569  lscp_param_info_t* lscp_get_audio_channe
569      if (pszParam == NULL)      if (pszParam == NULL)
570          return NULL;          return NULL;
571    
572      return pParamInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO %d %d %s", iAudioDevice, iAudioChannel, pszParam);
573        return _lscp_param_info_query(pClient, &(pClient->audio_channel_param_info), szQuery, sizeof(szQuery), NULL);
574  }  }
575    
576    
# Line 474  lscp_param_info_t* lscp_get_audio_channe Line 587  lscp_param_info_t* lscp_get_audio_channe
587   */   */
588  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 )
589  {  {
590      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
591    
592      if (pClient == NULL)      if (pClient == NULL)
593          return ret;          return LSCP_FAILED;
594      if (iAudioDevice < 0)      if (iAudioDevice < 0)
595          return ret;          return LSCP_FAILED;
596      if (iAudioChannel < 0)      if (iAudioChannel < 0)
597          return ret;          return LSCP_FAILED;
598      if (pParam == NULL)      if (pParam == NULL)
599          return ret;          return LSCP_FAILED;
600    
601      return ret;      sprintf(szQuery, "SET AUDIO_OUTPUT_CHANNEL_PARAMETER %d %d", iAudioDevice, iAudioChannel);
602        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
603        return lscp_client_query(pClient, szQuery);
604  }  }
605    
606    
# Line 541  lscp_driver_info_t* lscp_get_midi_driver Line 656  lscp_driver_info_t* lscp_get_midi_driver
656          return NULL;          return NULL;
657    
658      sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver);      sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver);
659      return _lscp_driver_info_query(pClient, &(pClient->midi_info), szQuery);      return _lscp_driver_info_query(pClient, &(pClient->midi_driver_info), szQuery);
660  }  }
661    
662    
# Line 570  lscp_param_info_t *lscp_get_midi_driver_ Line 685  lscp_param_info_t *lscp_get_midi_driver_
685      if (pszParam == NULL)      if (pszParam == NULL)
686          return NULL;          return NULL;
687    
688      sprintf(szQuery, "GET MIDI_INPUT_DRIVER_PARAMETER INFO %s %s\r\n", pszMidiDriver, pszParam);      sprintf(szQuery, "GET MIDI_INPUT_DRIVER_PARAMETER INFO %s %s", pszMidiDriver, pszParam);
689      return _lscp_param_info_query(pClient, &(pClient->midi_param_info), szQuery, pDepList);      return _lscp_param_info_query(pClient, &(pClient->midi_param_info), szQuery, sizeof(szQuery), pDepList);
690  }  }
691    
692    
# Line 591  lscp_param_info_t *lscp_get_midi_driver_ Line 706  lscp_param_info_t *lscp_get_midi_driver_
706   */   */
707  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 )
708  {  {
709        char szQuery[LSCP_BUFSIZ];
710      int iMidiDevice = -1;      int iMidiDevice = -1;
711    
712      if (pClient == NULL)      if (pClient == NULL)
713          return -1;          return iMidiDevice;
714      if (pszMidiDriver == NULL)      if (pszMidiDriver == NULL)
715          return -1;          return iMidiDevice;
716      if (pParams == NULL)  
717          return -1;      // Lock this section up.
718        lscp_mutex_lock(pClient->mutex);
719    
720        sprintf(szQuery, "CREATE MIDI_INPUT_DEVICE %s", pszMidiDriver);
721        lscp_param_concat(szQuery, sizeof(szQuery), pParams);
722        if (lscp_client_call(pClient, szQuery) == LSCP_OK)
723            iMidiDevice = atoi(lscp_client_get_result(pClient));
724    
725        // Unlock this section down.
726        lscp_mutex_unlock(pClient->mutex);
727    
728      return iMidiDevice;      return iMidiDevice;
729  }  }
# Line 616  int lscp_create_midi_device ( lscp_clien Line 741  int lscp_create_midi_device ( lscp_clien
741  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 )
742  {  {
743      lscp_status_t ret = LSCP_FAILED;      lscp_status_t ret = LSCP_FAILED;
744        char szQuery[LSCP_BUFSIZ];
745    
746      if (pClient == NULL)      if (pClient == NULL)
747          return ret;          return ret;
748      if (iMidiDevice < 0)      if (iMidiDevice < 0)
749          return ret;          return ret;
750    
751      return ret;      sprintf(szQuery, "DESTROY MIDI_INPUT_DEVICE %d\r\n", iMidiDevice);
752        return lscp_client_query(pClient, szQuery);
753  }  }
754    
755    
# Line 698  int *lscp_list_midi_devices ( lscp_clien Line 825  int *lscp_list_midi_devices ( lscp_clien
825   */   */
826  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 )
827  {  {
828      lscp_device_info_t *pDeviceInfo = NULL;      char szQuery[LSCP_BUFSIZ];
829    
830      if (pClient == NULL)      if (pClient == NULL)
831          return NULL;          return NULL;
832      if (iMidiDevice < 0)      if (iMidiDevice < 0)
833          return NULL;          return NULL;
834    
835      return pDeviceInfo;      sprintf(szQuery, "GET MIDI_INPUT_DEVICE INFO %d\r\n", iMidiDevice);
836        return _lscp_device_info_query(pClient, &(pClient->midi_device_info), szQuery);
837  }  }
838    
839    
840  /**  /**
841   *  Changing settings of MIDI input devices.   *  Changing settings of MIDI input devices.
842   *  SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param> <value>   *  SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param>=<value>
843   *   *
844   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
845   *  @param iMidiDevice  MIDI device number identifier.   *  @param iMidiDevice  MIDI device number identifier.
# Line 721  lscp_device_info_t* lscp_get_midi_device Line 849  lscp_device_info_t* lscp_get_midi_device
849   */   */
850  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 )
851  {  {
852      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
853    
854      if (pClient == NULL)      if (pClient == NULL)
855          return ret;          return LSCP_FAILED;
856      if (iMidiDevice < 0)      if (iMidiDevice < 0)
857          return ret;          return LSCP_FAILED;
858      if (pParam == NULL)      if (pParam == NULL)
859          return ret;          return LSCP_FAILED;
860    
861      return ret;      sprintf(szQuery, "SET MIDI_INPUT_DEVICE_PARAMETER %d", iMidiDevice);
862        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
863        return lscp_client_query(pClient, szQuery);
864  }  }
865    
866    
# Line 742  lscp_status_t lscp_set_midi_device_param Line 872  lscp_status_t lscp_set_midi_device_param
872   *  @param iMidiDevice  MIDI device number identifier.   *  @param iMidiDevice  MIDI device number identifier.
873   *  @param iMidiPort    MIDI port number.   *  @param iMidiPort    MIDI port number.
874   *   *
875   *  @returns A pointer to a @ref lscp_device_channel_info_t structure,   *  @returns A pointer to a @ref lscp_device_port_info_t structure,
876   *  with the given MIDI port information, or NULL in case of failure.   *  with the given MIDI port information, or NULL in case of failure.
877   */   */
878  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 )
879  {  {
880      lscp_device_channel_info_t *pDevChannelInfo = NULL;      char szQuery[LSCP_BUFSIZ];
881    
882      if (pClient == NULL)      if (pClient == NULL)
883          return NULL;          return NULL;
# Line 756  lscp_device_channel_info_t* lscp_get_mid Line 886  lscp_device_channel_info_t* lscp_get_mid
886      if (iMidiPort < 0)      if (iMidiPort < 0)
887          return NULL;          return NULL;
888    
889      return pDevChannelInfo;      sprintf(szQuery, "GET MIDI_INPUT_PORT INFO %d %d\r\n", iMidiDevice, iMidiPort);
890        return _lscp_device_port_info_query(pClient, &(pClient->midi_port_info), szQuery);
891  }  }
892    
893    
# Line 774  lscp_device_channel_info_t* lscp_get_mid Line 905  lscp_device_channel_info_t* lscp_get_mid
905   */   */
906  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 )
907  {  {
908      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
909    
910      if (pClient == NULL)      if (pClient == NULL)
911          return NULL;          return NULL;
# Line 785  lscp_param_info_t* lscp_get_midi_port_pa Line 916  lscp_param_info_t* lscp_get_midi_port_pa
916      if (pszParam == NULL)      if (pszParam == NULL)
917          return NULL;          return NULL;
918    
919      return pParamInfo;      sprintf(szQuery, "GET MIDI_INPUT_PORT_PARAMETER INFO %d %d %s", iMidiDevice, iMidiPort, pszParam);
920        return _lscp_param_info_query(pClient, &(pClient->midi_port_param_info), szQuery, sizeof(szQuery), NULL);
921  }  }
922    
923    
# Line 802  lscp_param_info_t* lscp_get_midi_port_pa Line 934  lscp_param_info_t* lscp_get_midi_port_pa
934   */   */
935  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 )
936  {  {
937      lscp_status_t ret = LSCP_FAILED;      char szQuery[LSCP_BUFSIZ];
938    
939      if (pClient == NULL)      if (pClient == NULL)
940          return ret;          return LSCP_FAILED;
941      if (iMidiDevice < 0)      if (iMidiDevice < 0)
942          return ret;          return LSCP_FAILED;
943      if (iMidiPort < 0)      if (iMidiPort < 0)
944          return ret;          return LSCP_FAILED;
945      if (pParam == NULL)      if (pParam == NULL)
946          return ret;          return LSCP_FAILED;
947    
948        sprintf(szQuery, "SET MIDI_INPUT_PORT_PARAMETER %d %d", iMidiDevice, iMidiPort);
949        lscp_param_concat(szQuery, sizeof(szQuery), pParam);
950        return lscp_client_query(pClient, szQuery);
951    }
952    
953    
954    //-------------------------------------------------------------------------
955    // Generic parameter list functions.
956    
957      return ret;  const char *lscp_get_param_value ( lscp_param_t *pParams, const char *pszParam )
958    {
959        int i;
960        
961        for (i = 0; pParams && pParams[i].key; i++) {
962            if (strcasecmp(pParams[i].key, pszParam) == 0)
963                return (const char *) pParams[i].value;
964        }
965        return NULL;
966  }  }
967    
968    
969  // end of device.c  // end of device.c
970    

Legend:
Removed from v.163  
changed lines
  Added in v.189

  ViewVC Help
Powered by ViewVC