--- linuxsampler/trunk/src/network/lscpserver.cpp 2005/01/09 02:26:29 337 +++ linuxsampler/trunk/src/network/lscpserver.cpp 2005/02/07 00:19:30 360 @@ -50,6 +50,7 @@ Mutex LSCPServer::NotifyMutex = Mutex(); Mutex LSCPServer::NotifyBufferMutex = Mutex(); Mutex LSCPServer::SubscriptionMutex = Mutex(); +Mutex LSCPServer::RTNotifyMutex = Mutex(); LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { this->pSampler = pSampler; @@ -203,6 +204,18 @@ NotifyMutex.Unlock(); } +int LSCPServer::EventSubscribers( std::list events ) { + int subs = 0; + SubscriptionMutex.Lock(); + for( std::list::iterator iter = events.begin(); + iter != events.end(); iter++) + { + subs += eventSubscriptions.count(*iter); + } + SubscriptionMutex.Unlock(); + return subs; +} + void LSCPServer::SendLSCPNotify( LSCPEvent event ) { SubscriptionMutex.Lock(); if (eventSubscriptions.count(event.GetType()) == 0) { @@ -461,7 +474,9 @@ else throw LinuxSamplerException("Unknown engine type"); SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); + LockRTNotify(); pSamplerChannel->LoadEngine(type); + UnlockRTNotify(); } catch (LinuxSamplerException e) { result.Error(e); @@ -512,7 +527,9 @@ String LSCPServer::RemoveChannel(uint uiSamplerChannel) { dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); LSCPResultSet result; + LockRTNotify(); pSampler->RemoveSamplerChannel(uiSamplerChannel); + UnlockRTNotify(); return result.Produce(); }