--- linuxsampler/trunk/src/network/lscpserver.cpp 2004/08/26 22:05:44 227 +++ 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(); } @@ -591,8 +608,8 @@ result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); - if (pSamplerChannel->GetMidiInputChannel()) result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); - else result.Add("MIDI_INPUT_CHANNEL", "ALL"); + if (pSamplerChannel->GetMidiInputChannel() == MidiInputPort::midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); + else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); result.Add("INSTRUMENT_FILE", InstrumentFileName); result.Add("INSTRUMENT_NR", InstrumentIndex); @@ -1123,6 +1140,8 @@ if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); Engine* pEngine = pSamplerChannel->GetEngine(); if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); + std::map devices = pSampler->GetAudioOutputDevices(); + if (!devices.count(ChannelAudioOutputChannel)) throw LinuxSamplerException("There is no audio output device with index " + ToString(ChannelAudioOutputChannel)); pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); } catch (LinuxSamplerException e) {