--- linuxsampler/trunk/src/network/lscpserver.h 2004/07/03 20:08:07 170 +++ linuxsampler/trunk/src/network/lscpserver.h 2005/02/07 00:19:30 360 @@ -42,16 +42,19 @@ #include "../Sampler.h" #include "../common/Thread.h" #include "../common/Mutex.h" +#include "../common/Condition.h" /// TCP Port on which the server should listen for connection requests. #define LSCP_PORT 8888 +/// try up to 3 minutes to bind server socket +#define LSCP_SERVER_BIND_TIMEOUT 180 + using namespace LinuxSampler; // External references to the main scanner and parser functions extern int yyparse(void* YYPARSE_PARAM); -extern int yylex_init(yyscan_t* scanner); -extern int yylex_destroy(yyscan_t yyscanner); +extern void restart(yyparse_param_t* pparam, int& yychar); /** * Network server for the LinuxSampler Control Protocol (LSCP). @@ -59,6 +62,7 @@ class LSCPServer : public Thread { public: LSCPServer(Sampler* pSampler); + int WaitUntilInitialized(long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L); // Methods called by the parser String DestroyAudioOutputDevice(uint DeviceIndex); @@ -66,6 +70,7 @@ String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false); String LoadEngine(String EngineName, uint uiSamplerChannel); String GetChannels(); + String ListChannels(); String AddChannel(); String RemoveChannel(uint uiSamplerChannel); String GetAvailableEngines(); @@ -97,6 +102,7 @@ String GetAudioOutputDeviceInfo(uint DeviceIndex); String GetMidiInputDeviceInfo(uint DeviceIndex); String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex); + String GetMidiInputPortParameterInfo(uint DeviceId, uint PortId, String ParameterName); String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId); String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName); String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal); @@ -111,30 +117,37 @@ String SetMIDIInputDevice(uint MIDIDeviceId, uint uiSamplerChannel); String SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel); String SetMIDIInput(uint MIDIDeviceId, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel); - String SetVolume(double Volume, uint uiSamplerChannel); + String SetVolume(double dVolume, uint uiSamplerChannel); String ResetChannel(uint uiSamplerChannel); + String ResetSampler(); String SubscribeNotification(LSCPEvent::event_t); String UnsubscribeNotification(LSCPEvent::event_t); + String SetEcho(yyparse_param_t* pSession, double boolean_value); void AnswerClient(String ReturnMessage); static int currentSocket; static std::map bufferedCommands; + + static void SendLSCPNotify( LSCPEvent Event ); + static int EventSubscribers( std::list events ); + static void LockRTNotify( void ) { RTNotifyMutex.Lock(); } + static void UnlockRTNotify( void ) { RTNotifyMutex.Unlock(); } + protected: int hSocket; sockaddr_in SocketAddress; Sampler* pSampler; + Condition Initialized; int Main(); ///< Implementation of virtual method from class Thread - static void SendLSCPNotify( LSCPEvent Event ); - private: - + /** * Find a created audio output device index. */ int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice); - + /** * Find a created midi input device index. */ @@ -143,12 +156,17 @@ static std::map bufferedNotifies; static Mutex NotifyMutex; static Mutex NotifyBufferMutex; - static bool GetLSCPCommand( std::vector::iterator iter ); - static void CloseConnection( std::vector::iterator iter ); - static std::vector hSessions; + static bool GetLSCPCommand( std::vector::iterator iter ); + static void CloseConnection( std::vector::iterator iter ); + static std::vector Sessions; static Mutex SubscriptionMutex; static std::map< LSCPEvent::event_t, std::list > eventSubscriptions; static fd_set fdSet; + + //Protect main thread that generates real time notify messages + //like voice count, stream count and buffer fill + //from LSCP server removing engines and channels from underneath + static Mutex RTNotifyMutex; }; /**