void stream_encoder::connect(){ if((!config->weareconnected)&&(ready_to_stream())){ setForceStop(config, 0); connectToServer(config); // SPMOD //if(connectToServer(config) == 0) // config->forcedDisconnect = true; // Did this in connectToServerResponse } }
void * startReconnectThread(void *url) { reconnectLoop = 1; reconnectThreadRunning = 1; while (reconnectLoop) { time_t currentTime; currentTime = time(¤tTime); for(int i = 0; i < gMain.gNumEncoders; i++) { if(g[i]->forcedDisconnect) { LogMessage(g[i], LOG_DEBUG, "Reconnecting disconnected encoder."); int timeout = getReconnectSecs(g[i]); int timediff = currentTime - g[i]->forcedDisconnectSecs; if(timediff > timeout) { g[i]->forcedDisconnect = false; if(!g[i]->weareconnected) { setForceStop(g[i], 0); if(!connectToServer(g[i])) { g[i]->forcedDisconnect = true; g[i]->forcedDisconnectSecs = time(&(g[i]->forcedDisconnectSecs)); } LogMessage(g[i], LOG_DEBUG, "Done Reconnecting disconnected encoder."); } } else { char buf[255] = ""; sprintf(buf, "Connecting in %d seconds", timeout - timediff); outputStatusCallback(g[i], buf); } } } #ifdef WIN32 Sleep(1000); #else sleep(1); #endif } reconnectThreadRunning = 0; return(NULL); }
void stream_encoder::disconnect(){ setForceStop(config, 1); disconnectFromServer(config); config->forcedDisconnect = false; }
int OddcastWnd::handleChildNotify (int msg, int objId, int param1, int param2) { if (msg != ChildNotify::BUTTON_LEFTPUSH) return 0; int ret; switch(objId) { case ODDCAST_VU: if (m_vu_on_off) { m_vu_on_off = 0; } else { m_vu_on_off = 1; } break; case ODDCAST_CONNECT: if (getIsConnected()) { disconnectFromServer(); setForceStop(1); if (getLiveRecordingSetFlag()) { stopRecording(); } setCurrentSongTitle(""); m_connect->setButtonText("Connect", EXB_BUTTON_FONT_SIZE); gAvgRight = 0; gAvgLeft = 0; invalidate(); } else { char message[1024] = ""; char error[1024] = ""; int ret = 1; #ifdef WIN32 if (getWMAFlag()) { ret = startWMAServer(message,error); } #endif if (ret == 0) { MessageBox(NULL,message, NULL, MB_OK); MessageBox(NULL,error, NULL, MB_OK); } else { if (startOddcast(NULL)) { // gThreadHandle = CreateThread(NULL, 0, startOddcast, NULL, 0, &gThreadID); m_connect->setButtonText("Stop", EXB_BUTTON_FONT_SIZE); } } } break; case ODDCAST_CONFIG: if (!getIsConnected()) { STARTUPINFO si = {0}; PROCESS_INFORMATION pi = {0}; si.cb = sizeof (si); si.lpReserved = si.lpDesktop = si.lpTitle = NULL; si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOW; si.cbReserved2 = 0; si.lpReserved2 = 0; DWORD dwError; CreateProcess (NULL, "oddcast_editConfig.exe", NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); WaitForSingleObject (pi.hProcess, INFINITE); initializeGlobals(); transcode_init(); } else { MessageBox(NULL, "Sorry, but you cannot edit the settings while connected", "Error", MB_OK); } break; } return 1; }
OddcastWnd::~OddcastWnd() { if (getIsConnected()) { disconnectFromServer(); setForceStop(1); if (getLiveRecordingSetFlag()) { stopRecording(); } setCurrentSongTitle(""); m_connect->setButtonText("Connect", EXB_BUTTON_FONT_SIZE); gAvgRight = 0; gAvgLeft = 0; invalidate(); } /* if (m_ServerDescText) { delete m_ServerDescText; } if (m_ServerDescValue) { delete m_ServerDescValue; } if (m_DestinationText) { delete m_DestinationText; } if (m_DestinationValue) { delete m_DestinationValue; } if (m_MetadataText) { delete m_MetadataText; } if (m_MetadataValue) { delete m_MetadataValue; } if (m_BPSText) { delete m_BPSText; } if (m_BPSValue) { delete m_BPSValue; } if (m_BitrateText) { delete m_BitrateText; } if (m_BitrateValue) { delete m_BitrateValue; } if (m_StatusText) { delete m_StatusText; } if (m_StatusValue) { delete m_StatusValue; } if (m_LiveRecordingText) { delete m_LiveRecordingText; } if (m_connect) { delete m_connect; } if (m_config) { delete m_config; } if (m_vu) { delete m_vu; } */ api->core_delCallback(0, this); m_pcurInst = NULL; }