/[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 162 by capela, Fri Jun 18 14:19:19 2004 UTC revision 163 by capela, Wed Jun 30 15:16:03 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_param_info_t  *_lscp_param_info_query  (lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, lscp_param_t *pDepList);
30    
31    
32  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
33  // Local funtions.  // Local funtions.
34    
35  // Common driver type query command.  // Common driver type query command.
36  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 )
37  {  {
38      const char *pszResult;      const char *pszResult;
39      const char *pszSeps = ":";      const char *pszSeps = ":";
# Line 74  static lscp_driver_info_t *_lscp_driver_ Line 75  static lscp_driver_info_t *_lscp_driver_
75  }  }
76    
77    
78    // Common parameter info query command.
79    static lscp_param_info_t *_lscp_param_info_query ( lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, lscp_param_t *pDepList )
80    {
81        const char *pszResult;
82        const char *pszSeps = ":";
83        const char *pszCrlf = "\r\n";
84        char *pszToken;
85        char *pch;
86    
87        // Lock this section up.
88        lscp_mutex_lock(pClient->mutex);
89    
90        lscp_param_info_reset(pParamInfo);
91        lscp_param_concat(pszQuery, LSCP_BUFSIZ, pDepList);
92        if (lscp_client_call(pClient, pszQuery) == LSCP_OK) {
93            pszResult = lscp_client_get_result(pClient);
94            pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
95            while (pszToken) {
96                if (strcasecmp(pszToken, "TYPE") == 0) {
97                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
98                    if (pszToken) {
99                        pszToken = lscp_unquote(&pszToken, 0);
100                        if (strcasecmp(pszToken, "BOOL") == 0)
101                            pParamInfo->type = LSCP_TYPE_BOOL;
102                        else if (strcasecmp(pszToken, "INT") == 0)
103                            pParamInfo->type = LSCP_TYPE_INT;
104                        else if (strcasecmp(pszToken, "FLOAT") == 0)
105                            pParamInfo->type = LSCP_TYPE_FLOAT;
106                        else if (strcasecmp(pszToken, "STRING") == 0)
107                            pParamInfo->type = LSCP_TYPE_STRING;
108                    }
109                }
110                else if (strcasecmp(pszToken, "DESCRIPTION") == 0) {
111                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
112                    if (pszToken)
113                        pParamInfo->description = lscp_unquote(&pszToken, 1);
114                }
115                else if (strcasecmp(pszToken, "MANDATORY") == 0) {
116                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
117                    if (pszToken)
118                        pParamInfo->mandatory = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0);
119                }
120                else if (strcasecmp(pszToken, "FIX") == 0) {
121                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
122                    if (pszToken)
123                        pParamInfo->fix = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0);
124                }
125                else if (strcasecmp(pszToken, "MULTIPLICITY") == 0) {
126                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
127                    if (pszToken)
128                        pParamInfo->multiplicity = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0);
129                }
130                else if (strcasecmp(pszToken, "DEPENDS") == 0) {
131                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
132                    if (pszToken)
133                        pParamInfo->depends = lscp_szsplit_create(pszToken, ",");
134                }
135                else if (strcasecmp(pszToken, "DEFAULT") == 0) {
136                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
137                    if (pszToken)
138                        pParamInfo->defaultv = lscp_unquote(&pszToken, 1);
139                }
140                else if (strcasecmp(pszToken, "RANGE_MIN") == 0) {
141                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
142                    if (pszToken)
143                        pParamInfo->range_min = lscp_unquote(&pszToken, 1);
144                }
145                else if (strcasecmp(pszToken, "RANGE_MAX") == 0) {
146                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
147                    if (pszToken)
148                        pParamInfo->range_max = lscp_unquote(&pszToken, 1);
149                }
150                else if (strcasecmp(pszToken, "POSSIBILITIES") == 0) {
151                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
152                    if (pszToken)
153                        pParamInfo->possibilities = lscp_szsplit_create(pszToken, ",");
154                }
155                pszToken = lscp_strtok(NULL, pszSeps, &(pch));
156            }
157        }
158    
159        // Unlock this section down.
160        lscp_mutex_unlock(pClient->mutex);
161    
162        return pParamInfo;
163    }
164    
165    
166  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
167  // Audio driver control functions.  // Audio driver control functions.
168    
# Line 144  lscp_driver_info_t* lscp_get_audio_drive Line 233  lscp_driver_info_t* lscp_get_audio_drive
233   */   */
234  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 )
235  {  {
236      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
237    
238      if (pClient == NULL)      if (pClient == NULL)
239          return NULL;          return NULL;
# Line 152  lscp_param_info_t *lscp_get_audio_driver Line 241  lscp_param_info_t *lscp_get_audio_driver
241          return NULL;          return NULL;
242      if (pszParam == NULL)      if (pszParam == NULL)
243          return NULL;          return NULL;
     if (pDepList == NULL)  
         return NULL;  
244    
245      return pParamInfo;      sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO %s %s\r\n", pszAudioDriver, pszParam);
246        return _lscp_param_info_query(pClient, &(pClient->audio_param_info), szQuery, pDepList);
247  }  }
248    
249    
# Line 473  lscp_driver_info_t* lscp_get_midi_driver Line 561  lscp_driver_info_t* lscp_get_midi_driver
561   */   */
562  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 )
563  {  {
564      lscp_param_info_t *pParamInfo = NULL;      char szQuery[LSCP_BUFSIZ];
565    
566      if (pClient == NULL)      if (pClient == NULL)
567          return NULL;          return NULL;
# Line 481  lscp_param_info_t *lscp_get_midi_driver_ Line 569  lscp_param_info_t *lscp_get_midi_driver_
569          return NULL;          return NULL;
570      if (pszParam == NULL)      if (pszParam == NULL)
571          return NULL;          return NULL;
     if (pDepList == NULL)  
         return NULL;  
572    
573      return pParamInfo;      sprintf(szQuery, "GET MIDI_INPUT_DRIVER_PARAMETER INFO %s %s\r\n", pszMidiDriver, pszParam);
574        return _lscp_param_info_query(pClient, &(pClient->midi_param_info), szQuery, pDepList);
575  }  }
576    
577    

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

  ViewVC Help
Powered by ViewVC