/[svn]/linuxsampler/trunk/src/network/lscpserver.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.h

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

revision 155 by senkov, Mon Jun 28 04:30:11 2004 UTC revision 212 by schoenebeck, Wed Jul 28 14:17:29 2004 UTC
# Line 26  Line 26 
26  #include <unistd.h>  #include <unistd.h>
27  #include <sys/types.h>  #include <sys/types.h>
28  #include <sys/socket.h>  #include <sys/socket.h>
29    #include <sys/select.h>
30    #include <sys/time.h>
31  #include <netinet/in.h>  #include <netinet/in.h>
32  #include <netinet/tcp.h>  #include <netinet/tcp.h>
33  #include <arpa/inet.h>  #include <arpa/inet.h>
34  #include <netdb.h>  #include <netdb.h>
35    
36    #include <list>
37    
38  #include "lscp.h"  #include "lscp.h"
39  #include "lscpparser.h"  #include "lscpparser.h"
40    #include "lscp.h"
41    #include "lscpevent.h"
42  #include "../Sampler.h"  #include "../Sampler.h"
43  #include "../common/Thread.h"  #include "../common/Thread.h"
44    #include "../common/Mutex.h"
45    #include "../common/Condition.h"
46    
47  /// TCP Port on which the server should listen for connection requests.  /// TCP Port on which the server should listen for connection requests.
48  #define LSCP_PORT 8888  #define LSCP_PORT 8888
49    
50  using namespace LinuxSampler;  using namespace LinuxSampler;
51    
 /// Handle for a client connection (FIXME: doesn't work for more than one network connections of course, thus has to be included to the yyparse() parameters instead).  
 extern int hSession;  
   
52  // External references to the main scanner and parser functions  // External references to the main scanner and parser functions
53  extern int yyparse(void* YYPARSE_PARAM);  extern int yyparse(void* YYPARSE_PARAM);
54  extern int yylex_init(yyscan_t* scanner);  extern int yylex_init(yyscan_t* scanner);
# Line 55  extern int yylex_destroy(yyscan_t yyscan Line 60  extern int yylex_destroy(yyscan_t yyscan
60  class LSCPServer : public Thread {  class LSCPServer : public Thread {
61      public:      public:
62          LSCPServer(Sampler* pSampler);          LSCPServer(Sampler* pSampler);
63            int WaitUntilInitialized(long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L);
64    
65          // Methods called by the parser          // Methods called by the parser
66          String DestroyAudioOutputDevice(uint DeviceIndex);          String DestroyAudioOutputDevice(uint DeviceIndex);
# Line 62  class LSCPServer : public Thread { Line 68  class LSCPServer : public Thread {
68          String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false);          String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false);
69          String LoadEngine(String EngineName, uint uiSamplerChannel);          String LoadEngine(String EngineName, uint uiSamplerChannel);
70          String GetChannels();          String GetChannels();
71            String ListChannels();
72          String AddChannel();          String AddChannel();
73          String RemoveChannel(uint uiSamplerChannel);          String RemoveChannel(uint uiSamplerChannel);
74          String GetAvailableEngines();          String GetAvailableEngines();
# Line 93  class LSCPServer : public Thread { Line 100  class LSCPServer : public Thread {
100          String GetAudioOutputDeviceInfo(uint DeviceIndex);          String GetAudioOutputDeviceInfo(uint DeviceIndex);
101          String GetMidiInputDeviceInfo(uint DeviceIndex);          String GetMidiInputDeviceInfo(uint DeviceIndex);
102          String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex);          String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex);
103            String GetMidiInputPortParameterInfo(uint DeviceId, uint PortId, String ParameterName);
104          String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId);          String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId);
105          String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName);          String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName);
106          String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal);          String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal);
107          String SetAudioOutputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);          String SetAudioOutputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
108          String SetMidiInputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);          String SetMidiInputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
109          String SetMidiInputPortParameter(uint DeviceIndex, uint PortIndex, String ParamKey, String ParamVal);          String SetMidiInputPortParameter(uint DeviceIndex, uint PortIndex, String ParamKey, String ParamVal);
110          String SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel);          String SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel);
111            String SetAudioOutputDevice(uint AudioDeviceId, uint SamplerChannel);
112          String SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel);          String SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel);
113            String SetMIDIInputPort(uint MIDIPort, uint uiSamplerChannel);
114            String SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel);
115            String SetMIDIInputDevice(uint MIDIDeviceId, uint uiSamplerChannel);
116          String SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel);          String SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel);
117          String SetMIDIInput(uint MIDIDevice, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel);          String SetMIDIInput(uint MIDIDeviceId, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel);
         String SetAudioOutputDevice(uint AudioDeviceId, uint SamplerChannel);  
118          String SetVolume(double Volume, uint uiSamplerChannel);          String SetVolume(double Volume, uint uiSamplerChannel);
119          String ResetChannel(uint uiSamplerChannel);          String ResetChannel(uint uiSamplerChannel);
120          String SubscribeNotification(event_t Event);          String ResetSampler();
121          String UnsubscribeNotification(event_t Event);          String SubscribeNotification(LSCPEvent::event_t);
122            String UnsubscribeNotification(LSCPEvent::event_t);
123            String SetEcho(yyparse_param_t* pSession, double boolean_value);
124          void   AnswerClient(String ReturnMessage);          void   AnswerClient(String ReturnMessage);
125    
126            static int currentSocket;
127            static std::map<int,String> bufferedCommands;
128    
129            static void SendLSCPNotify( LSCPEvent Event );
130    
131      protected:      protected:
132          int            hSocket;          int            hSocket;
133          sockaddr_in    SocketAddress;          sockaddr_in    SocketAddress;
134          Sampler*       pSampler;          Sampler*       pSampler;
135            Condition      Initialized;
136    
137          int Main(); ///< Implementation of virtual method from class Thread          int Main(); ///< Implementation of virtual method from class Thread
138    
139      private:      private:
140            
141          /**          /**
142           * Find a created audio output device index.           * Find a created audio output device index.
143           */           */
144          int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice);          int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice);
145            
146          /**          /**
147           * Find a created midi input device index.           * Find a created midi input device index.
148           */           */
149          int GetMidiInputDeviceIndex (MidiInputDevice *pDevice);          int GetMidiInputDeviceIndex (MidiInputDevice *pDevice);
150    
151          /**          static std::map<int,String> bufferedNotifies;
152           * Converts a result_t structure into a valid LSCP answer message.          static Mutex NotifyMutex;
153           */          static Mutex NotifyBufferMutex;
154          inline String ConvertResult(result_t result) {          static bool GetLSCPCommand( std::vector<yyparse_param_t>::iterator iter );
155              switch (result.type) {          static void CloseConnection( std::vector<yyparse_param_t>::iterator iter );
156                  case result_type_success: {          static std::vector<yyparse_param_t> Sessions;
157                      return "OK\r\n";          static Mutex SubscriptionMutex;
158                  }          static std::map< LSCPEvent::event_t, std::list<int> > eventSubscriptions;
159                  case result_type_warning: {          static fd_set fdSet;
                     std::stringstream ss;  
                     ss << "WRN:" << result.code << ":" << result.message << "\r\n";  
                     return ss.str();  
                 }  
                 case result_type_error: {  
                     std::stringstream ss;  
                     ss << "ERR:" << result.code << ":" << result.message << "\r\n";  
                     return ss.str();  
                 }  
             }  
         }  
   
         template<class T> inline String ToString(T o) {  
             std::stringstream ss;  
             ss << o;  
             return ss.str();  
         }  
160  };  };
161    
   
162  /**  /**
163   * Instrument loader thread for the LinuxSampler Control Protocol (LSCP).   * Instrument loader thread for the LinuxSampler Control Protocol (LSCP).
164   */   */

Legend:
Removed from v.155  
changed lines
  Added in v.212

  ViewVC Help
Powered by ViewVC