--- linuxsampler/trunk/src/network/lscpserver.h 2004/07/28 14:17:29 212 +++ linuxsampler/trunk/src/network/lscpserver.h 2005/02/21 04:28:50 397 @@ -3,19 +3,20 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * + * Copyright (C) 2005 Christian Schoenebeck * * * - * This program is free software; you can redistribute it and/or modify * + * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * This program is distributed in the hope that it will be useful, * + * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * + * along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * ***************************************************************************/ @@ -39,6 +40,7 @@ #include "lscpparser.h" #include "lscp.h" #include "lscpevent.h" +#include "lscpinstrumentloader.h" #include "../Sampler.h" #include "../common/Thread.h" #include "../common/Mutex.h" @@ -47,12 +49,14 @@ /// 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). @@ -115,11 +119,12 @@ 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 QueryDatabase(String query); String SetEcho(yyparse_param_t* pSession, double boolean_value); void AnswerClient(String ReturnMessage); @@ -127,12 +132,16 @@ 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; + LSCPInstrumentLoader InstrumentLoader; ///< thread responsible for loading instruments in the background int Main(); ///< Implementation of virtual method from class Thread @@ -157,24 +166,11 @@ static Mutex SubscriptionMutex; static std::map< LSCPEvent::event_t, std::list > eventSubscriptions; static fd_set fdSet; -}; - -/** - * Instrument loader thread for the LinuxSampler Control Protocol (LSCP). - */ -class LSCPLoadInstrument : public Thread { - - public: - LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument); - - protected: - // Instance variables. - Engine* pEngine; - String Filename; - uint uiInstrument; - // Implementation of virtual method from class Thread. - int Main(); + //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; }; #endif // __LSCPSERVER_H_