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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 212 - (show annotations) (download) (as text)
Wed Jul 28 14:17:29 2004 UTC (19 years, 9 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 8537 byte(s)
* introduced and implemented new LSCP command "RESET" which resets the
  whole sampler instance
* src/drivers/audio/AudioOutputDeviceAlsa.cpp: parameter 'card' now
  returns all available sound cards as possibility, added dependency to
  parameter 'card' to parameters 'fragments' and 'fragmentsize'
* src/drivers/DeviceParameter.cpp: fixed return value(s) for classes
  'DeviceCreationParameterString' and 'DeviceCreationParameterStrings'
  which returned the default value(s) not encapsulated into apostrophes
* src/network/lscpserver.cpp: fixed implementation of LSCP commands
  "GET MIDI_INPUT_DRIVER_PARAMETER INFO" and
  "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO"

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #ifndef __LSCPSERVER_H_
24 #define __LSCPSERVER_H_
25
26 #include <unistd.h>
27 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <sys/select.h>
30 #include <sys/time.h>
31 #include <netinet/in.h>
32 #include <netinet/tcp.h>
33 #include <arpa/inet.h>
34 #include <netdb.h>
35
36 #include <list>
37
38 #include "lscp.h"
39 #include "lscpparser.h"
40 #include "lscp.h"
41 #include "lscpevent.h"
42 #include "../Sampler.h"
43 #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.
48 #define LSCP_PORT 8888
49
50 using namespace LinuxSampler;
51
52 // External references to the main scanner and parser functions
53 extern int yyparse(void* YYPARSE_PARAM);
54 extern int yylex_init(yyscan_t* scanner);
55 extern int yylex_destroy(yyscan_t yyscanner);
56
57 /**
58 * Network server for the LinuxSampler Control Protocol (LSCP).
59 */
60 class LSCPServer : public Thread {
61 public:
62 LSCPServer(Sampler* pSampler);
63 int WaitUntilInitialized(long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L);
64
65 // Methods called by the parser
66 String DestroyAudioOutputDevice(uint DeviceIndex);
67 String DestroyMidiInputDevice(uint DeviceIndex);
68 String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false);
69 String LoadEngine(String EngineName, uint uiSamplerChannel);
70 String GetChannels();
71 String ListChannels();
72 String AddChannel();
73 String RemoveChannel(uint uiSamplerChannel);
74 String GetAvailableEngines();
75 String GetEngineInfo(String EngineName);
76 String GetChannelInfo(uint uiSamplerChannel);
77 String GetVoiceCount(uint uiSamplerChannel);
78 String GetStreamCount(uint uiSamplerChannel);
79 String GetBufferFill(fill_response_t ResponseType, uint uiSamplerChannel);
80 String GetAvailableAudioOutputDrivers();
81 String GetAvailableMidiInputDrivers();
82 String GetAudioOutputDriverInfo(String Driver);
83 String GetMidiInputDriverInfo(String Driver);
84 #ifdef __GNUC__
85 typedef std::map<String,String> StringMap; // nasty workaround for a GCC bug (see GCC bug #15980, #57)
86 String GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = StringMap());
87 String GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = StringMap());
88 String CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters = StringMap());
89 String CreateMidiInputDevice(String Driver, std::map<String,String> Parameters = StringMap());
90 #else
91 String GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = std::map<String,String>());
92 String GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = std::map<String,String>());
93 String CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters = std::map<String,String>());
94 String CreateMidiInputDevice(String Driver, std::map<String,String> Parameters = std::map<String,String>());
95 #endif // __GNUC__
96 String GetAudioOutputDeviceCount();
97 String GetMidiInputDeviceCount();
98 String GetAudioOutputDevices();
99 String GetMidiInputDevices();
100 String GetAudioOutputDeviceInfo(uint DeviceIndex);
101 String GetMidiInputDeviceInfo(uint DeviceIndex);
102 String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex);
103 String GetMidiInputPortParameterInfo(uint DeviceId, uint PortId, String ParameterName);
104 String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId);
105 String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName);
106 String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal);
107 String SetAudioOutputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
108 String SetMidiInputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
109 String SetMidiInputPortParameter(uint DeviceIndex, uint PortIndex, String ParamKey, String ParamVal);
110 String SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel);
111 String SetAudioOutputDevice(uint AudioDeviceId, uint SamplerChannel);
112 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);
117 String SetMIDIInput(uint MIDIDeviceId, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel);
118 String SetVolume(double Volume, uint uiSamplerChannel);
119 String ResetChannel(uint uiSamplerChannel);
120 String ResetSampler();
121 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);
125
126 static int currentSocket;
127 static std::map<int,String> bufferedCommands;
128
129 static void SendLSCPNotify( LSCPEvent Event );
130
131 protected:
132 int hSocket;
133 sockaddr_in SocketAddress;
134 Sampler* pSampler;
135 Condition Initialized;
136
137 int Main(); ///< Implementation of virtual method from class Thread
138
139 private:
140
141 /**
142 * Find a created audio output device index.
143 */
144 int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice);
145
146 /**
147 * Find a created midi input device index.
148 */
149 int GetMidiInputDeviceIndex (MidiInputDevice *pDevice);
150
151 static std::map<int,String> bufferedNotifies;
152 static Mutex NotifyMutex;
153 static Mutex NotifyBufferMutex;
154 static bool GetLSCPCommand( std::vector<yyparse_param_t>::iterator iter );
155 static void CloseConnection( std::vector<yyparse_param_t>::iterator iter );
156 static std::vector<yyparse_param_t> Sessions;
157 static Mutex SubscriptionMutex;
158 static std::map< LSCPEvent::event_t, std::list<int> > eventSubscriptions;
159 static fd_set fdSet;
160 };
161
162 /**
163 * Instrument loader thread for the LinuxSampler Control Protocol (LSCP).
164 */
165 class LSCPLoadInstrument : public Thread {
166
167 public:
168 LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument);
169
170 protected:
171 // Instance variables.
172 Engine* pEngine;
173 String Filename;
174 uint uiInstrument;
175
176 // Implementation of virtual method from class Thread.
177 int Main();
178 };
179
180 #endif // __LSCPSERVER_H_

  ViewVC Help
Powered by ViewVC