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 - 2015 Christian Schoenebeck * |
* Copyright (C) 2005 - 2016 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 * |
31 |
|
|
32 |
#if defined(WIN32) |
#if defined(WIN32) |
33 |
#include <windows.h> |
#include <windows.h> |
34 |
|
typedef unsigned short in_port_t; |
35 |
|
typedef unsigned long in_addr_t; |
36 |
#else |
#else |
37 |
#include <fcntl.h> |
#include <fcntl.h> |
38 |
#endif |
#endif |
113 |
|
|
114 |
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) { |
115 |
SocketAddress.sin_family = AF_INET; |
SocketAddress.sin_family = AF_INET; |
116 |
SocketAddress.sin_addr.s_addr = addr; |
SocketAddress.sin_addr.s_addr = (in_addr_t)addr; |
117 |
SocketAddress.sin_port = port; |
SocketAddress.sin_port = (in_port_t)port; |
118 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
119 |
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_count, "AUDIO_OUTPUT_DEVICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_count, "AUDIO_OUTPUT_DEVICE_COUNT"); |
120 |
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_info, "AUDIO_OUTPUT_DEVICE_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_info, "AUDIO_OUTPUT_DEVICE_INFO"); |
710 |
|
|
711 |
strcpy((char*) buf, command.c_str()); |
strcpy((char*) buf, command.c_str()); |
712 |
LSCPServer::bufferedCommands.erase(LSCPServer::currentSocket); |
LSCPServer::bufferedCommands.erase(LSCPServer::currentSocket); |
713 |
return command.size(); |
return (int) command.size(); |
714 |
} |
} |
715 |
|
|
716 |
extern yyparse_param_t* GetCurrentYaccSession() { |
extern yyparse_param_t* GetCurrentYaccSession() { |
764 |
// first get as many character as possible and add it to the 'input' buffer |
// first get as many character as possible and add it to the 'input' buffer |
765 |
while (true) { |
while (true) { |
766 |
#if defined(WIN32) |
#if defined(WIN32) |
767 |
result = recv(socket, (char *)&c, 1, 0); //Read one character at a time for now |
result = (int)recv(socket, (char*)&c, 1, 0); //Read one character at a time for now |
768 |
#else |
#else |
769 |
result = recv(socket, (void *)&c, 1, 0); //Read one character at a time for now |
result = (int)recv(socket, (void*)&c, 1, 0); //Read one character at a time for now |
770 |
#endif |
#endif |
771 |
if (result == 1) input.push_back(c); |
if (result == 1) input.push_back(c); |
772 |
else break; // end of input or some error |
else break; // end of input or some error |
800 |
} else if (c == 3) { // custom ASCII code usage for moving cursor right (LSCP shell) |
} else if (c == 3) { // custom ASCII code usage for moving cursor right (LSCP shell) |
801 |
if (iter->iCursorOffset < 0) iter->iCursorOffset++; |
if (iter->iCursorOffset < 0) iter->iCursorOffset++; |
802 |
} else { |
} else { |
803 |
size_t cursorPos = bufferedCommands[socket].size() + iter->iCursorOffset; |
ssize_t cursorPos = bufferedCommands[socket].size() + iter->iCursorOffset; |
804 |
// backspace character - should only happen with shell |
// backspace character - should only happen with shell |
805 |
if (c == '\b') { |
if (c == '\b') { |
806 |
if (!bufferedCommands[socket].empty() && cursorPos > 0) |
if (!bufferedCommands[socket].empty() && cursorPos > 0) |
1148 |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
1149 |
LSCPResultSet result; |
LSCPResultSet result; |
1150 |
try { |
try { |
1151 |
int n = EngineFactory::AvailableEngineTypes().size(); |
int n = (int)EngineFactory::AvailableEngineTypes().size(); |
1152 |
result.Add(n); |
result.Add(n); |
1153 |
} |
} |
1154 |
catch (Exception e) { |
catch (Exception e) { |
1352 |
dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n")); |
dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n")); |
1353 |
LSCPResultSet result; |
LSCPResultSet result; |
1354 |
try { |
try { |
1355 |
int n = AudioOutputDeviceFactory::AvailableDrivers().size(); |
int n = (int) AudioOutputDeviceFactory::AvailableDrivers().size(); |
1356 |
result.Add(n); |
result.Add(n); |
1357 |
} |
} |
1358 |
catch (Exception e) { |
catch (Exception e) { |
1378 |
dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n")); |
dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n")); |
1379 |
LSCPResultSet result; |
LSCPResultSet result; |
1380 |
try { |
try { |
1381 |
int n = MidiInputDeviceFactory::AvailableDrivers().size(); |
int n = (int)MidiInputDeviceFactory::AvailableDrivers().size(); |
1382 |
result.Add(n); |
result.Add(n); |
1383 |
} |
} |
1384 |
catch (Exception e) { |
catch (Exception e) { |
2436 |
dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n")); |
dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n")); |
2437 |
LSCPResultSet result; |
LSCPResultSet result; |
2438 |
try { |
try { |
2439 |
result.Add(MidiInstrumentMapper::Maps().size()); |
result.Add(int(MidiInstrumentMapper::Maps().size())); |
2440 |
} catch (Exception e) { |
} catch (Exception e) { |
2441 |
result.Error(e); |
result.Error(e); |
2442 |
} |
} |
3277 |
String LSCPServer::GetTotalVoiceCountMax() { |
String LSCPServer::GetTotalVoiceCountMax() { |
3278 |
dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n")); |
dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n")); |
3279 |
LSCPResultSet result; |
LSCPResultSet result; |
3280 |
result.Add(EngineFactory::EngineInstances().size() * pSampler->GetGlobalMaxVoices()); |
result.Add(int(EngineFactory::EngineInstances().size() * pSampler->GetGlobalMaxVoices())); |
3281 |
return result.Produce(); |
return result.Produce(); |
3282 |
} |
} |
3283 |
|
|
3379 |
std::vector<InstrumentManager::instrument_id_t> IDs = |
std::vector<InstrumentManager::instrument_id_t> IDs = |
3380 |
pManager->GetInstrumentFileContent(Filename); |
pManager->GetInstrumentFileContent(Filename); |
3381 |
// return the amount of instruments in the file |
// return the amount of instruments in the file |
3382 |
result.Add(IDs.size()); |
result.Add((int)IDs.size()); |
3383 |
// no more need to ask other engine types |
// no more need to ask other engine types |
3384 |
bFound = true; |
bFound = true; |
3385 |
} else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str())); |
} else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str())); |