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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 225 - (hide annotations) (download) (as text)
Sun Aug 22 14:46:47 2004 UTC (19 years, 7 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 8509 byte(s)
* set default volume to 1.0 in Gigasampler engine (was 0.0)
* implemented "SET CHANNEL AUDIO_OUTPUT_CHANNEL" LSCP command
* fixed "GET ENGINE INFO" LSCP command
* fixed "GET CHANNEL INFO" LSCP command
* src/network/lscp.y: fixed 'stringval' rule (returned string with formal
  apostrophes), fixed 'dotnum' rule (ignored position after decimal point)

1 schoenebeck 35 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5 schoenebeck 56 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 35 * *
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 senkov 170 #include <sys/select.h>
30     #include <sys/time.h>
31 schoenebeck 35 #include <netinet/in.h>
32     #include <netinet/tcp.h>
33     #include <arpa/inet.h>
34     #include <netdb.h>
35    
36 senkov 170 #include <list>
37    
38 schoenebeck 53 #include "lscp.h"
39 schoenebeck 35 #include "lscpparser.h"
40 senkov 170 #include "lscp.h"
41     #include "lscpevent.h"
42 schoenebeck 53 #include "../Sampler.h"
43     #include "../common/Thread.h"
44 senkov 170 #include "../common/Mutex.h"
45 schoenebeck 211 #include "../common/Condition.h"
46 schoenebeck 35
47     /// TCP Port on which the server should listen for connection requests.
48     #define LSCP_PORT 8888
49    
50 schoenebeck 53 using namespace LinuxSampler;
51    
52 schoenebeck 35 // External references to the main scanner and parser functions
53     extern int yyparse(void* YYPARSE_PARAM);
54 schoenebeck 219 extern void restart(yyparse_param_t* pparam, int& yychar);
55 schoenebeck 35
56     /**
57     * Network server for the LinuxSampler Control Protocol (LSCP).
58     */
59     class LSCPServer : public Thread {
60     public:
61 schoenebeck 53 LSCPServer(Sampler* pSampler);
62 schoenebeck 211 int WaitUntilInitialized(long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L);
63 schoenebeck 35
64     // Methods called by the parser
65 schoenebeck 123 String DestroyAudioOutputDevice(uint DeviceIndex);
66 senkov 155 String DestroyMidiInputDevice(uint DeviceIndex);
67 capela 137 String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false);
68 schoenebeck 53 String LoadEngine(String EngineName, uint uiSamplerChannel);
69 schoenebeck 35 String GetChannels();
70 schoenebeck 209 String ListChannels();
71 schoenebeck 35 String AddChannel();
72 schoenebeck 53 String RemoveChannel(uint uiSamplerChannel);
73 schoenebeck 35 String GetAvailableEngines();
74     String GetEngineInfo(String EngineName);
75 schoenebeck 53 String GetChannelInfo(uint uiSamplerChannel);
76     String GetVoiceCount(uint uiSamplerChannel);
77     String GetStreamCount(uint uiSamplerChannel);
78     String GetBufferFill(fill_response_t ResponseType, uint uiSamplerChannel);
79 schoenebeck 123 String GetAvailableAudioOutputDrivers();
80 senkov 155 String GetAvailableMidiInputDrivers();
81 schoenebeck 123 String GetAudioOutputDriverInfo(String Driver);
82 senkov 155 String GetMidiInputDriverInfo(String Driver);
83 schoenebeck 123 #ifdef __GNUC__
84     typedef std::map<String,String> StringMap; // nasty workaround for a GCC bug (see GCC bug #15980, #57)
85     String GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = StringMap());
86 senkov 155 String GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = StringMap());
87 senkov 140 String CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters = StringMap());
88 senkov 155 String CreateMidiInputDevice(String Driver, std::map<String,String> Parameters = StringMap());
89 schoenebeck 123 #else
90     String GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = std::map<String,String>());
91 senkov 155 String GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = std::map<String,String>());
92 senkov 140 String CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters = std::map<String,String>());
93 senkov 155 String CreateMidiInputDevice(String Driver, std::map<String,String> Parameters = std::map<String,String>());
94 schoenebeck 123 #endif // __GNUC__
95     String GetAudioOutputDeviceCount();
96 senkov 155 String GetMidiInputDeviceCount();
97 schoenebeck 123 String GetAudioOutputDevices();
98 senkov 155 String GetMidiInputDevices();
99 schoenebeck 123 String GetAudioOutputDeviceInfo(uint DeviceIndex);
100 senkov 155 String GetMidiInputDeviceInfo(uint DeviceIndex);
101     String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex);
102 senkov 185 String GetMidiInputPortParameterInfo(uint DeviceId, uint PortId, String ParameterName);
103 schoenebeck 123 String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId);
104     String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName);
105     String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal);
106     String SetAudioOutputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
107 senkov 155 String SetMidiInputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
108 capela 159 String SetMidiInputPortParameter(uint DeviceIndex, uint PortIndex, String ParamKey, String ParamVal);
109 schoenebeck 123 String SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel);
110 capela 159 String SetAudioOutputDevice(uint AudioDeviceId, uint SamplerChannel);
111 capela 143 String SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel);
112 capela 159 String SetMIDIInputPort(uint MIDIPort, uint uiSamplerChannel);
113     String SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel);
114     String SetMIDIInputDevice(uint MIDIDeviceId, uint uiSamplerChannel);
115 schoenebeck 123 String SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel);
116 capela 159 String SetMIDIInput(uint MIDIDeviceId, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel);
117 schoenebeck 225 String SetVolume(double dVolume, uint uiSamplerChannel);
118 schoenebeck 53 String ResetChannel(uint uiSamplerChannel);
119 schoenebeck 212 String ResetSampler();
120 senkov 170 String SubscribeNotification(LSCPEvent::event_t);
121     String UnsubscribeNotification(LSCPEvent::event_t);
122 schoenebeck 210 String SetEcho(yyparse_param_t* pSession, double boolean_value);
123 schoenebeck 35 void AnswerClient(String ReturnMessage);
124 senkov 170
125     static int currentSocket;
126     static std::map<int,String> bufferedCommands;
127 senkov 184
128     static void SendLSCPNotify( LSCPEvent Event );
129    
130 schoenebeck 35 protected:
131 schoenebeck 53 int hSocket;
132     sockaddr_in SocketAddress;
133     Sampler* pSampler;
134 schoenebeck 211 Condition Initialized;
135 schoenebeck 35
136     int Main(); ///< Implementation of virtual method from class Thread
137 senkov 170
138 schoenebeck 35 private:
139 schoenebeck 209
140 schoenebeck 35 /**
141 capela 143 * Find a created audio output device index.
142     */
143     int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice);
144 schoenebeck 209
145 senkov 155 /**
146     * Find a created midi input device index.
147     */
148     int GetMidiInputDeviceIndex (MidiInputDevice *pDevice);
149 capela 143
150 senkov 170 static std::map<int,String> bufferedNotifies;
151     static Mutex NotifyMutex;
152     static Mutex NotifyBufferMutex;
153 schoenebeck 210 static bool GetLSCPCommand( std::vector<yyparse_param_t>::iterator iter );
154     static void CloseConnection( std::vector<yyparse_param_t>::iterator iter );
155     static std::vector<yyparse_param_t> Sessions;
156 senkov 170 static Mutex SubscriptionMutex;
157     static std::map< LSCPEvent::event_t, std::list<int> > eventSubscriptions;
158     static fd_set fdSet;
159 schoenebeck 35 };
160    
161 capela 133 /**
162     * Instrument loader thread for the LinuxSampler Control Protocol (LSCP).
163     */
164     class LSCPLoadInstrument : public Thread {
165    
166     public:
167     LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument);
168    
169     protected:
170     // Instance variables.
171     Engine* pEngine;
172     String Filename;
173     uint uiInstrument;
174    
175     // Implementation of virtual method from class Thread.
176     int Main();
177     };
178    
179 schoenebeck 35 #endif // __LSCPSERVER_H_

  ViewVC Help
Powered by ViewVC