33 |
#endif |
#endif |
34 |
|
|
35 |
#include "../engines/EngineFactory.h" |
#include "../engines/EngineFactory.h" |
36 |
|
#include "../engines/EngineChannelFactory.h" |
37 |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
38 |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
39 |
|
|
63 |
|
|
64 |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) { |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) { |
65 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
66 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channels, "CHANNELS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
67 |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
68 |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
69 |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
70 |
LSCPEvent::RegisterEvent(LSCPEvent::event_info, "INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
71 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
72 |
hSocket = -1; |
hSocket = -1; |
73 |
} |
} |
191 |
} |
} |
192 |
} |
} |
193 |
|
|
194 |
|
// check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers |
195 |
|
{ |
196 |
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
197 |
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
198 |
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
199 |
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
200 |
|
if ((*itEngineChannel)->StatusChanged()) { |
201 |
|
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex)); |
202 |
|
} |
203 |
|
} |
204 |
|
} |
205 |
|
|
206 |
//Now let's deliver late notifies (if any) |
//Now let's deliver late notifies (if any) |
207 |
NotifyBufferMutex.Lock(); |
NotifyBufferMutex.Lock(); |
208 |
for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) { |
for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) { |
563 |
} |
} |
564 |
|
|
565 |
/** |
/** |
566 |
* Will be called by the parser to get all available engines. |
* Will be called by the parser to get the amount of all available engines. |
567 |
*/ |
*/ |
568 |
String LSCPServer::GetAvailableEngines() { |
String LSCPServer::GetAvailableEngines() { |
569 |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
570 |
LSCPResultSet result("GigEngine"); |
LSCPResultSet result("1"); |
571 |
|
return result.Produce(); |
572 |
|
} |
573 |
|
|
574 |
|
/** |
575 |
|
* Will be called by the parser to get a list of all available engines. |
576 |
|
*/ |
577 |
|
String LSCPServer::ListAvailableEngines() { |
578 |
|
dmsg(2,("LSCPServer: ListAvailableEngines()\n")); |
579 |
|
LSCPResultSet result("\'GIG\'"); |
580 |
return result.Produce(); |
return result.Produce(); |
581 |
} |
} |
582 |
|
|
591 |
Engine* pEngine = EngineFactory::Create(EngineName); |
Engine* pEngine = EngineFactory::Create(EngineName); |
592 |
result.Add("DESCRIPTION", pEngine->Description()); |
result.Add("DESCRIPTION", pEngine->Description()); |
593 |
result.Add("VERSION", pEngine->Version()); |
result.Add("VERSION", pEngine->Version()); |
594 |
delete pEngine; |
EngineFactory::Destroy(pEngine); |
595 |
} |
} |
596 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
597 |
result.Error(e); |
result.Error(e); |
673 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
674 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
675 |
if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel"); |
676 |
|
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
677 |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
678 |
} |
} |
679 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
694 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
695 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
696 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
697 |
|
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
698 |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
699 |
} |
} |
700 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
715 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
716 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
717 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
718 |
|
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
719 |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
720 |
else { |
else { |
721 |
switch (ResponseType) { |
switch (ResponseType) { |
740 |
dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n")); |
dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n")); |
741 |
LSCPResultSet result; |
LSCPResultSet result; |
742 |
try { |
try { |
743 |
|
int n = AudioOutputDeviceFactory::AvailableDrivers().size(); |
744 |
|
result.Add(n); |
745 |
|
} |
746 |
|
catch (LinuxSamplerException e) { |
747 |
|
result.Error(e); |
748 |
|
} |
749 |
|
return result.Produce(); |
750 |
|
} |
751 |
|
|
752 |
|
String LSCPServer::ListAvailableAudioOutputDrivers() { |
753 |
|
dmsg(2,("LSCPServer: ListAvailableAudioOutputDrivers()\n")); |
754 |
|
LSCPResultSet result; |
755 |
|
try { |
756 |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
757 |
result.Add(s); |
result.Add(s); |
758 |
} |
} |
766 |
dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n")); |
dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n")); |
767 |
LSCPResultSet result; |
LSCPResultSet result; |
768 |
try { |
try { |
769 |
|
int n = MidiInputDeviceFactory::AvailableDrivers().size(); |
770 |
|
result.Add(n); |
771 |
|
} |
772 |
|
catch (LinuxSamplerException e) { |
773 |
|
result.Error(e); |
774 |
|
} |
775 |
|
return result.Produce(); |
776 |
|
} |
777 |
|
|
778 |
|
String LSCPServer::ListAvailableMidiInputDrivers() { |
779 |
|
dmsg(2,("LSCPServer: ListAvailableMidiInputDrivers()\n")); |
780 |
|
LSCPResultSet result; |
781 |
|
try { |
782 |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
783 |
result.Add(s); |
result.Add(s); |
784 |
} |
} |
1407 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1408 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1409 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
1410 |
|
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
1411 |
pEngineChannel->GetEngine()->Reset(); |
pEngineChannel->GetEngine()->Reset(); |
1412 |
} |
} |
1413 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1426 |
return result.Produce(); |
return result.Produce(); |
1427 |
} |
} |
1428 |
|
|
1429 |
|
/** |
1430 |
|
* Will be called by the parser to return general informations about this |
1431 |
|
* sampler. |
1432 |
|
*/ |
1433 |
|
String LSCPServer::GetServerInfo() { |
1434 |
|
dmsg(2,("LSCPServer: GetServerInfo()\n")); |
1435 |
|
LSCPResultSet result; |
1436 |
|
result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler"); |
1437 |
|
result.Add("VERSION", VERSION); |
1438 |
|
result.Add("PROTOCOL_VERSION", "1.0"); |
1439 |
|
return result.Produce(); |
1440 |
|
} |
1441 |
|
|
1442 |
/** |
/** |
1443 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
1444 |
* server for receiving event messages. |
* server for receiving event messages. |