/[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 184 - (hide annotations) (download) (as text)
Wed Jul 7 02:00:37 2004 UTC (19 years, 8 months ago) by senkov
File MIME type: text/x-c++hdr
File size: 8121 byte(s)
* Added MISCELLANEOUS event to help debugging client/server
interaction. It spits out every line received by the server.

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 35
46     /// TCP Port on which the server should listen for connection requests.
47     #define LSCP_PORT 8888
48    
49 schoenebeck 53 using namespace LinuxSampler;
50    
51 schoenebeck 35 // External references to the main scanner and parser functions
52     extern int yyparse(void* YYPARSE_PARAM);
53     extern int yylex_init(yyscan_t* scanner);
54     extern int yylex_destroy(yyscan_t yyscanner);
55    
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 35
63     // Methods called by the parser
64 schoenebeck 123 String DestroyAudioOutputDevice(uint DeviceIndex);
65 senkov 155 String DestroyMidiInputDevice(uint DeviceIndex);
66 capela 137 String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false);
67 schoenebeck 53 String LoadEngine(String EngineName, uint uiSamplerChannel);
68 schoenebeck 35 String GetChannels();
69     String AddChannel();
70 schoenebeck 53 String RemoveChannel(uint uiSamplerChannel);
71 schoenebeck 35 String GetAvailableEngines();
72     String GetEngineInfo(String EngineName);
73 schoenebeck 53 String GetChannelInfo(uint uiSamplerChannel);
74     String GetVoiceCount(uint uiSamplerChannel);
75     String GetStreamCount(uint uiSamplerChannel);
76     String GetBufferFill(fill_response_t ResponseType, uint uiSamplerChannel);
77 schoenebeck 123 String GetAvailableAudioOutputDrivers();
78 senkov 155 String GetAvailableMidiInputDrivers();
79 schoenebeck 123 String GetAudioOutputDriverInfo(String Driver);
80 senkov 155 String GetMidiInputDriverInfo(String Driver);
81 schoenebeck 123 #ifdef __GNUC__
82     typedef std::map<String,String> StringMap; // nasty workaround for a GCC bug (see GCC bug #15980, #57)
83     String GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = StringMap());
84 senkov 155 String GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = StringMap());
85 senkov 140 String CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters = StringMap());
86 senkov 155 String CreateMidiInputDevice(String Driver, std::map<String,String> Parameters = StringMap());
87 schoenebeck 123 #else
88     String GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = std::map<String,String>());
89 senkov 155 String GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList = std::map<String,String>());
90 senkov 140 String CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters = std::map<String,String>());
91 senkov 155 String CreateMidiInputDevice(String Driver, std::map<String,String> Parameters = std::map<String,String>());
92 schoenebeck 123 #endif // __GNUC__
93     String GetAudioOutputDeviceCount();
94 senkov 155 String GetMidiInputDeviceCount();
95 schoenebeck 123 String GetAudioOutputDevices();
96 senkov 155 String GetMidiInputDevices();
97 schoenebeck 123 String GetAudioOutputDeviceInfo(uint DeviceIndex);
98 senkov 155 String GetMidiInputDeviceInfo(uint DeviceIndex);
99     String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex);
100 schoenebeck 123 String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId);
101     String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName);
102     String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal);
103     String SetAudioOutputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
104 senkov 155 String SetMidiInputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal);
105 capela 159 String SetMidiInputPortParameter(uint DeviceIndex, uint PortIndex, String ParamKey, String ParamVal);
106 schoenebeck 123 String SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel);
107 capela 159 String SetAudioOutputDevice(uint AudioDeviceId, uint SamplerChannel);
108 capela 143 String SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel);
109 capela 159 String SetMIDIInputPort(uint MIDIPort, uint uiSamplerChannel);
110     String SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel);
111     String SetMIDIInputDevice(uint MIDIDeviceId, uint uiSamplerChannel);
112 schoenebeck 123 String SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel);
113 capela 159 String SetMIDIInput(uint MIDIDeviceId, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel);
114 schoenebeck 53 String SetVolume(double Volume, uint uiSamplerChannel);
115     String ResetChannel(uint uiSamplerChannel);
116 senkov 170 String SubscribeNotification(LSCPEvent::event_t);
117     String UnsubscribeNotification(LSCPEvent::event_t);
118 schoenebeck 35 void AnswerClient(String ReturnMessage);
119 senkov 170
120     static int currentSocket;
121     static std::map<int,String> bufferedCommands;
122 senkov 184
123     static void SendLSCPNotify( LSCPEvent Event );
124    
125 schoenebeck 35 protected:
126 schoenebeck 53 int hSocket;
127     sockaddr_in SocketAddress;
128     Sampler* pSampler;
129 schoenebeck 35
130     int Main(); ///< Implementation of virtual method from class Thread
131 senkov 170
132 schoenebeck 35 private:
133 capela 143
134 schoenebeck 35 /**
135 capela 143 * Find a created audio output device index.
136     */
137     int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice);
138 senkov 155
139     /**
140     * Find a created midi input device index.
141     */
142     int GetMidiInputDeviceIndex (MidiInputDevice *pDevice);
143 capela 143
144 senkov 170 static std::map<int,String> bufferedNotifies;
145     static Mutex NotifyMutex;
146     static Mutex NotifyBufferMutex;
147     static bool GetLSCPCommand( std::vector<int>::iterator iter );
148     static void CloseConnection( std::vector<int>::iterator iter );
149     static std::vector<int> hSessions;
150     static Mutex SubscriptionMutex;
151     static std::map< LSCPEvent::event_t, std::list<int> > eventSubscriptions;
152     static fd_set fdSet;
153 schoenebeck 35 };
154    
155 capela 133 /**
156     * Instrument loader thread for the LinuxSampler Control Protocol (LSCP).
157     */
158     class LSCPLoadInstrument : public Thread {
159    
160     public:
161     LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument);
162    
163     protected:
164     // Instance variables.
165     Engine* pEngine;
166     String Filename;
167     uint uiInstrument;
168    
169     // Implementation of virtual method from class Thread.
170     int Main();
171     };
172    
173 schoenebeck 35 #endif // __LSCPSERVER_H_

  ViewVC Help
Powered by ViewVC