26 |
#include "lscpevent.h" |
#include "lscpevent.h" |
27 |
//#include "../common/global.h" |
//#include "../common/global.h" |
28 |
|
|
29 |
#ifdef HAVE_SQLITE3 |
#include <fcntl.h> |
30 |
#include "sqlite3.h" |
|
31 |
|
#if HAVE_SQLITE3 |
32 |
|
# include "sqlite3.h" |
33 |
#endif |
#endif |
34 |
|
|
35 |
#include "../engines/gig/Engine.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; |
73 |
|
} |
74 |
|
|
75 |
|
LSCPServer::~LSCPServer() { |
76 |
|
if (hSocket >= 0) close(hSocket); |
77 |
} |
} |
78 |
|
|
79 |
/** |
/** |
91 |
} |
} |
92 |
|
|
93 |
int LSCPServer::Main() { |
int LSCPServer::Main() { |
94 |
int hSocket = socket(AF_INET, SOCK_STREAM, 0); |
hSocket = socket(AF_INET, SOCK_STREAM, 0); |
95 |
if (hSocket < 0) { |
if (hSocket < 0) { |
96 |
std::cerr << "LSCPServer: Could not create server socket." << std::endl; |
std::cerr << "LSCPServer: Could not create server socket." << std::endl; |
97 |
//return -1; |
//return -1; |
174 |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
175 |
restart(NULL, dummy); // restart the 'scanner' |
restart(NULL, dummy); // restart the 'scanner' |
176 |
currentSocket = (*iter).hSession; //a hack |
currentSocket = (*iter).hSession; //a hack |
177 |
|
dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str())); |
178 |
if ((*iter).bVerbose) { // if echo mode enabled |
if ((*iter).bVerbose) { // if echo mode enabled |
179 |
AnswerClient(bufferedCommands[currentSocket]); |
AnswerClient(bufferedCommands[currentSocket]); |
180 |
} |
} |
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++) { |
473 |
try { |
try { |
474 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
475 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
476 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
477 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel yet"); |
478 |
if (!pSamplerChannel->GetAudioOutputDevice()) |
if (!pSamplerChannel->GetAudioOutputDevice()) |
479 |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
480 |
if (bBackground) { |
if (bBackground) { |
481 |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngine); |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngineChannel); |
482 |
} |
} |
483 |
else { |
else { |
484 |
// tell the engine which instrument to load |
// tell the engine channel which instrument to load |
485 |
pEngine->PrepareLoadInstrument(Filename.c_str(), uiInstrument); |
pEngineChannel->PrepareLoadInstrument(Filename.c_str(), uiInstrument); |
486 |
// actually start to load the instrument (blocks until completed) |
// actually start to load the instrument (blocks until completed) |
487 |
pEngine->LoadInstrument(); |
pEngineChannel->LoadInstrument(); |
488 |
} |
} |
489 |
} |
} |
490 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
494 |
} |
} |
495 |
|
|
496 |
/** |
/** |
497 |
* Will be called by the parser to load and deploy an engine. |
* Will be called by the parser to assign a sampler engine type to a |
498 |
|
* sampler channel. |
499 |
*/ |
*/ |
500 |
String LSCPServer::LoadEngine(String EngineName, uint uiSamplerChannel) { |
String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) { |
501 |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
502 |
LSCPResultSet result; |
LSCPResultSet result; |
503 |
try { |
try { |
|
Engine::type_t type; |
|
|
if ((EngineName == "GigEngine") || (EngineName == "gig")) type = Engine::type_gig; |
|
|
else throw LinuxSamplerException("Unknown engine type"); |
|
504 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
505 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
506 |
LockRTNotify(); |
LockRTNotify(); |
507 |
pSamplerChannel->LoadEngine(type); |
pSamplerChannel->SetEngineType(EngineName); |
508 |
UnlockRTNotify(); |
UnlockRTNotify(); |
509 |
} |
} |
510 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
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 |
|
|
583 |
/** |
/** |
584 |
* Will be called by the parser to get descriptions for a particular engine. |
* Will be called by the parser to get descriptions for a particular |
585 |
|
* sampler engine. |
586 |
*/ |
*/ |
587 |
String LSCPServer::GetEngineInfo(String EngineName) { |
String LSCPServer::GetEngineInfo(String EngineName) { |
588 |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
589 |
LSCPResultSet result; |
LSCPResultSet result; |
590 |
try { |
try { |
591 |
if ((EngineName == "GigEngine") || (EngineName == "gig")) { |
Engine* pEngine = EngineFactory::Create(EngineName); |
592 |
Engine* pEngine = new LinuxSampler::gig::Engine; |
result.Add("DESCRIPTION", pEngine->Description()); |
593 |
result.Add("DESCRIPTION", pEngine->Description()); |
result.Add("VERSION", pEngine->Version()); |
594 |
result.Add("VERSION", pEngine->Version()); |
EngineFactory::Destroy(pEngine); |
|
delete pEngine; |
|
|
} |
|
|
else throw LinuxSamplerException("Unknown engine type"); |
|
595 |
} |
} |
596 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
597 |
result.Error(e); |
result.Error(e); |
609 |
try { |
try { |
610 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
611 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
612 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
613 |
|
|
614 |
//Defaults values |
//Defaults values |
615 |
String EngineName = "NONE"; |
String EngineName = "NONE"; |
621 |
int AudioOutputChannels = 0; |
int AudioOutputChannels = 0; |
622 |
String AudioRouting; |
String AudioRouting; |
623 |
|
|
624 |
if (pEngine) { |
if (pEngineChannel) { |
625 |
EngineName = pEngine->EngineName(); |
EngineName = pEngineChannel->EngineName(); |
626 |
AudioOutputChannels = pEngine->Channels(); |
AudioOutputChannels = pEngineChannel->Channels(); |
627 |
Volume = pEngine->Volume(); |
Volume = pEngineChannel->Volume(); |
628 |
InstrumentStatus = pEngine->InstrumentStatus(); |
InstrumentStatus = pEngineChannel->InstrumentStatus(); |
629 |
InstrumentIndex = pEngine->InstrumentIndex(); |
InstrumentIndex = pEngineChannel->InstrumentIndex(); |
630 |
if (InstrumentIndex != -1) |
if (InstrumentIndex != -1) { |
631 |
{ |
InstrumentFileName = pEngineChannel->InstrumentFileName(); |
632 |
InstrumentFileName = pEngine->InstrumentFileName(); |
InstrumentName = pEngineChannel->InstrumentName(); |
633 |
InstrumentName = pEngine->InstrumentName(); |
} |
634 |
} |
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
|
for (int chan = 0; chan < pEngine->Channels(); chan++) { |
|
635 |
if (AudioRouting != "") AudioRouting += ","; |
if (AudioRouting != "") AudioRouting += ","; |
636 |
AudioRouting += ToString(pEngine->OutputChannel(chan)); |
AudioRouting += ToString(pEngineChannel->OutputChannel(chan)); |
637 |
} |
} |
638 |
} |
} |
639 |
|
|
671 |
try { |
try { |
672 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
673 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
674 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
675 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel"); |
676 |
result.Add(pEngine->VoiceCount()); |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
677 |
|
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
678 |
} |
} |
679 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
680 |
result.Error(e); |
result.Error(e); |
692 |
try { |
try { |
693 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
694 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
695 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
696 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
697 |
result.Add(pEngine->DiskStreamCount()); |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
698 |
|
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
699 |
} |
} |
700 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
701 |
result.Error(e); |
result.Error(e); |
713 |
try { |
try { |
714 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
715 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
716 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
717 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
718 |
if (!pEngine->DiskStreamSupported()) |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
719 |
result.Add("NA"); |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
720 |
else { |
else { |
721 |
switch (ResponseType) { |
switch (ResponseType) { |
722 |
case fill_response_bytes: |
case fill_response_bytes: |
723 |
result.Add(pEngine->DiskStreamBufferFillBytes()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillBytes()); |
724 |
break; |
break; |
725 |
case fill_response_percentage: |
case fill_response_percentage: |
726 |
result.Add(pEngine->DiskStreamBufferFillPercentage()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage()); |
727 |
break; |
break; |
728 |
default: |
default: |
729 |
throw LinuxSamplerException("Unknown fill response type"); |
throw LinuxSamplerException("Unknown fill response type"); |
730 |
} |
} |
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 |
} |
} |
1206 |
try { |
try { |
1207 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1208 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1209 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1210 |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type yet assigned to sampler channel " + ToString(uiSamplerChannel)); |
1211 |
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
1212 |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1213 |
} |
} |
1214 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1215 |
result.Error(e); |
result.Error(e); |
1386 |
try { |
try { |
1387 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1388 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1389 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1390 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
1391 |
pEngine->Volume(dVolume); |
pEngineChannel->Volume(dVolume); |
1392 |
} |
} |
1393 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1394 |
result.Error(e); |
result.Error(e); |
1405 |
try { |
try { |
1406 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1407 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1408 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1409 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
1410 |
pEngine->Reset(); |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
1411 |
|
pEngineChannel->GetEngine()->Reset(); |
1412 |
} |
} |
1413 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1414 |
result.Error(e); |
result.Error(e); |
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. |
1445 |
*/ |
*/ |
1475 |
|
|
1476 |
String LSCPServer::QueryDatabase(String query) { |
String LSCPServer::QueryDatabase(String query) { |
1477 |
LSCPResultSet result; |
LSCPResultSet result; |
1478 |
#ifdef HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
1479 |
char* zErrMsg = NULL; |
char* zErrMsg = NULL; |
1480 |
sqlite3 *db; |
sqlite3 *db; |
1481 |
String selectStr = "SELECT " + query; |
String selectStr = "SELECT " + query; |
1487 |
} |
} |
1488 |
if ( rc != SQLITE_OK ) |
if ( rc != SQLITE_OK ) |
1489 |
{ |
{ |
1490 |
//result.Error(String(zErrMsg), rc); |
result.Error(String(zErrMsg), rc); |
|
result.Error(selectStr, 666); |
|
1491 |
} |
} |
1492 |
sqlite3_close(db); |
sqlite3_close(db); |
1493 |
#else |
#else |