26 |
#include "lscpevent.h" |
#include "lscpevent.h" |
27 |
|
|
28 |
#if defined(WIN32) |
#if defined(WIN32) |
29 |
|
#include <windows.h> |
30 |
#else |
#else |
31 |
#include <fcntl.h> |
#include <fcntl.h> |
32 |
#endif |
#endif |
127 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_info, "DB_INSTRUMENT_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_info, "DB_INSTRUMENT_INFO"); |
128 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instrs_job_info, "DB_INSTRUMENTS_JOB_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instrs_job_info, "DB_INSTRUMENTS_JOB_INFO"); |
129 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
130 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_total_stream_count, "TOTAL_STREAM_COUNT"); |
131 |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
132 |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
133 |
hSocket = -1; |
hSocket = -1; |
189 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, NewCount)); |
190 |
} |
} |
191 |
|
|
192 |
|
void LSCPServer::EventHandler::TotalStreamCountChanged(int NewCount) { |
193 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_stream_count, NewCount)); |
194 |
|
} |
195 |
|
|
196 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
197 |
void LSCPServer::DbInstrumentsEventHandler::DirectoryCountChanged(String Dir) { |
void LSCPServer::DbInstrumentsEventHandler::DirectoryCountChanged(String Dir) { |
198 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_count, InstrumentsDb::toEscapedPath(Dir))); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_count, InstrumentsDb::toEscapedPath(Dir))); |
289 |
pSampler->AddVoiceCountListener(&eventHandler); |
pSampler->AddVoiceCountListener(&eventHandler); |
290 |
pSampler->AddStreamCountListener(&eventHandler); |
pSampler->AddStreamCountListener(&eventHandler); |
291 |
pSampler->AddBufferFillListener(&eventHandler); |
pSampler->AddBufferFillListener(&eventHandler); |
292 |
|
pSampler->AddTotalStreamCountListener(&eventHandler); |
293 |
pSampler->AddTotalVoiceCountListener(&eventHandler); |
pSampler->AddTotalVoiceCountListener(&eventHandler); |
294 |
pSampler->AddFxSendCountListener(&eventHandler); |
pSampler->AddFxSendCountListener(&eventHandler); |
295 |
MidiInstrumentMapper::AddMidiInstrumentCountListener(&eventHandler); |
MidiInstrumentMapper::AddMidiInstrumentCountListener(&eventHandler); |
2353 |
} |
} |
2354 |
|
|
2355 |
/** |
/** |
2356 |
|
* Will be called by the parser to return the current number of all active streams. |
2357 |
|
*/ |
2358 |
|
String LSCPServer::GetTotalStreamCount() { |
2359 |
|
dmsg(2,("LSCPServer: GetTotalStreamCount()\n")); |
2360 |
|
LSCPResultSet result; |
2361 |
|
result.Add(pSampler->GetDiskStreamCount()); |
2362 |
|
return result.Produce(); |
2363 |
|
} |
2364 |
|
|
2365 |
|
/** |
2366 |
* Will be called by the parser to return the current number of all active voices. |
* Will be called by the parser to return the current number of all active voices. |
2367 |
*/ |
*/ |
2368 |
String LSCPServer::GetTotalVoiceCount() { |
String LSCPServer::GetTotalVoiceCount() { |
2534 |
} |
} |
2535 |
|
|
2536 |
void LSCPServer::VerifyFile(String Filename) { |
void LSCPServer::VerifyFile(String Filename) { |
2537 |
|
#if WIN32 |
2538 |
|
WIN32_FIND_DATA win32FileAttributeData; |
2539 |
|
BOOL res = GetFileAttributesEx( Filename.c_str(), GetFileExInfoStandard, &win32FileAttributeData ); |
2540 |
|
if (!res) { |
2541 |
|
std::stringstream ss; |
2542 |
|
ss << "File does not exist, GetFileAttributesEx failed `" << Filename << "`: Error " << GetLastError(); |
2543 |
|
throw Exception(ss.str()); |
2544 |
|
} |
2545 |
|
if ( win32FileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { |
2546 |
|
throw Exception("Directory is specified"); |
2547 |
|
} |
2548 |
|
#else |
2549 |
struct stat statBuf; |
struct stat statBuf; |
2550 |
int res = stat(Filename.c_str(), &statBuf); |
int res = stat(Filename.c_str(), &statBuf); |
2551 |
if (res) { |
if (res) { |
2557 |
if (S_ISDIR(statBuf.st_mode)) { |
if (S_ISDIR(statBuf.st_mode)) { |
2558 |
throw Exception("Directory is specified"); |
throw Exception("Directory is specified"); |
2559 |
} |
} |
2560 |
|
#endif |
2561 |
} |
} |
2562 |
|
|
2563 |
/** |
/** |