50 |
Mutex LSCPServer::NotifyMutex = Mutex(); |
Mutex LSCPServer::NotifyMutex = Mutex(); |
51 |
Mutex LSCPServer::NotifyBufferMutex = Mutex(); |
Mutex LSCPServer::NotifyBufferMutex = Mutex(); |
52 |
Mutex LSCPServer::SubscriptionMutex = Mutex(); |
Mutex LSCPServer::SubscriptionMutex = Mutex(); |
53 |
|
Mutex LSCPServer::RTNotifyMutex = Mutex(); |
54 |
|
|
55 |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { |
56 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
204 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
205 |
} |
} |
206 |
|
|
207 |
|
int LSCPServer::EventSubscribers( std::list<LSCPEvent::event_t> events ) { |
208 |
|
int subs = 0; |
209 |
|
SubscriptionMutex.Lock(); |
210 |
|
for( std::list<LSCPEvent::event_t>::iterator iter = events.begin(); |
211 |
|
iter != events.end(); iter++) |
212 |
|
{ |
213 |
|
subs += eventSubscriptions.count(*iter); |
214 |
|
} |
215 |
|
SubscriptionMutex.Unlock(); |
216 |
|
return subs; |
217 |
|
} |
218 |
|
|
219 |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
220 |
SubscriptionMutex.Lock(); |
SubscriptionMutex.Lock(); |
221 |
if (eventSubscriptions.count(event.GetType()) == 0) { |
if (eventSubscriptions.count(event.GetType()) == 0) { |
474 |
else throw LinuxSamplerException("Unknown engine type"); |
else throw LinuxSamplerException("Unknown engine type"); |
475 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
476 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
477 |
|
LockRTNotify(); |
478 |
pSamplerChannel->LoadEngine(type); |
pSamplerChannel->LoadEngine(type); |
479 |
|
UnlockRTNotify(); |
480 |
} |
} |
481 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
482 |
result.Error(e); |
result.Error(e); |
527 |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
528 |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
529 |
LSCPResultSet result; |
LSCPResultSet result; |
530 |
|
LockRTNotify(); |
531 |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
532 |
|
UnlockRTNotify(); |
533 |
return result.Produce(); |
return result.Produce(); |
534 |
} |
} |
535 |
|
|