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

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

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

revision 419 by capela, Wed Mar 2 16:25:27 2005 UTC revision 869 by capela, Thu Jun 1 08:32:16 2006 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This library is free software; you can redistribute it and/or     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public     modify it under the terms of the GNU Lesser General Public
# Line 72  lscp_status_t lscp_client_recv ( lscp_cl Line 72  lscp_status_t lscp_client_recv ( lscp_cl
72      // Use the timeout select feature...      // Use the timeout select feature...
73      if (iTimeout < 1)      if (iTimeout < 1)
74          iTimeout = pClient->iTimeout;          iTimeout = pClient->iTimeout;
75      if (iTimeout > 1000) {      if (iTimeout >= 1000) {
76          tv.tv_sec = iTimeout / 1000;          tv.tv_sec = iTimeout / 1000;
77          iTimeout -= tv.tv_sec * 1000;          iTimeout -= tv.tv_sec * 1000;
78      }      }
# Line 133  lscp_status_t lscp_client_call ( lscp_cl Line 133  lscp_status_t lscp_client_call ( lscp_cl
133          return ret;          return ret;
134      }      }
135    
136            // Check if last transaction has timed out, in which case
137            // we'll retry wait and flush for some pending garbage...
138            if (pClient->iTimeoutCount > 0) {
139                    cchResult = sizeof(achResult);
140                    ret = lscp_client_recv(pClient, achResult, &cchResult, pClient->iTimeout);
141                    if (ret == LSCP_OK) {
142                            // We've got rid of timeout trouble (hopefully).
143                            pClient->iTimeoutCount = 0;
144                    } else {
145                            // Things are worse than before. Fake a result message.
146                            iErrno = (int) ret;
147                            pszResult = "Failure during flush timeout operation";
148                            lscp_client_set_result(pClient, pszResult, iErrno);
149                            return ret;
150                    }
151            }
152    
153      // Send data, and then, wait for the result...      // Send data, and then, wait for the result...
154      cchQuery = strlen(pszQuery);      cchQuery = strlen(pszQuery);
155      if (send(pClient->cmd.sock, pszQuery, cchQuery, 0) < cchQuery) {      if (send(pClient->cmd.sock, pszQuery, cchQuery, 0) < cchQuery) {
# Line 188  lscp_status_t lscp_client_call ( lscp_cl Line 205  lscp_status_t lscp_client_call ( lscp_cl
205          break;          break;
206    
207        case LSCP_TIMEOUT:        case LSCP_TIMEOUT:
208                    // We have trouble...
209                    pClient->iTimeoutCount++;
210          // Fake a result message.          // Fake a result message.
211          pszResult = "Timeout during receive operation";          pszResult = "Timeout during receive operation";
212          iErrno = (int) ret;          iErrno = (int) ret;
# Line 660  int lscp_plist_size ( lscp_param_t **ppL Line 679  int lscp_plist_size ( lscp_param_t **ppL
679    
680    
681  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
682    // Server info struct helper functions.
683    
684    void lscp_server_info_init ( lscp_server_info_t *pServerInfo )
685    {
686        pServerInfo->description = NULL;
687        pServerInfo->version     = NULL;
688    }
689    
690    void lscp_server_info_free ( lscp_server_info_t *pServerInfo )
691    {
692        if (pServerInfo->description)
693            free(pServerInfo->description);
694        if (pServerInfo->version)
695            free(pServerInfo->version);
696    }
697    
698    void lscp_server_info_reset ( lscp_server_info_t *pServerInfo )
699    {
700        lscp_server_info_free(pServerInfo);
701        lscp_server_info_init(pServerInfo);
702    }
703    
704    
705    //-------------------------------------------------------------------------
706  // Engine info struct helper functions.  // Engine info struct helper functions.
707    
708  void lscp_engine_info_init ( lscp_engine_info_t *pEngineInfo )  void lscp_engine_info_init ( lscp_engine_info_t *pEngineInfo )
# Line 700  void lscp_channel_info_init ( lscp_chann Line 743  void lscp_channel_info_init ( lscp_chann
743      pChannelInfo->midi_port         = 0;      pChannelInfo->midi_port         = 0;
744      pChannelInfo->midi_channel      = 0;      pChannelInfo->midi_channel      = 0;
745      pChannelInfo->volume            = 0.0;      pChannelInfo->volume            = 0.0;
746        pChannelInfo->mute              = 0;
747        pChannelInfo->solo              = 0;
748  }  }
749    
750  void lscp_channel_info_free ( lscp_channel_info_t *pChannelInfo )  void lscp_channel_info_free ( lscp_channel_info_t *pChannelInfo )

Legend:
Removed from v.419  
changed lines
  Added in v.869

  ViewVC Help
Powered by ViewVC