88 |
SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); |
SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); |
89 |
|
|
90 |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
91 |
std::cerr << "LSCPServer: Could not bind server socket." << std::endl; |
std::cerr << "LSCPServer: Could not bind server socket, retrying for " << ToString(LSCP_SERVER_BIND_TIMEOUT) << " seconds..."; |
92 |
close(hSocket); |
for (int trial = 0; true; trial++) { // retry for LSCP_SERVER_BIND_TIMEOUT seconds |
93 |
//return -1; |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
94 |
exit(EXIT_FAILURE); |
if (trial > LSCP_SERVER_BIND_TIMEOUT) { |
95 |
|
std::cerr << "gave up!" << std::endl; |
96 |
|
close(hSocket); |
97 |
|
//return -1; |
98 |
|
exit(EXIT_FAILURE); |
99 |
|
} |
100 |
|
else sleep(1); // sleep 1s |
101 |
|
} |
102 |
|
else break; // success |
103 |
|
} |
104 |
} |
} |
105 |
|
|
106 |
listen(hSocket, 1); |
listen(hSocket, 1); |
591 |
|
|
592 |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
593 |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
594 |
if (pSamplerChannel->GetMidiInputChannel()) result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
if (pSamplerChannel->GetMidiInputChannel() == MidiInputPort::midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
595 |
else result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
596 |
|
|
597 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
598 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
752 |
} |
} |
753 |
|
|
754 |
String LSCPServer::GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
String LSCPServer::GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
755 |
dmsg(2,("LSCPServer: GetMidiInputDriverParameterInfo(Driver=%s,Parameter=%s)\n",Driver.c_str(),Parameter.c_str())); |
dmsg(2,("LSCPServer: GetMidiInputDriverParameterInfo(Driver=%s,Parameter=%s,DependencyListSize=%d)\n",Driver.c_str(),Parameter.c_str(),DependencyList.size())); |
756 |
LSCPResultSet result; |
LSCPResultSet result; |
757 |
try { |
try { |
758 |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
761 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", pParameter->Mandatory()); |
762 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
763 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
764 |
if (pParameter->Depends()) result.Add("DEPENDS", *pParameter->Depends()); |
optional<String> oDepends = pParameter->Depends(); |
765 |
if (pParameter->Default()) result.Add("DEFAULT", *pParameter->Default()); |
optional<String> oDefault = pParameter->Default(DependencyList); |
766 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
optional<String> oRangeMin = pParameter->RangeMin(DependencyList); |
767 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
optional<String> oRangeMax = pParameter->RangeMax(DependencyList); |
768 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
optional<String> oPossibilities = pParameter->Possibilities(DependencyList); |
769 |
|
if (oDepends) result.Add("DEPENDS", *oDepends); |
770 |
|
if (oDefault) result.Add("DEFAULT", *oDefault); |
771 |
|
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
772 |
|
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
773 |
|
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
774 |
} |
} |
775 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
776 |
result.Error(e); |
result.Error(e); |
779 |
} |
} |
780 |
|
|
781 |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
782 |
dmsg(2,("LSCPServer: GetAudioOutputDriverParameterInfo(Driver=%s,Parameter=%s)\n",Driver.c_str(),Parameter.c_str())); |
dmsg(2,("LSCPServer: GetAudioOutputDriverParameterInfo(Driver=%s,Parameter=%s,DependencyListSize=%d)\n",Driver.c_str(),Parameter.c_str(),DependencyList.size())); |
783 |
LSCPResultSet result; |
LSCPResultSet result; |
784 |
try { |
try { |
785 |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
788 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", pParameter->Mandatory()); |
789 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
790 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
791 |
if (pParameter->Depends()) result.Add("DEPENDS", *pParameter->Depends()); |
optional<String> oDepends = pParameter->Depends(); |
792 |
if (pParameter->Default()) result.Add("DEFAULT", *pParameter->Default()); |
optional<String> oDefault = pParameter->Default(DependencyList); |
793 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
optional<String> oRangeMin = pParameter->RangeMin(DependencyList); |
794 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
optional<String> oRangeMax = pParameter->RangeMax(DependencyList); |
795 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
optional<String> oPossibilities = pParameter->Possibilities(DependencyList); |
796 |
|
if (oDepends) result.Add("DEPENDS", *oDepends); |
797 |
|
if (oDefault) result.Add("DEFAULT", *oDefault); |
798 |
|
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
799 |
|
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
800 |
|
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
801 |
} |
} |
802 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
803 |
result.Error(e); |
result.Error(e); |
1123 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1124 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1125 |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
1126 |
|
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1127 |
|
if (!devices.count(ChannelAudioOutputChannel)) throw LinuxSamplerException("There is no audio output device with index " + ToString(ChannelAudioOutputChannel)); |
1128 |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1129 |
} |
} |
1130 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1157 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1158 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1159 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1160 |
if (AudioOutputDriver == "ALSA") AudioOutputDriver = "Alsa"; |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1161 |
if (AudioOutputDriver == "JACK") AudioOutputDriver = "Jack"; |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1162 |
// Check if there's one audio output device already created |
// Check if there's one audio output device already created |
1163 |
// for the intended audio driver type (AudioOutputDriver)... |
// for the intended audio driver type (AudioOutputDriver)... |
1164 |
AudioOutputDevice *pDevice = NULL; |
AudioOutputDevice *pDevice = NULL; |
1239 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1240 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1241 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1242 |
if (MidiInputDriver == "ALSA") MidiInputDriver = "Alsa"; |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
1243 |
// Check if there's one MIDI input device already created |
// Check if there's one MIDI input device already created |
1244 |
// for the intended MIDI driver type (MidiInputDriver)... |
// for the intended MIDI driver type (MidiInputDriver)... |
1245 |
MidiInputDevice *pDevice = NULL; |
MidiInputDevice *pDevice = NULL; |