3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2010 Christian Schoenebeck * |
* Copyright (C) 2005 - 2014 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
47 |
|
|
48 |
namespace LinuxSampler { |
namespace LinuxSampler { |
49 |
|
|
50 |
|
String lscpParserProcessShellInteraction(String& line, yyparse_param_t* param); |
51 |
|
|
52 |
/** |
/** |
53 |
* Returns a copy of the given string where all special characters are |
* Returns a copy of the given string where all special characters are |
54 |
* replaced by LSCP escape sequences ("\xHH"). This function shall be used |
* replaced by LSCP escape sequences ("\xHH"). This function shall be used |
99 |
*/ |
*/ |
100 |
fd_set LSCPServer::fdSet; |
fd_set LSCPServer::fdSet; |
101 |
int LSCPServer::currentSocket = -1; |
int LSCPServer::currentSocket = -1; |
102 |
std::vector<yyparse_param_t> LSCPServer::Sessions = std::vector<yyparse_param_t>(); |
std::vector<yyparse_param_t> LSCPServer::Sessions; |
103 |
std::vector<yyparse_param_t>::iterator itCurrentSession = std::vector<yyparse_param_t>::iterator(); |
std::vector<yyparse_param_t>::iterator itCurrentSession; |
104 |
std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>(); |
std::map<int,String> LSCPServer::bufferedNotifies; |
105 |
std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>(); |
std::map<int,String> LSCPServer::bufferedCommands; |
106 |
std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions = std::map< LSCPEvent::event_t, std::list<int> >(); |
std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions; |
107 |
Mutex LSCPServer::NotifyMutex = Mutex(); |
Mutex LSCPServer::NotifyMutex; |
108 |
Mutex LSCPServer::NotifyBufferMutex = Mutex(); |
Mutex LSCPServer::NotifyBufferMutex; |
109 |
Mutex LSCPServer::SubscriptionMutex = Mutex(); |
Mutex LSCPServer::SubscriptionMutex; |
110 |
Mutex LSCPServer::RTNotifyMutex = Mutex(); |
Mutex LSCPServer::RTNotifyMutex; |
111 |
|
|
112 |
LSCPServer::LSCPServer(Sampler* pSampler, long int addr, short int port) : Thread(true, false, 0, -4), eventHandler(this) { |
LSCPServer::LSCPServer(Sampler* pSampler, long int addr, short int port) : Thread(true, false, 0, -4), eventHandler(this) { |
113 |
SocketAddress.sin_family = AF_INET; |
SocketAddress.sin_family = AF_INET; |
140 |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
141 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_midi, "CHANNEL_MIDI"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_midi, "CHANNEL_MIDI"); |
142 |
LSCPEvent::RegisterEvent(LSCPEvent::event_device_midi, "DEVICE_MIDI"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_device_midi, "DEVICE_MIDI"); |
143 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_fx_instance_count, "EFFECT_INSTANCE_COUNT"); |
144 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_fx_instance_info, "EFFECT_INSTANCE_INFO"); |
145 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_send_fx_chain_count, "SEND_EFFECT_CHAIN_COUNT"); |
146 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_send_fx_chain_info, "SEND_EFFECT_CHAIN_INFO"); |
147 |
hSocket = -1; |
hSocket = -1; |
148 |
} |
} |
149 |
|
|
449 |
#endif |
#endif |
450 |
// check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers |
// check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers |
451 |
{ |
{ |
452 |
|
LockGuard lock(EngineChannelFactory::EngineChannelsMutex); |
453 |
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
454 |
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
455 |
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
518 |
} |
} |
519 |
} |
} |
520 |
|
|
521 |
//Now let's deliver late notifies (if any) |
//Now let's deliver late notifies (if any) |
522 |
NotifyBufferMutex.Lock(); |
{ |
523 |
for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) { |
LockGuard lock(NotifyBufferMutex); |
524 |
|
for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) { |
525 |
#ifdef MSG_NOSIGNAL |
#ifdef MSG_NOSIGNAL |
526 |
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL); |
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL); |
527 |
#else |
#else |
528 |
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), 0); |
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), 0); |
529 |
#endif |
#endif |
530 |
} |
} |
531 |
bufferedNotifies.clear(); |
bufferedNotifies.clear(); |
532 |
NotifyBufferMutex.Unlock(); |
} |
533 |
|
|
534 |
fd_set selectSet = fdSet; |
fd_set selectSet = fdSet; |
535 |
timeout.tv_sec = 0; |
timeout.tv_sec = 0; |
594 |
//Something was selected and it was not the hSocket, so it must be some command(s) coming. |
//Something was selected and it was not the hSocket, so it must be some command(s) coming. |
595 |
for (std::vector<yyparse_param_t>::iterator iter = Sessions.begin(); iter != Sessions.end(); iter++) { |
for (std::vector<yyparse_param_t>::iterator iter = Sessions.begin(); iter != Sessions.end(); iter++) { |
596 |
if (FD_ISSET((*iter).hSession, &selectSet)) { //Was it this socket? |
if (FD_ISSET((*iter).hSession, &selectSet)) { //Was it this socket? |
597 |
|
currentSocket = (*iter).hSession; //a hack |
598 |
if (GetLSCPCommand(iter)) { //Have we read the entire command? |
if (GetLSCPCommand(iter)) { //Have we read the entire command? |
599 |
dmsg(3,("LSCPServer: Got command on socket %d, calling parser.\n", currentSocket)); |
dmsg(3,("LSCPServer: Got command on socket %d, calling parser.\n", currentSocket)); |
600 |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
601 |
restart(NULL, dummy); // restart the 'scanner' |
restart(NULL, dummy); // restart the 'scanner' |
|
currentSocket = (*iter).hSession; //a hack |
|
602 |
itCurrentSession = iter; // another hack |
itCurrentSession = iter; // another hack |
603 |
dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str())); |
dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str())); |
604 |
if ((*iter).bVerbose) { // if echo mode enabled |
if ((*iter).bVerbose) { // if echo mode enabled |
612 |
CloseConnection(iter); |
CloseConnection(iter); |
613 |
} |
} |
614 |
} |
} |
615 |
|
currentSocket = -1; //continuation of a hack |
616 |
//socket may have been closed, iter may be invalid, get out of the loop for now. |
//socket may have been closed, iter may be invalid, get out of the loop for now. |
617 |
//we'll be back if there is data. |
//we'll be back if there is data. |
618 |
break; |
break; |
627 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Client connection terminated on socket", socket)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Client connection terminated on socket", socket)); |
628 |
Sessions.erase(iter); |
Sessions.erase(iter); |
629 |
FD_CLR(socket, &fdSet); |
FD_CLR(socket, &fdSet); |
630 |
SubscriptionMutex.Lock(); //Must unsubscribe this socket from all events (if any) |
{ |
631 |
for (std::map< LSCPEvent::event_t, std::list<int> >::iterator iter = eventSubscriptions.begin(); iter != eventSubscriptions.end(); iter++) { |
LockGuard lock(SubscriptionMutex); |
632 |
iter->second.remove(socket); |
// Must unsubscribe this socket from all events (if any) |
633 |
} |
for (std::map< LSCPEvent::event_t, std::list<int> >::iterator iter = eventSubscriptions.begin(); iter != eventSubscriptions.end(); iter++) { |
634 |
SubscriptionMutex.Unlock(); |
iter->second.remove(socket); |
635 |
NotifyMutex.Lock(); |
} |
636 |
|
} |
637 |
|
LockGuard lock(NotifyMutex); |
638 |
bufferedCommands.erase(socket); |
bufferedCommands.erase(socket); |
639 |
bufferedNotifies.erase(socket); |
bufferedNotifies.erase(socket); |
640 |
#if defined(WIN32) |
#if defined(WIN32) |
642 |
#else |
#else |
643 |
close(socket); |
close(socket); |
644 |
#endif |
#endif |
|
NotifyMutex.Unlock(); |
|
645 |
} |
} |
646 |
|
|
647 |
void LSCPServer::CloseAllConnections() { |
void LSCPServer::CloseAllConnections() { |
652 |
} |
} |
653 |
} |
} |
654 |
|
|
|
void LSCPServer::LockRTNotify() { |
|
|
RTNotifyMutex.Lock(); |
|
|
} |
|
|
|
|
|
void LSCPServer::UnlockRTNotify() { |
|
|
RTNotifyMutex.Unlock(); |
|
|
} |
|
|
|
|
655 |
int LSCPServer::EventSubscribers( std::list<LSCPEvent::event_t> events ) { |
int LSCPServer::EventSubscribers( std::list<LSCPEvent::event_t> events ) { |
656 |
int subs = 0; |
int subs = 0; |
657 |
SubscriptionMutex.Lock(); |
LockGuard lock(SubscriptionMutex); |
658 |
for( std::list<LSCPEvent::event_t>::iterator iter = events.begin(); |
for( std::list<LSCPEvent::event_t>::iterator iter = events.begin(); |
659 |
iter != events.end(); iter++) |
iter != events.end(); iter++) |
660 |
{ |
{ |
661 |
subs += eventSubscriptions.count(*iter); |
subs += eventSubscriptions.count(*iter); |
662 |
} |
} |
|
SubscriptionMutex.Unlock(); |
|
663 |
return subs; |
return subs; |
664 |
} |
} |
665 |
|
|
666 |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
667 |
SubscriptionMutex.Lock(); |
LockGuard lock(SubscriptionMutex); |
668 |
if (eventSubscriptions.count(event.GetType()) == 0) { |
if (eventSubscriptions.count(event.GetType()) == 0) { |
669 |
SubscriptionMutex.Unlock(); //Nobody is subscribed to this event |
// Nobody is subscribed to this event |
670 |
return; |
return; |
671 |
} |
} |
672 |
std::list<int>::iterator iter = eventSubscriptions[event.GetType()].begin(); |
std::list<int>::iterator iter = eventSubscriptions[event.GetType()].begin(); |
692 |
} |
} |
693 |
} |
} |
694 |
} |
} |
|
SubscriptionMutex.Unlock(); |
|
695 |
} |
} |
696 |
|
|
697 |
extern int GetLSCPCommand( void *buf, int max_size ) { |
extern int GetLSCPCommand( void *buf, int max_size ) { |
742 |
bufferedCommands[socket] += "\r\n"; |
bufferedCommands[socket] += "\r\n"; |
743 |
return true; //Complete command was read |
return true; //Complete command was read |
744 |
} |
} |
745 |
bufferedCommands[socket] += c; |
// backspace character - should only happen with shell |
746 |
|
if (c == '\b') { |
747 |
|
if (!bufferedCommands[socket].empty()) { |
748 |
|
bufferedCommands[socket] = bufferedCommands[socket].substr( |
749 |
|
0, bufferedCommands[socket].length() - 1 |
750 |
|
); |
751 |
|
} |
752 |
|
} else bufferedCommands[socket] += c; |
753 |
|
// only if the other side is the LSCP shell application: |
754 |
|
// check the current (incomplete) command line for syntax errors, |
755 |
|
// possible completions and report everything back to the shell |
756 |
|
if ((*iter).bShellInteract || (*iter).bShellAutoCorrect) { |
757 |
|
String s = lscpParserProcessShellInteraction(bufferedCommands[socket], &(*iter)); |
758 |
|
if (!s.empty() && (*iter).bShellInteract) AnswerClient(s + "\n"); |
759 |
|
} |
760 |
} |
} |
761 |
#if defined(WIN32) |
#if defined(WIN32) |
762 |
if (result == SOCKET_ERROR) { |
if (result == SOCKET_ERROR) { |
818 |
* @param ReturnMessage - message that will be send to the client |
* @param ReturnMessage - message that will be send to the client |
819 |
*/ |
*/ |
820 |
void LSCPServer::AnswerClient(String ReturnMessage) { |
void LSCPServer::AnswerClient(String ReturnMessage) { |
821 |
dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str())); |
dmsg(2,("LSCPServer::AnswerClient(ReturnMessage='%s')", ReturnMessage.c_str())); |
822 |
if (currentSocket != -1) { |
if (currentSocket != -1) { |
823 |
NotifyMutex.Lock(); |
LockGuard lock(NotifyMutex); |
824 |
|
|
825 |
|
// just if other side is LSCP shell: in case respose is a multi-line |
826 |
|
// one, then inform client about it before sending the actual mult-line |
827 |
|
// response |
828 |
|
if (GetCurrentYaccSession()->bShellInteract) { |
829 |
|
// check if this is a multi-line response |
830 |
|
int n = 0; |
831 |
|
for (int i = 0; i < ReturnMessage.size(); ++i) |
832 |
|
if (ReturnMessage[i] == '\n') ++n; |
833 |
|
if (n >= 2) { |
834 |
|
dmsg(2,("LSCP Shell <- expect mult-line response\n")); |
835 |
|
String s = LSCP_SHK_EXPECT_MULTI_LINE "\r\n"; |
836 |
|
#ifdef MSG_NOSIGNAL |
837 |
|
send(currentSocket, s.c_str(), s.size(), MSG_NOSIGNAL); |
838 |
|
#else |
839 |
|
send(currentSocket, s.c_str(), s.size(), 0); |
840 |
|
#endif |
841 |
|
} |
842 |
|
} |
843 |
|
|
844 |
#ifdef MSG_NOSIGNAL |
#ifdef MSG_NOSIGNAL |
845 |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL); |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL); |
846 |
#else |
#else |
847 |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), 0); |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), 0); |
848 |
#endif |
#endif |
|
NotifyMutex.Unlock(); |
|
849 |
} |
} |
850 |
} |
} |
851 |
|
|
995 |
try { |
try { |
996 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
997 |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
998 |
LockRTNotify(); |
LockGuard lock(RTNotifyMutex); |
999 |
pSamplerChannel->SetEngineType(EngineName); |
pSamplerChannel->SetEngineType(EngineName); |
1000 |
if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1); |
if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1); |
|
UnlockRTNotify(); |
|
1001 |
} |
} |
1002 |
catch (Exception e) { |
catch (Exception e) { |
1003 |
result.Error(e); |
result.Error(e); |
1037 |
*/ |
*/ |
1038 |
String LSCPServer::AddChannel() { |
String LSCPServer::AddChannel() { |
1039 |
dmsg(2,("LSCPServer: AddChannel()\n")); |
dmsg(2,("LSCPServer: AddChannel()\n")); |
1040 |
LockRTNotify(); |
SamplerChannel* pSamplerChannel; |
1041 |
SamplerChannel* pSamplerChannel = pSampler->AddSamplerChannel(); |
{ |
1042 |
UnlockRTNotify(); |
LockGuard lock(RTNotifyMutex); |
1043 |
|
pSamplerChannel = pSampler->AddSamplerChannel(); |
1044 |
|
} |
1045 |
LSCPResultSet result(pSamplerChannel->Index()); |
LSCPResultSet result(pSamplerChannel->Index()); |
1046 |
return result.Produce(); |
return result.Produce(); |
1047 |
} |
} |
1052 |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
1053 |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
1054 |
LSCPResultSet result; |
LSCPResultSet result; |
1055 |
LockRTNotify(); |
{ |
1056 |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
LockGuard lock(RTNotifyMutex); |
1057 |
UnlockRTNotify(); |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
1058 |
|
} |
1059 |
return result.Produce(); |
return result.Produce(); |
1060 |
} |
} |
1061 |
|
|
1098 |
String LSCPServer::GetEngineInfo(String EngineName) { |
String LSCPServer::GetEngineInfo(String EngineName) { |
1099 |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
1100 |
LSCPResultSet result; |
LSCPResultSet result; |
1101 |
LockRTNotify(); |
{ |
1102 |
try { |
LockGuard lock(RTNotifyMutex); |
1103 |
Engine* pEngine = EngineFactory::Create(EngineName); |
try { |
1104 |
result.Add("DESCRIPTION", _escapeLscpResponse(pEngine->Description())); |
Engine* pEngine = EngineFactory::Create(EngineName); |
1105 |
result.Add("VERSION", pEngine->Version()); |
result.Add("DESCRIPTION", _escapeLscpResponse(pEngine->Description())); |
1106 |
EngineFactory::Destroy(pEngine); |
result.Add("VERSION", pEngine->Version()); |
1107 |
} |
EngineFactory::Destroy(pEngine); |
1108 |
catch (Exception e) { |
} |
1109 |
result.Error(e); |
catch (Exception e) { |
1110 |
|
result.Error(e); |
1111 |
|
} |
1112 |
} |
} |
|
UnlockRTNotify(); |
|
1113 |
return result.Produce(); |
return result.Produce(); |
1114 |
} |
} |
1115 |
|
|
1758 |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
1759 |
dmsg(2,("LSCPServer: SetAudiotOutputDevice(AudioDeviceId=%d, SamplerChannel=%d)\n",AudioDeviceId,uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetAudiotOutputDevice(AudioDeviceId=%d, SamplerChannel=%d)\n",AudioDeviceId,uiSamplerChannel)); |
1760 |
LSCPResultSet result; |
LSCPResultSet result; |
1761 |
LockRTNotify(); |
{ |
1762 |
|
LockGuard lock(RTNotifyMutex); |
1763 |
|
try { |
1764 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1765 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1766 |
|
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1767 |
|
if (!devices.count(AudioDeviceId)) throw Exception("There is no audio output device with index " + ToString(AudioDeviceId)); |
1768 |
|
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
1769 |
|
pSamplerChannel->SetAudioOutputDevice(pDevice); |
1770 |
|
} |
1771 |
|
catch (Exception e) { |
1772 |
|
result.Error(e); |
1773 |
|
} |
1774 |
|
} |
1775 |
|
return result.Produce(); |
1776 |
|
} |
1777 |
|
|
1778 |
|
String LSCPServer::SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel) { |
1779 |
|
dmsg(2,("LSCPServer: SetAudioOutputType(String AudioOutputDriver=%s, SamplerChannel=%d)\n",AudioOutputDriver.c_str(),uiSamplerChannel)); |
1780 |
|
LSCPResultSet result; |
1781 |
|
{ |
1782 |
|
LockGuard lock(RTNotifyMutex); |
1783 |
|
try { |
1784 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1785 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1786 |
|
// Driver type name aliasing... |
1787 |
|
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1788 |
|
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1789 |
|
// Check if there's one audio output device already created |
1790 |
|
// for the intended audio driver type (AudioOutputDriver)... |
1791 |
|
AudioOutputDevice *pDevice = NULL; |
1792 |
|
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1793 |
|
std::map<uint, AudioOutputDevice*>::iterator iter = devices.begin(); |
1794 |
|
for (; iter != devices.end(); iter++) { |
1795 |
|
if ((iter->second)->Driver() == AudioOutputDriver) { |
1796 |
|
pDevice = iter->second; |
1797 |
|
break; |
1798 |
|
} |
1799 |
|
} |
1800 |
|
// If it doesn't exist, create a new one with default parameters... |
1801 |
|
if (pDevice == NULL) { |
1802 |
|
std::map<String,String> params; |
1803 |
|
pDevice = pSampler->CreateAudioOutputDevice(AudioOutputDriver, params); |
1804 |
|
} |
1805 |
|
// Must have a device... |
1806 |
|
if (pDevice == NULL) |
1807 |
|
throw Exception("Internal error: could not create audio output device."); |
1808 |
|
// Set it as the current channel device... |
1809 |
|
pSamplerChannel->SetAudioOutputDevice(pDevice); |
1810 |
|
} |
1811 |
|
catch (Exception e) { |
1812 |
|
result.Error(e); |
1813 |
|
} |
1814 |
|
} |
1815 |
|
return result.Produce(); |
1816 |
|
} |
1817 |
|
|
1818 |
|
String LSCPServer::AddChannelMidiInput(uint uiSamplerChannel, uint MIDIDeviceId, uint MIDIPort) { |
1819 |
|
dmsg(2,("LSCPServer: AddChannelMidiInput(uiSamplerChannel=%d, MIDIDeviceId=%d, MIDIPort=%d)\n",uiSamplerChannel,MIDIDeviceId,MIDIPort)); |
1820 |
|
LSCPResultSet result; |
1821 |
try { |
try { |
1822 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1823 |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1824 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
|
1825 |
if (!devices.count(AudioDeviceId)) throw Exception("There is no audio output device with index " + ToString(AudioDeviceId)); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1826 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1827 |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1828 |
|
|
1829 |
|
MidiInputPort* pPort = pDevice->GetPort(MIDIPort); |
1830 |
|
if (!pPort) throw Exception("There is no MIDI input port with index " + ToString(MIDIPort) + " on MIDI input device with index " + ToString(MIDIDeviceId)); |
1831 |
|
|
1832 |
|
pSamplerChannel->Connect(pPort); |
1833 |
|
} catch (Exception e) { |
1834 |
|
result.Error(e); |
1835 |
} |
} |
1836 |
catch (Exception e) { |
return result.Produce(); |
1837 |
result.Error(e); |
} |
1838 |
|
|
1839 |
|
String LSCPServer::RemoveChannelMidiInput(uint uiSamplerChannel) { |
1840 |
|
dmsg(2,("LSCPServer: RemoveChannelMidiInput(uiSamplerChannel=%d)\n",uiSamplerChannel)); |
1841 |
|
LSCPResultSet result; |
1842 |
|
try { |
1843 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1844 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1845 |
|
pSamplerChannel->DisconnectAllMidiInputPorts(); |
1846 |
|
} catch (Exception e) { |
1847 |
|
result.Error(e); |
1848 |
} |
} |
|
UnlockRTNotify(); |
|
1849 |
return result.Produce(); |
return result.Produce(); |
1850 |
} |
} |
1851 |
|
|
1852 |
String LSCPServer::SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel) { |
String LSCPServer::RemoveChannelMidiInput(uint uiSamplerChannel, uint MIDIDeviceId) { |
1853 |
dmsg(2,("LSCPServer: SetAudioOutputType(String AudioOutputDriver=%s, SamplerChannel=%d)\n",AudioOutputDriver.c_str(),uiSamplerChannel)); |
dmsg(2,("LSCPServer: RemoveChannelMidiInput(uiSamplerChannel=%d, MIDIDeviceId=%d)\n",uiSamplerChannel,MIDIDeviceId)); |
1854 |
LSCPResultSet result; |
LSCPResultSet result; |
|
LockRTNotify(); |
|
1855 |
try { |
try { |
1856 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1857 |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1858 |
// Driver type name aliasing... |
|
1859 |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1860 |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1861 |
// Check if there's one audio output device already created |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1862 |
// for the intended audio driver type (AudioOutputDriver)... |
|
1863 |
AudioOutputDevice *pDevice = NULL; |
std::vector<MidiInputPort*> vPorts = pSamplerChannel->GetMidiInputPorts(); |
1864 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
for (int i = 0; i < vPorts.size(); ++i) |
1865 |
std::map<uint, AudioOutputDevice*>::iterator iter = devices.begin(); |
if (vPorts[i]->GetDevice() == pDevice) |
1866 |
for (; iter != devices.end(); iter++) { |
pSamplerChannel->Disconnect(vPorts[i]); |
1867 |
if ((iter->second)->Driver() == AudioOutputDriver) { |
|
1868 |
pDevice = iter->second; |
} catch (Exception e) { |
1869 |
break; |
result.Error(e); |
|
} |
|
|
} |
|
|
// If it doesn't exist, create a new one with default parameters... |
|
|
if (pDevice == NULL) { |
|
|
std::map<String,String> params; |
|
|
pDevice = pSampler->CreateAudioOutputDevice(AudioOutputDriver, params); |
|
|
} |
|
|
// Must have a device... |
|
|
if (pDevice == NULL) |
|
|
throw Exception("Internal error: could not create audio output device."); |
|
|
// Set it as the current channel device... |
|
|
pSamplerChannel->SetAudioOutputDevice(pDevice); |
|
1870 |
} |
} |
1871 |
catch (Exception e) { |
return result.Produce(); |
1872 |
result.Error(e); |
} |
1873 |
|
|
1874 |
|
String LSCPServer::RemoveChannelMidiInput(uint uiSamplerChannel, uint MIDIDeviceId, uint MIDIPort) { |
1875 |
|
dmsg(2,("LSCPServer: RemoveChannelMidiInput(uiSamplerChannel=%d, MIDIDeviceId=%d, MIDIPort=%d)\n",uiSamplerChannel,MIDIDeviceId,MIDIPort)); |
1876 |
|
LSCPResultSet result; |
1877 |
|
try { |
1878 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1879 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1880 |
|
|
1881 |
|
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1882 |
|
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1883 |
|
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1884 |
|
|
1885 |
|
MidiInputPort* pPort = pDevice->GetPort(MIDIPort); |
1886 |
|
if (!pPort) throw Exception("There is no MIDI input port with index " + ToString(MIDIPort) + " on MIDI input device with index " + ToString(MIDIDeviceId)); |
1887 |
|
|
1888 |
|
pSamplerChannel->Disconnect(pPort); |
1889 |
|
} catch (Exception e) { |
1890 |
|
result.Error(e); |
1891 |
|
} |
1892 |
|
return result.Produce(); |
1893 |
|
} |
1894 |
|
|
1895 |
|
String LSCPServer::ListChannelMidiInputs(uint uiSamplerChannel) { |
1896 |
|
dmsg(2,("LSCPServer: ListChannelMidiInputs(uiSamplerChannel=%d)\n",uiSamplerChannel)); |
1897 |
|
LSCPResultSet result; |
1898 |
|
try { |
1899 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1900 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1901 |
|
std::vector<MidiInputPort*> vPorts = pSamplerChannel->GetMidiInputPorts(); |
1902 |
|
|
1903 |
|
String s; |
1904 |
|
for (int i = 0; i < vPorts.size(); ++i) { |
1905 |
|
const int iDeviceID = vPorts[i]->GetDevice()->MidiInputDeviceID(); |
1906 |
|
const int iPortNr = vPorts[i]->GetPortNumber(); |
1907 |
|
if (s.size()) s += ","; |
1908 |
|
s += "{" + ToString(iDeviceID) + "," |
1909 |
|
+ ToString(iPortNr) + "}"; |
1910 |
|
} |
1911 |
|
result.Add(s); |
1912 |
|
} catch (Exception e) { |
1913 |
|
result.Error(e); |
1914 |
} |
} |
|
UnlockRTNotify(); |
|
1915 |
return result.Produce(); |
return result.Produce(); |
1916 |
} |
} |
1917 |
|
|
2531 |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
2532 |
result.Add("LEVEL", ToString(pFxSend->Level())); |
result.Add("LEVEL", ToString(pFxSend->Level())); |
2533 |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
2534 |
result.Add("SEND_EFFECT", sEffectRouting); |
result.Add("EFFECT", sEffectRouting); |
2535 |
} catch (Exception e) { |
} catch (Exception e) { |
2536 |
result.Error(e); |
result.Error(e); |
2537 |
} |
} |
2748 |
); |
); |
2749 |
|
|
2750 |
pEffectControl->SetValue(dValue); |
pEffectControl->SetValue(dValue); |
2751 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_info, iEffectInstance)); |
2752 |
} catch (Exception e) { |
} catch (Exception e) { |
2753 |
result.Error(e); |
result.Error(e); |
2754 |
} |
} |
2764 |
throw Exception("There is no effect with index " + ToString(iEffectIndex)); |
throw Exception("There is no effect with index " + ToString(iEffectIndex)); |
2765 |
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2766 |
result = pEffect->ID(); // success |
result = pEffect->ID(); // success |
2767 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount())); |
2768 |
} catch (Exception e) { |
} catch (Exception e) { |
2769 |
result.Error(e); |
result.Error(e); |
2770 |
} |
} |
2811 |
|
|
2812 |
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2813 |
result = LSCPResultSet(pEffect->ID()); |
result = LSCPResultSet(pEffect->ID()); |
2814 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount())); |
2815 |
} catch (Exception e) { |
} catch (Exception e) { |
2816 |
result.Error(e); |
result.Error(e); |
2817 |
} |
} |
2826 |
if (!pEffect) |
if (!pEffect) |
2827 |
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2828 |
EffectFactory::Destroy(pEffect); |
EffectFactory::Destroy(pEffect); |
2829 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount())); |
2830 |
} catch (Exception e) { |
} catch (Exception e) { |
2831 |
result.Error(e); |
result.Error(e); |
2832 |
} |
} |
2911 |
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2912 |
EffectChain* pEffectChain = pDevice->AddSendEffectChain(); |
EffectChain* pEffectChain = pDevice->AddSendEffectChain(); |
2913 |
result = pEffectChain->ID(); |
result = pEffectChain->ID(); |
2914 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_count, iAudioOutputDevice, pDevice->SendEffectChainCount())); |
2915 |
} catch (Exception e) { |
} catch (Exception e) { |
2916 |
result.Error(e); |
result.Error(e); |
2917 |
} |
} |
2925 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2926 |
if (!devices.count(iAudioOutputDevice)) |
if (!devices.count(iAudioOutputDevice)) |
2927 |
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2928 |
|
|
2929 |
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
2930 |
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
2931 |
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
2932 |
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
2933 |
|
AudioOutputDevice* pDev = (*itEngineChannel)->GetAudioOutputDevice(); |
2934 |
|
if (pDev != NULL && pDev->deviceId() == iAudioOutputDevice) { |
2935 |
|
for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) { |
2936 |
|
FxSend* fxs = (*itEngineChannel)->GetFxSend(i); |
2937 |
|
if(fxs != NULL && fxs->DestinationEffectChain() == iSendEffectChain) { |
2938 |
|
throw Exception("The effect chain is still in use by channel " + ToString((*itEngineChannel)->GetSamplerChannel()->Index())); |
2939 |
|
} |
2940 |
|
} |
2941 |
|
} |
2942 |
|
} |
2943 |
|
|
2944 |
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2945 |
for (int i = 0; i < pDevice->SendEffectChainCount(); i++) { |
for (int i = 0; i < pDevice->SendEffectChainCount(); i++) { |
2946 |
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
2947 |
if (pEffectChain->ID() == iSendEffectChain) { |
if (pEffectChain->ID() == iSendEffectChain) { |
2948 |
pDevice->RemoveSendEffectChain(i); |
pDevice->RemoveSendEffectChain(i); |
2949 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_count, iAudioOutputDevice, pDevice->SendEffectChainCount())); |
2950 |
return result.Produce(); |
return result.Produce(); |
2951 |
} |
} |
2952 |
} |
} |
2969 |
ToString(iAudioOutputDevice) + "." |
ToString(iAudioOutputDevice) + "." |
2970 |
); |
); |
2971 |
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2972 |
for (int i = 0; i < pDevice->SendEffectChainCount(); i++) { |
EffectChain* pEffectChain = pDevice->SendEffectChainByID(iSendEffectChain); |
2973 |
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
if(pEffectChain != NULL) return pEffectChain; |
|
if (pEffectChain->ID() == iSendEffectChain) { |
|
|
return pEffectChain; |
|
|
} |
|
|
} |
|
2974 |
throw Exception( |
throw Exception( |
2975 |
"There is no send effect chain with ID " + |
"There is no send effect chain with ID " + |
2976 |
ToString(iSendEffectChain) + " for audio output device " + |
ToString(iSendEffectChain) + " for audio output device " + |
3007 |
if (!pEffect) |
if (!pEffect) |
3008 |
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
3009 |
pEffectChain->AppendEffect(pEffect); |
pEffectChain->AppendEffect(pEffect); |
3010 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount())); |
3011 |
} catch (Exception e) { |
} catch (Exception e) { |
3012 |
result.Error(e); |
result.Error(e); |
3013 |
} |
} |
3024 |
if (!pEffect) |
if (!pEffect) |
3025 |
throw Exception("There is no effect instance with index " + ToString(iEffectInstance)); |
throw Exception("There is no effect instance with index " + ToString(iEffectInstance)); |
3026 |
pEffectChain->InsertEffect(pEffect, iEffectChainPosition); |
pEffectChain->InsertEffect(pEffect, iEffectChainPosition); |
3027 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount())); |
3028 |
} catch (Exception e) { |
} catch (Exception e) { |
3029 |
result.Error(e); |
result.Error(e); |
3030 |
} |
} |
3037 |
try { |
try { |
3038 |
EffectChain* pEffectChain = |
EffectChain* pEffectChain = |
3039 |
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
3040 |
|
|
3041 |
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
3042 |
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
3043 |
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
3044 |
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
3045 |
|
AudioOutputDevice* pDev = (*itEngineChannel)->GetAudioOutputDevice(); |
3046 |
|
if (pDev != NULL && pDev->deviceId() == iAudioOutputDevice) { |
3047 |
|
for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) { |
3048 |
|
FxSend* fxs = (*itEngineChannel)->GetFxSend(i); |
3049 |
|
if(fxs != NULL && fxs->DestinationEffectChain() == iSendEffectChain && fxs->DestinationEffectChainPosition() == iEffectChainPosition) { |
3050 |
|
throw Exception("The effect instance is still in use by channel " + ToString((*itEngineChannel)->GetSamplerChannel()->Index())); |
3051 |
|
} |
3052 |
|
} |
3053 |
|
} |
3054 |
|
} |
3055 |
|
|
3056 |
pEffectChain->RemoveEffect(iEffectChainPosition); |
pEffectChain->RemoveEffect(iEffectChainPosition); |
3057 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount())); |
3058 |
} catch (Exception e) { |
} catch (Exception e) { |
3059 |
result.Error(e); |
result.Error(e); |
3060 |
} |
} |
3195 |
String LSCPServer::GetTotalVoiceCountMax() { |
String LSCPServer::GetTotalVoiceCountMax() { |
3196 |
dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n")); |
dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n")); |
3197 |
LSCPResultSet result; |
LSCPResultSet result; |
3198 |
result.Add(EngineFactory::EngineInstances().size() * GLOBAL_MAX_VOICES); |
result.Add(EngineFactory::EngineInstances().size() * pSampler->GetGlobalMaxVoices()); |
3199 |
return result.Produce(); |
return result.Produce(); |
3200 |
} |
} |
3201 |
|
|
3206 |
String LSCPServer::GetGlobalMaxVoices() { |
String LSCPServer::GetGlobalMaxVoices() { |
3207 |
dmsg(2,("LSCPServer: GetGlobalMaxVoices()\n")); |
dmsg(2,("LSCPServer: GetGlobalMaxVoices()\n")); |
3208 |
LSCPResultSet result; |
LSCPResultSet result; |
3209 |
result.Add(GLOBAL_MAX_VOICES); |
result.Add(pSampler->GetGlobalMaxVoices()); |
3210 |
return result.Produce(); |
return result.Produce(); |
3211 |
} |
} |
3212 |
|
|
3218 |
dmsg(2,("LSCPServer: SetGlobalMaxVoices(%d)\n", iVoices)); |
dmsg(2,("LSCPServer: SetGlobalMaxVoices(%d)\n", iVoices)); |
3219 |
LSCPResultSet result; |
LSCPResultSet result; |
3220 |
try { |
try { |
3221 |
if (iVoices < 1) throw Exception("Maximum voices may not be less than 1"); |
pSampler->SetGlobalMaxVoices(iVoices); |
3222 |
GLOBAL_MAX_VOICES = iVoices; // see common/global_private.cpp |
LSCPServer::SendLSCPNotify( |
3223 |
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
LSCPEvent(LSCPEvent::event_global_info, "VOICES", pSampler->GetGlobalMaxVoices()) |
3224 |
if (engines.size() > 0) { |
); |
|
std::set<Engine*>::iterator iter = engines.begin(); |
|
|
std::set<Engine*>::iterator end = engines.end(); |
|
|
for (; iter != end; ++iter) { |
|
|
(*iter)->SetMaxVoices(iVoices); |
|
|
} |
|
|
} |
|
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "VOICES", GLOBAL_MAX_VOICES)); |
|
3225 |
} catch (Exception e) { |
} catch (Exception e) { |
3226 |
result.Error(e); |
result.Error(e); |
3227 |
} |
} |
3235 |
String LSCPServer::GetGlobalMaxStreams() { |
String LSCPServer::GetGlobalMaxStreams() { |
3236 |
dmsg(2,("LSCPServer: GetGlobalMaxStreams()\n")); |
dmsg(2,("LSCPServer: GetGlobalMaxStreams()\n")); |
3237 |
LSCPResultSet result; |
LSCPResultSet result; |
3238 |
result.Add(GLOBAL_MAX_STREAMS); |
result.Add(pSampler->GetGlobalMaxStreams()); |
3239 |
return result.Produce(); |
return result.Produce(); |
3240 |
} |
} |
3241 |
|
|
3247 |
dmsg(2,("LSCPServer: SetGlobalMaxStreams(%d)\n", iStreams)); |
dmsg(2,("LSCPServer: SetGlobalMaxStreams(%d)\n", iStreams)); |
3248 |
LSCPResultSet result; |
LSCPResultSet result; |
3249 |
try { |
try { |
3250 |
if (iStreams < 0) throw Exception("Maximum disk streams may not be negative"); |
pSampler->SetGlobalMaxStreams(iStreams); |
3251 |
GLOBAL_MAX_STREAMS = iStreams; // see common/global_private.cpp |
LSCPServer::SendLSCPNotify( |
3252 |
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
LSCPEvent(LSCPEvent::event_global_info, "STREAMS", pSampler->GetGlobalMaxStreams()) |
3253 |
if (engines.size() > 0) { |
); |
|
std::set<Engine*>::iterator iter = engines.begin(); |
|
|
std::set<Engine*>::iterator end = engines.end(); |
|
|
for (; iter != end; ++iter) { |
|
|
(*iter)->SetMaxDiskStreams(iStreams); |
|
|
} |
|
|
} |
|
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "STREAMS", GLOBAL_MAX_STREAMS)); |
|
3254 |
} catch (Exception e) { |
} catch (Exception e) { |
3255 |
result.Error(e); |
result.Error(e); |
3256 |
} |
} |
3454 |
String LSCPServer::SubscribeNotification(LSCPEvent::event_t type) { |
String LSCPServer::SubscribeNotification(LSCPEvent::event_t type) { |
3455 |
dmsg(2,("LSCPServer: SubscribeNotification(Event=%s)\n", LSCPEvent::Name(type).c_str())); |
dmsg(2,("LSCPServer: SubscribeNotification(Event=%s)\n", LSCPEvent::Name(type).c_str())); |
3456 |
LSCPResultSet result; |
LSCPResultSet result; |
3457 |
SubscriptionMutex.Lock(); |
{ |
3458 |
eventSubscriptions[type].push_back(currentSocket); |
LockGuard lock(SubscriptionMutex); |
3459 |
SubscriptionMutex.Unlock(); |
eventSubscriptions[type].push_back(currentSocket); |
3460 |
|
} |
3461 |
return result.Produce(); |
return result.Produce(); |
3462 |
} |
} |
3463 |
|
|
3468 |
String LSCPServer::UnsubscribeNotification(LSCPEvent::event_t type) { |
String LSCPServer::UnsubscribeNotification(LSCPEvent::event_t type) { |
3469 |
dmsg(2,("LSCPServer: UnsubscribeNotification(Event=%s)\n", LSCPEvent::Name(type).c_str())); |
dmsg(2,("LSCPServer: UnsubscribeNotification(Event=%s)\n", LSCPEvent::Name(type).c_str())); |
3470 |
LSCPResultSet result; |
LSCPResultSet result; |
3471 |
SubscriptionMutex.Lock(); |
{ |
3472 |
eventSubscriptions[type].remove(currentSocket); |
LockGuard lock(SubscriptionMutex); |
3473 |
SubscriptionMutex.Unlock(); |
eventSubscriptions[type].remove(currentSocket); |
3474 |
|
} |
3475 |
return result.Produce(); |
return result.Produce(); |
3476 |
} |
} |
3477 |
|
|
3996 |
} |
} |
3997 |
return result.Produce(); |
return result.Produce(); |
3998 |
} |
} |
3999 |
|
|
4000 |
|
String LSCPServer::SetShellInteract(yyparse_param_t* pSession, double boolean_value) { |
4001 |
|
dmsg(2,("LSCPServer: SetShellInteract(val=%f)\n", boolean_value)); |
4002 |
|
LSCPResultSet result; |
4003 |
|
try { |
4004 |
|
if (boolean_value == 0) pSession->bShellInteract = false; |
4005 |
|
else if (boolean_value == 1) pSession->bShellInteract = true; |
4006 |
|
else throw Exception("Not a boolean value, must either be 0 or 1"); |
4007 |
|
} catch (Exception e) { |
4008 |
|
result.Error(e); |
4009 |
|
} |
4010 |
|
return result.Produce(); |
4011 |
|
} |
4012 |
|
|
4013 |
|
String LSCPServer::SetShellAutoCorrect(yyparse_param_t* pSession, double boolean_value) { |
4014 |
|
dmsg(2,("LSCPServer: SetShellAutoCorrect(val=%f)\n", boolean_value)); |
4015 |
|
LSCPResultSet result; |
4016 |
|
try { |
4017 |
|
if (boolean_value == 0) pSession->bShellAutoCorrect = false; |
4018 |
|
else if (boolean_value == 1) pSession->bShellAutoCorrect = true; |
4019 |
|
else throw Exception("Not a boolean value, must either be 0 or 1"); |
4020 |
|
} catch (Exception e) { |
4021 |
|
result.Error(e); |
4022 |
|
} |
4023 |
|
return result.Produce(); |
4024 |
|
} |
4025 |
|
|
4026 |
} |
} |