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 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2012 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 * |
24 |
#include <algorithm> |
#include <algorithm> |
25 |
#include <string> |
#include <string> |
26 |
|
|
27 |
|
#include "../common/File.h" |
28 |
#include "lscpserver.h" |
#include "lscpserver.h" |
29 |
#include "lscpresultset.h" |
#include "lscpresultset.h" |
30 |
#include "lscpevent.h" |
#include "lscpevent.h" |
43 |
#include "../engines/EngineChannelFactory.h" |
#include "../engines/EngineChannelFactory.h" |
44 |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
45 |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
46 |
|
#include "../effects/EffectFactory.h" |
47 |
|
|
48 |
namespace LinuxSampler { |
namespace LinuxSampler { |
49 |
|
|
138 |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
139 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_midi, "CHANNEL_MIDI"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_midi, "CHANNEL_MIDI"); |
140 |
LSCPEvent::RegisterEvent(LSCPEvent::event_device_midi, "DEVICE_MIDI"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_device_midi, "DEVICE_MIDI"); |
141 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_fx_instance_count, "EFFECT_INSTANCE_COUNT"); |
142 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_fx_instance_info, "EFFECT_INSTANCE_INFO"); |
143 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_send_fx_chain_count, "SEND_EFFECT_CHAIN_COUNT"); |
144 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_send_fx_chain_info, "SEND_EFFECT_CHAIN_INFO"); |
145 |
hSocket = -1; |
hSocket = -1; |
146 |
} |
} |
147 |
|
|
148 |
LSCPServer::~LSCPServer() { |
LSCPServer::~LSCPServer() { |
149 |
|
CloseAllConnections(); |
150 |
|
InstrumentManager::StopBackgroundThread(); |
151 |
#if defined(WIN32) |
#if defined(WIN32) |
152 |
if (hSocket >= 0) closesocket(hSocket); |
if (hSocket >= 0) closesocket(hSocket); |
153 |
#else |
#else |
342 |
} |
} |
343 |
#endif // HAVE_SQLITE3 |
#endif // HAVE_SQLITE3 |
344 |
|
|
345 |
|
void LSCPServer::RemoveListeners() { |
346 |
|
pSampler->RemoveChannelCountListener(&eventHandler); |
347 |
|
pSampler->RemoveAudioDeviceCountListener(&eventHandler); |
348 |
|
pSampler->RemoveMidiDeviceCountListener(&eventHandler); |
349 |
|
pSampler->RemoveVoiceCountListener(&eventHandler); |
350 |
|
pSampler->RemoveStreamCountListener(&eventHandler); |
351 |
|
pSampler->RemoveBufferFillListener(&eventHandler); |
352 |
|
pSampler->RemoveTotalStreamCountListener(&eventHandler); |
353 |
|
pSampler->RemoveTotalVoiceCountListener(&eventHandler); |
354 |
|
pSampler->RemoveFxSendCountListener(&eventHandler); |
355 |
|
MidiInstrumentMapper::RemoveMidiInstrumentCountListener(&eventHandler); |
356 |
|
MidiInstrumentMapper::RemoveMidiInstrumentInfoListener(&eventHandler); |
357 |
|
MidiInstrumentMapper::RemoveMidiInstrumentMapCountListener(&eventHandler); |
358 |
|
MidiInstrumentMapper::RemoveMidiInstrumentMapInfoListener(&eventHandler); |
359 |
|
#if HAVE_SQLITE3 |
360 |
|
InstrumentsDb::GetInstrumentsDb()->RemoveInstrumentsDbListener(&dbInstrumentsEventHandler); |
361 |
|
#endif |
362 |
|
} |
363 |
|
|
364 |
/** |
/** |
365 |
* Blocks the calling thread until the LSCP Server is initialized and |
* Blocks the calling thread until the LSCP Server is initialized and |
447 |
#endif |
#endif |
448 |
// 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 |
449 |
{ |
{ |
450 |
|
EngineChannelFactory::EngineChannelsMutex.Lock(); |
451 |
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
452 |
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
453 |
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
465 |
} |
} |
466 |
} |
} |
467 |
} |
} |
468 |
|
EngineChannelFactory::EngineChannelsMutex.Unlock(); |
469 |
} |
} |
470 |
|
|
471 |
// check if MIDI data arrived on some engine channel |
// check if MIDI data arrived on some engine channel |
535 |
|
|
536 |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout); |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout); |
537 |
|
|
538 |
if (retval == 0) |
if (retval == 0 || (retval == -1 && errno == EINTR)) |
539 |
continue; //Nothing try again |
continue; //Nothing try again |
540 |
if (retval == -1) { |
if (retval == -1) { |
541 |
std::cerr << "LSCPServer: Socket select error." << std::endl; |
std::cerr << "LSCPServer: Socket select error." << std::endl; |
562 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
563 |
} |
} |
564 |
#else |
#else |
565 |
|
struct linger linger; |
566 |
|
linger.l_onoff = 1; |
567 |
|
linger.l_linger = 0; |
568 |
|
if(setsockopt(socket, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger))) { |
569 |
|
std::cerr << "LSCPServer: Failed to set SO_LINGER\n"; |
570 |
|
} |
571 |
|
|
572 |
if (fcntl(socket, F_SETFL, O_NONBLOCK)) { |
if (fcntl(socket, F_SETFL, O_NONBLOCK)) { |
573 |
std::cerr << "LSCPServer: F_SETFL O_NONBLOCK failed." << std::endl; |
std::cerr << "LSCPServer: F_SETFL O_NONBLOCK failed." << std::endl; |
574 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
640 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
641 |
} |
} |
642 |
|
|
643 |
|
void LSCPServer::CloseAllConnections() { |
644 |
|
std::vector<yyparse_param_t>::iterator iter = Sessions.begin(); |
645 |
|
while(iter != Sessions.end()) { |
646 |
|
CloseConnection(iter); |
647 |
|
iter = Sessions.begin(); |
648 |
|
} |
649 |
|
} |
650 |
|
|
651 |
void LSCPServer::LockRTNotify() { |
void LSCPServer::LockRTNotify() { |
652 |
RTNotifyMutex.Lock(); |
RTNotifyMutex.Lock(); |
653 |
} |
} |
1302 |
for (;iter != parameters.end(); iter++) { |
for (;iter != parameters.end(); iter++) { |
1303 |
if (s != "") s += ","; |
if (s != "") s += ","; |
1304 |
s += iter->first; |
s += iter->first; |
1305 |
|
delete iter->second; |
1306 |
} |
} |
1307 |
result.Add("PARAMETERS", s); |
result.Add("PARAMETERS", s); |
1308 |
} |
} |
1327 |
for (;iter != parameters.end(); iter++) { |
for (;iter != parameters.end(); iter++) { |
1328 |
if (s != "") s += ","; |
if (s != "") s += ","; |
1329 |
s += iter->first; |
s += iter->first; |
1330 |
|
delete iter->second; |
1331 |
} |
} |
1332 |
result.Add("PARAMETERS", s); |
result.Add("PARAMETERS", s); |
1333 |
} |
} |
1358 |
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
1359 |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
1360 |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
1361 |
|
delete pParameter; |
1362 |
} |
} |
1363 |
catch (Exception e) { |
catch (Exception e) { |
1364 |
result.Error(e); |
result.Error(e); |
1386 |
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
1387 |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
1388 |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
1389 |
|
delete pParameter; |
1390 |
} |
} |
1391 |
catch (Exception e) { |
catch (Exception e) { |
1392 |
result.Error(e); |
result.Error(e); |
1853 |
pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params); |
pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params); |
1854 |
// Make it with at least one initial port. |
// Make it with at least one initial port. |
1855 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
|
parameters["PORTS"]->SetValue("1"); |
|
1856 |
} |
} |
1857 |
// Must have a device... |
// Must have a device... |
1858 |
if (pDevice == NULL) |
if (pDevice == NULL) |
2389 |
AudioRouting += ToString(pFxSend->DestinationChannel(chan)); |
AudioRouting += ToString(pFxSend->DestinationChannel(chan)); |
2390 |
} |
} |
2391 |
|
|
2392 |
|
const String sEffectRouting = |
2393 |
|
(pFxSend->DestinationEffectChain() >= 0 && pFxSend->DestinationEffectChainPosition() >= 0) |
2394 |
|
? ToString(pFxSend->DestinationEffectChain()) + "," + ToString(pFxSend->DestinationEffectChainPosition()) |
2395 |
|
: "NONE"; |
2396 |
|
|
2397 |
// success |
// success |
2398 |
result.Add("NAME", _escapeLscpResponse(pFxSend->Name())); |
result.Add("NAME", _escapeLscpResponse(pFxSend->Name())); |
2399 |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
2400 |
result.Add("LEVEL", ToString(pFxSend->Level())); |
result.Add("LEVEL", ToString(pFxSend->Level())); |
2401 |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
2402 |
|
result.Add("EFFECT", sEffectRouting); |
2403 |
} catch (Exception e) { |
} catch (Exception e) { |
2404 |
result.Error(e); |
result.Error(e); |
2405 |
} |
} |
2462 |
return result.Produce(); |
return result.Produce(); |
2463 |
} |
} |
2464 |
|
|
2465 |
|
String LSCPServer::SetFxSendEffect(uint uiSamplerChannel, uint FxSendID, int iSendEffectChain, int iEffectChainPosition) { |
2466 |
|
dmsg(2,("LSCPServer: SetFxSendEffect(%d,%d)\n", iSendEffectChain, iEffectChainPosition)); |
2467 |
|
LSCPResultSet result; |
2468 |
|
try { |
2469 |
|
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
2470 |
|
|
2471 |
|
pFxSend->SetDestinationEffect(iSendEffectChain, iEffectChainPosition); |
2472 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2473 |
|
} catch (Exception e) { |
2474 |
|
result.Error(e); |
2475 |
|
} |
2476 |
|
return result.Produce(); |
2477 |
|
} |
2478 |
|
|
2479 |
|
String LSCPServer::GetAvailableEffects() { |
2480 |
|
dmsg(2,("LSCPServer: GetAvailableEffects()\n")); |
2481 |
|
LSCPResultSet result; |
2482 |
|
try { |
2483 |
|
int n = EffectFactory::AvailableEffectsCount(); |
2484 |
|
result.Add(n); |
2485 |
|
} |
2486 |
|
catch (Exception e) { |
2487 |
|
result.Error(e); |
2488 |
|
} |
2489 |
|
return result.Produce(); |
2490 |
|
} |
2491 |
|
|
2492 |
|
String LSCPServer::ListAvailableEffects() { |
2493 |
|
dmsg(2,("LSCPServer: ListAvailableEffects()\n")); |
2494 |
|
LSCPResultSet result; |
2495 |
|
String list; |
2496 |
|
try { |
2497 |
|
//FIXME: for now we simply enumerate from 0 .. EffectFactory::AvailableEffectsCount() here, in future we should use unique IDs for effects during the whole sampler session. This issue comes into game when the user forces a reload of available effect plugins |
2498 |
|
int n = EffectFactory::AvailableEffectsCount(); |
2499 |
|
for (int i = 0; i < n; i++) { |
2500 |
|
if (i) list += ","; |
2501 |
|
list += ToString(i); |
2502 |
|
} |
2503 |
|
} |
2504 |
|
catch (Exception e) { |
2505 |
|
result.Error(e); |
2506 |
|
} |
2507 |
|
result.Add(list); |
2508 |
|
return result.Produce(); |
2509 |
|
} |
2510 |
|
|
2511 |
|
String LSCPServer::GetEffectInfo(int iEffectIndex) { |
2512 |
|
dmsg(2,("LSCPServer: GetEffectInfo(%d)\n", iEffectIndex)); |
2513 |
|
LSCPResultSet result; |
2514 |
|
try { |
2515 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(iEffectIndex); |
2516 |
|
if (!pEffectInfo) |
2517 |
|
throw Exception("There is no effect with index " + ToString(iEffectIndex)); |
2518 |
|
|
2519 |
|
// convert the filename into the correct encoding as defined for LSCP |
2520 |
|
// (especially in terms of special characters -> escape sequences) |
2521 |
|
#if WIN32 |
2522 |
|
const String dllFileName = Path::fromWindows(pEffectInfo->Module()).toLscp(); |
2523 |
|
#else |
2524 |
|
// assuming POSIX |
2525 |
|
const String dllFileName = Path::fromPosix(pEffectInfo->Module()).toLscp(); |
2526 |
|
#endif |
2527 |
|
|
2528 |
|
result.Add("SYSTEM", pEffectInfo->EffectSystem()); |
2529 |
|
result.Add("MODULE", dllFileName); |
2530 |
|
result.Add("NAME", _escapeLscpResponse(pEffectInfo->Name())); |
2531 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectInfo->Description())); |
2532 |
|
} |
2533 |
|
catch (Exception e) { |
2534 |
|
result.Error(e); |
2535 |
|
} |
2536 |
|
return result.Produce(); |
2537 |
|
} |
2538 |
|
|
2539 |
|
String LSCPServer::GetEffectInstanceInfo(int iEffectInstance) { |
2540 |
|
dmsg(2,("LSCPServer: GetEffectInstanceInfo(%d)\n", iEffectInstance)); |
2541 |
|
LSCPResultSet result; |
2542 |
|
try { |
2543 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2544 |
|
if (!pEffect) |
2545 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2546 |
|
|
2547 |
|
EffectInfo* pEffectInfo = pEffect->GetEffectInfo(); |
2548 |
|
|
2549 |
|
// convert the filename into the correct encoding as defined for LSCP |
2550 |
|
// (especially in terms of special characters -> escape sequences) |
2551 |
|
#if WIN32 |
2552 |
|
const String dllFileName = Path::fromWindows(pEffectInfo->Module()).toLscp(); |
2553 |
|
#else |
2554 |
|
// assuming POSIX |
2555 |
|
const String dllFileName = Path::fromPosix(pEffectInfo->Module()).toLscp(); |
2556 |
|
#endif |
2557 |
|
|
2558 |
|
result.Add("SYSTEM", pEffectInfo->EffectSystem()); |
2559 |
|
result.Add("MODULE", dllFileName); |
2560 |
|
result.Add("NAME", _escapeLscpResponse(pEffectInfo->Name())); |
2561 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectInfo->Description())); |
2562 |
|
result.Add("INPUT_CONTROLS", ToString(pEffect->InputControlCount())); |
2563 |
|
} |
2564 |
|
catch (Exception e) { |
2565 |
|
result.Error(e); |
2566 |
|
} |
2567 |
|
return result.Produce(); |
2568 |
|
} |
2569 |
|
|
2570 |
|
String LSCPServer::GetEffectInstanceInputControlInfo(int iEffectInstance, int iInputControlIndex) { |
2571 |
|
dmsg(2,("LSCPServer: GetEffectInstanceInputControlInfo(%d,%d)\n", iEffectInstance, iInputControlIndex)); |
2572 |
|
LSCPResultSet result; |
2573 |
|
try { |
2574 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2575 |
|
if (!pEffect) |
2576 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2577 |
|
|
2578 |
|
EffectControl* pEffectControl = pEffect->InputControl(iInputControlIndex); |
2579 |
|
if (!pEffectControl) |
2580 |
|
throw Exception( |
2581 |
|
"Effect instance " + ToString(iEffectInstance) + |
2582 |
|
" does not have an input control with index " + |
2583 |
|
ToString(iInputControlIndex) |
2584 |
|
); |
2585 |
|
|
2586 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectControl->Description())); |
2587 |
|
result.Add("VALUE", pEffectControl->Value()); |
2588 |
|
if (pEffectControl->MinValue()) |
2589 |
|
result.Add("RANGE_MIN", *pEffectControl->MinValue()); |
2590 |
|
if (pEffectControl->MaxValue()) |
2591 |
|
result.Add("RANGE_MAX", *pEffectControl->MaxValue()); |
2592 |
|
if (!pEffectControl->Possibilities().empty()) |
2593 |
|
result.Add("POSSIBILITIES", pEffectControl->Possibilities()); |
2594 |
|
if (pEffectControl->DefaultValue()) |
2595 |
|
result.Add("DEFAULT", *pEffectControl->DefaultValue()); |
2596 |
|
} catch (Exception e) { |
2597 |
|
result.Error(e); |
2598 |
|
} |
2599 |
|
return result.Produce(); |
2600 |
|
} |
2601 |
|
|
2602 |
|
String LSCPServer::SetEffectInstanceInputControlValue(int iEffectInstance, int iInputControlIndex, double dValue) { |
2603 |
|
dmsg(2,("LSCPServer: SetEffectInstanceInputControlValue(%d,%d,%f)\n", iEffectInstance, iInputControlIndex, dValue)); |
2604 |
|
LSCPResultSet result; |
2605 |
|
try { |
2606 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2607 |
|
if (!pEffect) |
2608 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2609 |
|
|
2610 |
|
EffectControl* pEffectControl = pEffect->InputControl(iInputControlIndex); |
2611 |
|
if (!pEffectControl) |
2612 |
|
throw Exception( |
2613 |
|
"Effect instance " + ToString(iEffectInstance) + |
2614 |
|
" does not have an input control with index " + |
2615 |
|
ToString(iInputControlIndex) |
2616 |
|
); |
2617 |
|
|
2618 |
|
pEffectControl->SetValue(dValue); |
2619 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_info, iEffectInstance)); |
2620 |
|
} catch (Exception e) { |
2621 |
|
result.Error(e); |
2622 |
|
} |
2623 |
|
return result.Produce(); |
2624 |
|
} |
2625 |
|
|
2626 |
|
String LSCPServer::CreateEffectInstance(int iEffectIndex) { |
2627 |
|
dmsg(2,("LSCPServer: CreateEffectInstance(%d)\n", iEffectIndex)); |
2628 |
|
LSCPResultSet result; |
2629 |
|
try { |
2630 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(iEffectIndex); |
2631 |
|
if (!pEffectInfo) |
2632 |
|
throw Exception("There is no effect with index " + ToString(iEffectIndex)); |
2633 |
|
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2634 |
|
result = pEffect->ID(); // success |
2635 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount())); |
2636 |
|
} catch (Exception e) { |
2637 |
|
result.Error(e); |
2638 |
|
} |
2639 |
|
return result.Produce(); |
2640 |
|
} |
2641 |
|
|
2642 |
|
String LSCPServer::CreateEffectInstance(String effectSystem, String module, String effectName) { |
2643 |
|
dmsg(2,("LSCPServer: CreateEffectInstance('%s','%s','%s')\n", effectSystem.c_str(), module.c_str(), effectName.c_str())); |
2644 |
|
LSCPResultSet result; |
2645 |
|
try { |
2646 |
|
// to allow loading the same LSCP session file on different systems |
2647 |
|
// successfully, probably with different effect plugin DLL paths or even |
2648 |
|
// running completely different operating systems, we do the following |
2649 |
|
// for finding the right effect: |
2650 |
|
// |
2651 |
|
// first try to search for an exact match of the effect plugin DLL |
2652 |
|
// (a.k.a 'module'), to avoid picking the wrong DLL with the same |
2653 |
|
// effect name ... |
2654 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_MATCH_EXACTLY); |
2655 |
|
// ... if no effect with exactly matchin DLL filename was found, then |
2656 |
|
// try to lower the restrictions of matching the effect plugin DLL |
2657 |
|
// filename and try again and again ... |
2658 |
|
if (!pEffectInfo) { |
2659 |
|
dmsg(2,("no exact module match, trying MODULE_IGNORE_PATH\n")); |
2660 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH); |
2661 |
|
} |
2662 |
|
if (!pEffectInfo) { |
2663 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_PATH | MODULE_IGNORE_CASE\n")); |
2664 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH | EffectFactory::MODULE_IGNORE_CASE); |
2665 |
|
} |
2666 |
|
if (!pEffectInfo) { |
2667 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_PATH | MODULE_IGNORE_CASE | MODULE_IGNORE_EXTENSION\n")); |
2668 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH | EffectFactory::MODULE_IGNORE_CASE | EffectFactory::MODULE_IGNORE_EXTENSION); |
2669 |
|
} |
2670 |
|
// ... if there was still no effect found, then completely ignore the |
2671 |
|
// DLL plugin filename argument and just search for the matching effect |
2672 |
|
// system type and effect name |
2673 |
|
if (!pEffectInfo) { |
2674 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_ALL\n")); |
2675 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_ALL); |
2676 |
|
} |
2677 |
|
if (!pEffectInfo) |
2678 |
|
throw Exception("There is no such effect '" + effectSystem + "' '" + module + "' '" + effectName + "'"); |
2679 |
|
|
2680 |
|
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2681 |
|
result = LSCPResultSet(pEffect->ID()); |
2682 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount())); |
2683 |
|
} catch (Exception e) { |
2684 |
|
result.Error(e); |
2685 |
|
} |
2686 |
|
return result.Produce(); |
2687 |
|
} |
2688 |
|
|
2689 |
|
String LSCPServer::DestroyEffectInstance(int iEffectInstance) { |
2690 |
|
dmsg(2,("LSCPServer: DestroyEffectInstance(%d)\n", iEffectInstance)); |
2691 |
|
LSCPResultSet result; |
2692 |
|
try { |
2693 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2694 |
|
if (!pEffect) |
2695 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2696 |
|
EffectFactory::Destroy(pEffect); |
2697 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount())); |
2698 |
|
} catch (Exception e) { |
2699 |
|
result.Error(e); |
2700 |
|
} |
2701 |
|
return result.Produce(); |
2702 |
|
} |
2703 |
|
|
2704 |
|
String LSCPServer::GetEffectInstances() { |
2705 |
|
dmsg(2,("LSCPServer: GetEffectInstances()\n")); |
2706 |
|
LSCPResultSet result; |
2707 |
|
try { |
2708 |
|
int n = EffectFactory::EffectInstancesCount(); |
2709 |
|
result.Add(n); |
2710 |
|
} catch (Exception e) { |
2711 |
|
result.Error(e); |
2712 |
|
} |
2713 |
|
return result.Produce(); |
2714 |
|
} |
2715 |
|
|
2716 |
|
String LSCPServer::ListEffectInstances() { |
2717 |
|
dmsg(2,("LSCPServer: ListEffectInstances()\n")); |
2718 |
|
LSCPResultSet result; |
2719 |
|
String list; |
2720 |
|
try { |
2721 |
|
int n = EffectFactory::EffectInstancesCount(); |
2722 |
|
for (int i = 0; i < n; i++) { |
2723 |
|
Effect* pEffect = EffectFactory::GetEffectInstance(i); |
2724 |
|
if (i) list += ","; |
2725 |
|
list += ToString(pEffect->ID()); |
2726 |
|
} |
2727 |
|
} catch (Exception e) { |
2728 |
|
result.Error(e); |
2729 |
|
} |
2730 |
|
result.Add(list); |
2731 |
|
return result.Produce(); |
2732 |
|
} |
2733 |
|
|
2734 |
|
String LSCPServer::GetSendEffectChains(int iAudioOutputDevice) { |
2735 |
|
dmsg(2,("LSCPServer: GetSendEffectChains(%d)\n", iAudioOutputDevice)); |
2736 |
|
LSCPResultSet result; |
2737 |
|
try { |
2738 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2739 |
|
if (!devices.count(iAudioOutputDevice)) |
2740 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2741 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2742 |
|
int n = pDevice->SendEffectChainCount(); |
2743 |
|
result.Add(n); |
2744 |
|
} catch (Exception e) { |
2745 |
|
result.Error(e); |
2746 |
|
} |
2747 |
|
return result.Produce(); |
2748 |
|
} |
2749 |
|
|
2750 |
|
String LSCPServer::ListSendEffectChains(int iAudioOutputDevice) { |
2751 |
|
dmsg(2,("LSCPServer: ListSendEffectChains(%d)\n", iAudioOutputDevice)); |
2752 |
|
LSCPResultSet result; |
2753 |
|
String list; |
2754 |
|
try { |
2755 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2756 |
|
if (!devices.count(iAudioOutputDevice)) |
2757 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2758 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2759 |
|
int n = pDevice->SendEffectChainCount(); |
2760 |
|
for (int i = 0; i < n; i++) { |
2761 |
|
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
2762 |
|
if (i) list += ","; |
2763 |
|
list += ToString(pEffectChain->ID()); |
2764 |
|
} |
2765 |
|
} catch (Exception e) { |
2766 |
|
result.Error(e); |
2767 |
|
} |
2768 |
|
result.Add(list); |
2769 |
|
return result.Produce(); |
2770 |
|
} |
2771 |
|
|
2772 |
|
String LSCPServer::AddSendEffectChain(int iAudioOutputDevice) { |
2773 |
|
dmsg(2,("LSCPServer: AddSendEffectChain(%d)\n", iAudioOutputDevice)); |
2774 |
|
LSCPResultSet result; |
2775 |
|
try { |
2776 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2777 |
|
if (!devices.count(iAudioOutputDevice)) |
2778 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2779 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2780 |
|
EffectChain* pEffectChain = pDevice->AddSendEffectChain(); |
2781 |
|
result = pEffectChain->ID(); |
2782 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_count, iAudioOutputDevice, pDevice->SendEffectChainCount())); |
2783 |
|
} catch (Exception e) { |
2784 |
|
result.Error(e); |
2785 |
|
} |
2786 |
|
return result.Produce(); |
2787 |
|
} |
2788 |
|
|
2789 |
|
String LSCPServer::RemoveSendEffectChain(int iAudioOutputDevice, int iSendEffectChain) { |
2790 |
|
dmsg(2,("LSCPServer: RemoveSendEffectChain(%d,%d)\n", iAudioOutputDevice, iSendEffectChain)); |
2791 |
|
LSCPResultSet result; |
2792 |
|
try { |
2793 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2794 |
|
if (!devices.count(iAudioOutputDevice)) |
2795 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2796 |
|
|
2797 |
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
2798 |
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
2799 |
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
2800 |
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
2801 |
|
AudioOutputDevice* pDev = (*itEngineChannel)->GetAudioOutputDevice(); |
2802 |
|
if (pDev != NULL && pDev->deviceId() == iAudioOutputDevice) { |
2803 |
|
for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) { |
2804 |
|
FxSend* fxs = (*itEngineChannel)->GetFxSend(i); |
2805 |
|
if(fxs != NULL && fxs->DestinationEffectChain() == iSendEffectChain) { |
2806 |
|
throw Exception("The effect chain is still in use by channel " + ToString((*itEngineChannel)->GetSamplerChannel()->Index())); |
2807 |
|
} |
2808 |
|
} |
2809 |
|
} |
2810 |
|
} |
2811 |
|
|
2812 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2813 |
|
for (int i = 0; i < pDevice->SendEffectChainCount(); i++) { |
2814 |
|
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
2815 |
|
if (pEffectChain->ID() == iSendEffectChain) { |
2816 |
|
pDevice->RemoveSendEffectChain(i); |
2817 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_count, iAudioOutputDevice, pDevice->SendEffectChainCount())); |
2818 |
|
return result.Produce(); |
2819 |
|
} |
2820 |
|
} |
2821 |
|
throw Exception( |
2822 |
|
"There is no send effect chain with ID " + |
2823 |
|
ToString(iSendEffectChain) + " for audio output device " + |
2824 |
|
ToString(iAudioOutputDevice) + "." |
2825 |
|
); |
2826 |
|
} catch (Exception e) { |
2827 |
|
result.Error(e); |
2828 |
|
} |
2829 |
|
return result.Produce(); |
2830 |
|
} |
2831 |
|
|
2832 |
|
static EffectChain* _getSendEffectChain(Sampler* pSampler, int iAudioOutputDevice, int iSendEffectChain) throw (Exception) { |
2833 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2834 |
|
if (!devices.count(iAudioOutputDevice)) |
2835 |
|
throw Exception( |
2836 |
|
"There is no audio output device with index " + |
2837 |
|
ToString(iAudioOutputDevice) + "." |
2838 |
|
); |
2839 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2840 |
|
EffectChain* pEffectChain = pDevice->SendEffectChainByID(iSendEffectChain); |
2841 |
|
if(pEffectChain != NULL) return pEffectChain; |
2842 |
|
throw Exception( |
2843 |
|
"There is no send effect chain with ID " + |
2844 |
|
ToString(iSendEffectChain) + " for audio output device " + |
2845 |
|
ToString(iAudioOutputDevice) + "." |
2846 |
|
); |
2847 |
|
} |
2848 |
|
|
2849 |
|
String LSCPServer::GetSendEffectChainInfo(int iAudioOutputDevice, int iSendEffectChain) { |
2850 |
|
dmsg(2,("LSCPServer: GetSendEffectChainInfo(%d,%d)\n", iAudioOutputDevice, iSendEffectChain)); |
2851 |
|
LSCPResultSet result; |
2852 |
|
try { |
2853 |
|
EffectChain* pEffectChain = |
2854 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2855 |
|
String sEffectSequence; |
2856 |
|
for (int i = 0; i < pEffectChain->EffectCount(); i++) { |
2857 |
|
if (i) sEffectSequence += ","; |
2858 |
|
sEffectSequence += ToString(pEffectChain->GetEffect(i)->ID()); |
2859 |
|
} |
2860 |
|
result.Add("EFFECT_COUNT", pEffectChain->EffectCount()); |
2861 |
|
result.Add("EFFECT_SEQUENCE", sEffectSequence); |
2862 |
|
} catch (Exception e) { |
2863 |
|
result.Error(e); |
2864 |
|
} |
2865 |
|
return result.Produce(); |
2866 |
|
} |
2867 |
|
|
2868 |
|
String LSCPServer::AppendSendEffectChainEffect(int iAudioOutputDevice, int iSendEffectChain, int iEffectInstance) { |
2869 |
|
dmsg(2,("LSCPServer: AppendSendEffectChainEffect(%d,%d,%d)\n", iAudioOutputDevice, iSendEffectChain, iEffectInstance)); |
2870 |
|
LSCPResultSet result; |
2871 |
|
try { |
2872 |
|
EffectChain* pEffectChain = |
2873 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2874 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2875 |
|
if (!pEffect) |
2876 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2877 |
|
pEffectChain->AppendEffect(pEffect); |
2878 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount())); |
2879 |
|
} catch (Exception e) { |
2880 |
|
result.Error(e); |
2881 |
|
} |
2882 |
|
return result.Produce(); |
2883 |
|
} |
2884 |
|
|
2885 |
|
String LSCPServer::InsertSendEffectChainEffect(int iAudioOutputDevice, int iSendEffectChain, int iEffectChainPosition, int iEffectInstance) { |
2886 |
|
dmsg(2,("LSCPServer: InsertSendEffectChainEffect(%d,%d,%d,%d)\n", iAudioOutputDevice, iSendEffectChain, iEffectChainPosition, iEffectInstance)); |
2887 |
|
LSCPResultSet result; |
2888 |
|
try { |
2889 |
|
EffectChain* pEffectChain = |
2890 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2891 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2892 |
|
if (!pEffect) |
2893 |
|
throw Exception("There is no effect instance with index " + ToString(iEffectInstance)); |
2894 |
|
pEffectChain->InsertEffect(pEffect, iEffectChainPosition); |
2895 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount())); |
2896 |
|
} catch (Exception e) { |
2897 |
|
result.Error(e); |
2898 |
|
} |
2899 |
|
return result.Produce(); |
2900 |
|
} |
2901 |
|
|
2902 |
|
String LSCPServer::RemoveSendEffectChainEffect(int iAudioOutputDevice, int iSendEffectChain, int iEffectChainPosition) { |
2903 |
|
dmsg(2,("LSCPServer: RemoveSendEffectChainEffect(%d,%d,%d)\n", iAudioOutputDevice, iSendEffectChain, iEffectChainPosition)); |
2904 |
|
LSCPResultSet result; |
2905 |
|
try { |
2906 |
|
EffectChain* pEffectChain = |
2907 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2908 |
|
|
2909 |
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
2910 |
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
2911 |
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
2912 |
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
2913 |
|
AudioOutputDevice* pDev = (*itEngineChannel)->GetAudioOutputDevice(); |
2914 |
|
if (pDev != NULL && pDev->deviceId() == iAudioOutputDevice) { |
2915 |
|
for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) { |
2916 |
|
FxSend* fxs = (*itEngineChannel)->GetFxSend(i); |
2917 |
|
if(fxs != NULL && fxs->DestinationEffectChain() == iSendEffectChain && fxs->DestinationEffectChainPosition() == iEffectChainPosition) { |
2918 |
|
throw Exception("The effect instance is still in use by channel " + ToString((*itEngineChannel)->GetSamplerChannel()->Index())); |
2919 |
|
} |
2920 |
|
} |
2921 |
|
} |
2922 |
|
} |
2923 |
|
|
2924 |
|
pEffectChain->RemoveEffect(iEffectChainPosition); |
2925 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount())); |
2926 |
|
} catch (Exception e) { |
2927 |
|
result.Error(e); |
2928 |
|
} |
2929 |
|
return result.Produce(); |
2930 |
|
} |
2931 |
|
|
2932 |
String LSCPServer::EditSamplerChannelInstrument(uint uiSamplerChannel) { |
String LSCPServer::EditSamplerChannelInstrument(uint uiSamplerChannel) { |
2933 |
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
2934 |
LSCPResultSet result; |
LSCPResultSet result; |
2977 |
pMidiDevice->SendNoteOffToDevice(Arg1, Arg2); |
pMidiDevice->SendNoteOffToDevice(Arg1, Arg2); |
2978 |
bool b = pMidiDevice->SendNoteOffToSampler(Arg1, Arg2); |
bool b = pMidiDevice->SendNoteOffToSampler(Arg1, Arg2); |
2979 |
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
2980 |
|
} else if (MidiMsg == "CC") { |
2981 |
|
pMidiDevice->SendCCToDevice(Arg1, Arg2); |
2982 |
|
bool b = pMidiDevice->SendCCToSampler(Arg1, Arg2); |
2983 |
|
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
2984 |
} else { |
} else { |
2985 |
throw Exception("Unknown MIDI message type: " + MidiMsg); |
throw Exception("Unknown MIDI message type: " + MidiMsg); |
2986 |
} |
} |
3063 |
String LSCPServer::GetTotalVoiceCountMax() { |
String LSCPServer::GetTotalVoiceCountMax() { |
3064 |
dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n")); |
dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n")); |
3065 |
LSCPResultSet result; |
LSCPResultSet result; |
3066 |
result.Add(EngineFactory::EngineInstances().size() * CONFIG_MAX_VOICES); |
result.Add(EngineFactory::EngineInstances().size() * GLOBAL_MAX_VOICES); |
3067 |
|
return result.Produce(); |
3068 |
|
} |
3069 |
|
|
3070 |
|
/** |
3071 |
|
* Will be called by the parser to return the sampler global maximum |
3072 |
|
* allowed number of voices. |
3073 |
|
*/ |
3074 |
|
String LSCPServer::GetGlobalMaxVoices() { |
3075 |
|
dmsg(2,("LSCPServer: GetGlobalMaxVoices()\n")); |
3076 |
|
LSCPResultSet result; |
3077 |
|
result.Add(GLOBAL_MAX_VOICES); |
3078 |
|
return result.Produce(); |
3079 |
|
} |
3080 |
|
|
3081 |
|
/** |
3082 |
|
* Will be called by the parser to set the sampler global maximum number of |
3083 |
|
* voices. |
3084 |
|
*/ |
3085 |
|
String LSCPServer::SetGlobalMaxVoices(int iVoices) { |
3086 |
|
dmsg(2,("LSCPServer: SetGlobalMaxVoices(%d)\n", iVoices)); |
3087 |
|
LSCPResultSet result; |
3088 |
|
try { |
3089 |
|
if (iVoices < 1) throw Exception("Maximum voices may not be less than 1"); |
3090 |
|
GLOBAL_MAX_VOICES = iVoices; // see common/global_private.cpp |
3091 |
|
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
3092 |
|
if (engines.size() > 0) { |
3093 |
|
std::set<Engine*>::iterator iter = engines.begin(); |
3094 |
|
std::set<Engine*>::iterator end = engines.end(); |
3095 |
|
for (; iter != end; ++iter) { |
3096 |
|
(*iter)->SetMaxVoices(iVoices); |
3097 |
|
} |
3098 |
|
} |
3099 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "VOICES", GLOBAL_MAX_VOICES)); |
3100 |
|
} catch (Exception e) { |
3101 |
|
result.Error(e); |
3102 |
|
} |
3103 |
|
return result.Produce(); |
3104 |
|
} |
3105 |
|
|
3106 |
|
/** |
3107 |
|
* Will be called by the parser to return the sampler global maximum |
3108 |
|
* allowed number of disk streams. |
3109 |
|
*/ |
3110 |
|
String LSCPServer::GetGlobalMaxStreams() { |
3111 |
|
dmsg(2,("LSCPServer: GetGlobalMaxStreams()\n")); |
3112 |
|
LSCPResultSet result; |
3113 |
|
result.Add(GLOBAL_MAX_STREAMS); |
3114 |
|
return result.Produce(); |
3115 |
|
} |
3116 |
|
|
3117 |
|
/** |
3118 |
|
* Will be called by the parser to set the sampler global maximum number of |
3119 |
|
* disk streams. |
3120 |
|
*/ |
3121 |
|
String LSCPServer::SetGlobalMaxStreams(int iStreams) { |
3122 |
|
dmsg(2,("LSCPServer: SetGlobalMaxStreams(%d)\n", iStreams)); |
3123 |
|
LSCPResultSet result; |
3124 |
|
try { |
3125 |
|
if (iStreams < 0) throw Exception("Maximum disk streams may not be negative"); |
3126 |
|
GLOBAL_MAX_STREAMS = iStreams; // see common/global_private.cpp |
3127 |
|
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
3128 |
|
if (engines.size() > 0) { |
3129 |
|
std::set<Engine*>::iterator iter = engines.begin(); |
3130 |
|
std::set<Engine*>::iterator end = engines.end(); |
3131 |
|
for (; iter != end; ++iter) { |
3132 |
|
(*iter)->SetMaxDiskStreams(iStreams); |
3133 |
|
} |
3134 |
|
} |
3135 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "STREAMS", GLOBAL_MAX_STREAMS)); |
3136 |
|
} catch (Exception e) { |
3137 |
|
result.Error(e); |
3138 |
|
} |
3139 |
return result.Produce(); |
return result.Produce(); |
3140 |
} |
} |
3141 |
|
|
3323 |
throw Exception("Directory is specified"); |
throw Exception("Directory is specified"); |
3324 |
} |
} |
3325 |
#else |
#else |
3326 |
struct stat statBuf; |
File f(Filename); |
3327 |
int res = stat(Filename.c_str(), &statBuf); |
if(!f.Exist()) throw Exception(f.GetErrorMsg()); |
3328 |
if (res) { |
if (f.IsDirectory()) throw Exception("Directory is specified"); |
|
std::stringstream ss; |
|
|
ss << "Fail to stat `" << Filename << "`: " << strerror(errno); |
|
|
throw Exception(ss.str()); |
|
|
} |
|
|
|
|
|
if (S_ISDIR(statBuf.st_mode)) { |
|
|
throw Exception("Directory is specified"); |
|
|
} |
|
3329 |
#endif |
#endif |
3330 |
} |
} |
3331 |
|
|