--- linuxsampler/trunk/src/network/lscpserver.h 2004/08/26 22:05:44 227 +++ linuxsampler/trunk/src/network/lscpserver.h 2005/09/23 06:58:26 778 @@ -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,12 +40,14 @@ #include "lscpparser.h" #include "lscp.h" #include "lscpevent.h" +#include "lscpinstrumentloader.h" #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_ADDR INADDR_ANY #define LSCP_PORT 8888 /// try up to 3 minutes to bind server socket @@ -61,26 +64,30 @@ */ class LSCPServer : public Thread { public: - LSCPServer(Sampler* pSampler); + LSCPServer(Sampler* pSampler, long int addr, short int port); + virtual ~LSCPServer(); int WaitUntilInitialized(long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L); // Methods called by the parser String DestroyAudioOutputDevice(uint DeviceIndex); String DestroyMidiInputDevice(uint DeviceIndex); String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false); - String LoadEngine(String EngineName, uint uiSamplerChannel); + String SetEngineType(String EngineName, uint uiSamplerChannel); String GetChannels(); String ListChannels(); String AddChannel(); String RemoveChannel(uint uiSamplerChannel); String GetAvailableEngines(); + String ListAvailableEngines(); String GetEngineInfo(String EngineName); String GetChannelInfo(uint uiSamplerChannel); String GetVoiceCount(uint uiSamplerChannel); String GetStreamCount(uint uiSamplerChannel); String GetBufferFill(fill_response_t ResponseType, uint uiSamplerChannel); String GetAvailableAudioOutputDrivers(); + String ListAvailableAudioOutputDrivers(); String GetAvailableMidiInputDrivers(); + String ListAvailableMidiInputDrivers(); String GetAudioOutputDriverInfo(String Driver); String GetMidiInputDriverInfo(String Driver); #ifdef __GNUC__ @@ -118,10 +125,16 @@ String SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel); String SetMIDIInput(uint MIDIDeviceId, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel); String SetVolume(double dVolume, uint uiSamplerChannel); + String SetChannelMute(bool bMute, uint uiSamplerChannel); + String SetChannelSolo(bool bSolo, uint uiSamplerChannel); String ResetChannel(uint uiSamplerChannel); String ResetSampler(); + String GetServerInfo(); + String GetTotalVoiceCount(); + String GetTotalVoiceCountMax(); 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); @@ -129,12 +142,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 @@ -150,6 +167,10 @@ */ int GetMidiInputDeviceIndex (MidiInputDevice *pDevice); + bool HasSoloChannel(); + void MuteNonSoloChannels(); + void UnmuteChannels(); + static std::map bufferedNotifies; static Mutex NotifyMutex; static Mutex NotifyBufferMutex; @@ -159,24 +180,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_