int main (int argc, char ** argv) { configInit(); if(!declare_pid("player")) { puts("Player already found"); return 1; } srandom(time(NULL)); arguments = argv; signalsSetup(); gst_init (NULL,NULL); selectSetup(); onSignal(SIGUSR1,signalNext); onSignal(SIGUSR2,restartPlayer); preparation_t queries[] = { { "getTopRecording", "SELECT queue.recording," "replaygain.gain,replaygain.peak,replaygain.level," "recordings.path " "FROM queue INNER JOIN replaygain ON replaygain.id = queue.recording INNER JOIN recordings ON recordings.id = queue.recording ORDER BY queue.id ASC LIMIT 1" }, }; prepareQueries(queries); GMainLoop* loop = g_main_loop_new (NULL, FALSE); void done_quit() { g_main_loop_quit(loop); }
void ExternalConnectThread::SignalError() { m_csSocket.Enter(); if(m_udpSocket) { m_udpSocket->Close(); } m_csSocket.Leave(); ConnectErrorMessage errMsg(m_address.m_moduleName, "", GetError()); onSignal(errMsg); }
void ConnectThread::ThreadFunc() { m_socket = m_address.m_socketFactory->CreateSocket(); m_socket->Bind(m_address.m_localIP, m_address.m_localPort); if(m_socket->Connect(m_address.m_ip, m_address.m_port)) { Connector* connector = m_address.m_connectorFactory->CreateConnector(m_socket); connector->SetId(m_address.m_id); connector->SetRemoteAddr(m_address.m_ip, m_address.m_port); m_socket = 0; ConnectorMessage msg(connector); onSignal(msg); } else { ConnectErrorMessage errMsg(m_address.m_moduleName, "", GetError()); onSignal(errMsg); delete m_socket; m_socket = 0; } }
void Timer::run() { while (m_running) { std::unique_lock<std::mutex> lock(m_mutex); // Wait the timer delay or the interrupt m_condition.wait_for(lock, std::chrono::milliseconds(m_delay), [&] () { return m_running == false; }); if (m_running) { // Signal process onSignal(); if (m_type == TimerType::Single) { m_running = false; } } } // Finished onEnd(); }