void Session::FinalRelease() { LogFlowThisFunc(("\n")); uninit(); BaseFinalRelease(); }
void CvGameRecord::reset() { uninit(); m_eEra = NO_ERA; m_szMapName.clear(); }
WasapiEngine::~WasapiEngine() { uninit(); QSettings settings; settings.beginGroup("wasapiengine"); settings.setValue("deviceIndex", deviceIndex); settings.endGroup(); }
static int init(struct ao *ao) { MP_DBG(ao, "Init wasapi\n"); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); struct wasapi_state *state = ao->priv; state->log = ao->log; state->deviceID = find_deviceID(ao); if (!state->deviceID) { uninit(ao); return -1; } wasapi_change_init(ao, false); state->hInitDone = CreateEventW(NULL, FALSE, FALSE, NULL); state->hWake = CreateEventW(NULL, FALSE, FALSE, NULL); if (!state->hInitDone || !state->hWake) { MP_ERR(ao, "Error creating events\n"); uninit(ao); return -1; } state->init_ret = E_FAIL; state->hAudioThread = CreateThread(NULL, 0, &AudioThread, ao, 0, NULL); if (!state->hAudioThread) { MP_ERR(ao, "Failed to create audio thread\n"); uninit(ao); return -1; } WaitForSingleObject(state->hInitDone, INFINITE); // wait on init complete SAFE_RELEASE(state->hInitDone,CloseHandle(state->hInitDone)); if (state->init_ret != S_OK) { if (!ao->probing) MP_ERR(ao, "Received failure from audio thread\n"); uninit(ao); return -1; } wasapi_receive_proxies(state); MP_DBG(ao, "Init wasapi done\n"); return 0; }
HRESULT MachineToken::abandon(AutoCaller &aAutoCaller) { /* have to release the AutoCaller before calling uninit(), self-deadlock */ aAutoCaller.release(); /* uninit does everything we need */ uninit(true); return S_OK; }
int main() { init(); while (step()) ; for (int i = 0; i < 5; i++) { printf("%d", strip[i + 1000 * 500]); } uninit(); }
void LocalHttpServer::stop(void) { if (m_spP2pInterface.get()) { m_spP2pInterface->uninit_p2p_system(); } uninit(); }
// // This function is called to init the video driver for specific mode // static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { int32_t req_w = width;// (d_width > 0 ? d_width : width); int32_t req_h = height;// (d_height > 0 ? d_height : height); uint16_t vid_mode = 0; int32_t req_bpp; uint32_t accflags; if( mp_msg_test(MSGT_VO,MSGL_V) ) mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height, d_width, d_height, flags, title, format); //Only RGB modes supported if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {assert(0);return -1;} req_bpp = IMGFMT_BGR_DEPTH(format); if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {assert(0);return-1;} if(!force_vm) { if ( mp_msg_test(MSGT_VO,MSGL_V) ) { mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n"); mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp); } vid_mode=find_best_svga_mode(req_w,req_h,req_bpp); if(vid_mode==0) return 1; modeinfo=vga_getmodeinfo(vid_mode); }else{//force_vm vid_mode=force_vm; if(vga_hasmode(vid_mode) == 0){ mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable, vid_mode,vga_getmodename(vid_mode)); return 1; //error; } modeinfo=vga_getmodeinfo(vid_mode); if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ){ mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall, vid_mode,vga_getmodename(vid_mode)); return 1; } } mode_bpp=bpp_from_vminfo(modeinfo); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode, vid_mode,modeinfo->width,modeinfo->height,mode_bpp); if (vga_setmode(vid_mode) == -1) { mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode); uninit(); return 1; // error } /* set 332 palette for 8 bpp */ if(mode_bpp==8){ int i; for(i=0; i<256; i++) vga_setpalette(i, ((i>>5)&7)*9, ((i>>2)&7)*9, (i&3)*21); }
ErrVal ReadBitstreamFile::destroy() { AOT_DBG( m_cFile.is_open() ); RNOK( uninit() ); delete this; return Err::m_nOK; }
void CFtpSocket::closeSocket() { if( INVALID_SOCKET != m_Sock ) { closesocket( m_Sock ); m_Sock = INVALID_SOCKET; } uninit(); }
static int _restart() { // report to the SCM that we're about to start utils_trace("Re-starting PMC Serial Port Access Coordinator Version 1.0...\n"); uninit(); init(); utils_trace("PMC Serial Port Access Coordinator Version 1.0 re-started...\n"); return 1; }
// FUNCTION: reset() // Initializes data members that are serialized. void CvRandom::reset(unsigned long long ullSeed) { //-------------------------------- // Uninit class uninit(); m_ullRandomSeed = ullSeed; m_ulResetCount++; }
CAppManConnectController::~CAppManConnectController() { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__); uninit(); mpConnection->disconnect(); delete mpConnection; delete mpClient; delete mpCore; }
void VBoxVetoEvent::FinalRelease() { if (m) { uninit(); delete m; m = NULL; } BaseFinalRelease(); }
Kinect::~Kinect() { uninit(); DeleteCriticalSection(&_csVideo); DeleteCriticalSection(&_csDepth); DeleteCriticalSection(&_csSkeleton); CloseHandle(_nextVideoFrameEvent); CloseHandle(_nextDepthFrameEvent); CloseHandle(_nextSkeletonEvent); CloseHandle(_nuiProcessStop); }
CAppManConnectController::~CAppManConnectController() { LOG4CPLUS_TRACE(msLogger,"~CAppManConnectController()"); uninit(); mpConnection->disconnect(); delete mpConnection; delete mpClient; delete mpCore; }
void VBoxEvent::FinalRelease() { if (m) { uninit(); delete m; m = 0; BaseFinalRelease(); } }
void VBoxVetoEvent::FinalRelease() { if (m) { uninit(); delete m; m = 0; } VBoxEvent::FinalRelease(); }
static void __exit mtk_fm_remove(void) { int ret = 0; ret = uninit(&op); if(ret){ FM_LOG_ALT(D_INIT,"%s, FM uninit failed\n", __func__); } FM_LOG_NTC(D_INIT,"%s, FM remove ok\n", __func__); return; }
void ProgressProxy::FinalRelease() { uninit(); mfMultiOperation = false; muOtherProgressStartWeight = 0; muOtherProgressWeight = 0; muOtherProgressStartOperation = 0; BaseFinalRelease(); }
bool CFtpSocket::connectTo( const char* serverAddr, int serverPort ) { assert( m_Sock == INVALID_SOCKET ); m_Sock = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED ); if( INVALID_SOCKET == m_Sock ) { //CLogger::getInst()<<_T("建立侦听端口失败!错误号:") // << WSAGetLastError()<<_T("\n"); uninit(); return false; } memset( &m_InternetAddr, 0, sizeof( sockaddr_in ) ); m_InternetAddr.sin_family = AF_INET; m_InternetAddr.sin_addr.s_addr = inet_addr( serverAddr ); m_InternetAddr.sin_port = htons( serverPort ); //CLogger::getInst()<<_T("连接服务器...\n"); if( m_InternetAddr.sin_addr.s_addr == INADDR_NONE ) { //CLogger::getInst()<<_T("启用DNS解析...\n"); LPHOSTENT lpHostent = gethostbyname( serverAddr ); if( NULL == lpHostent ) { //CLogger::getInst()<<_T("无法解析服务器地址!")<< "错误号:" << WSAGetLastError() << "\n"; return false; } else { m_InternetAddr.sin_addr.s_addr = ((in_addr*)lpHostent->h_addr)->s_addr; //char* IP = inet_ntoa(*((in_addr*)lpHostent->h_addr)); //CLogger::getInst()<<_T("解析结果:")<<IP<<std::endl; } } int err; err = connect( m_Sock, (const sockaddr*)&m_InternetAddr, sizeof(sockaddr_in) ); if( SOCKET_ERROR == err ) { //CLogger::getInst()<<_T("无法连接到服务器!")<< "错误号:" << WSAGetLastError() << "\n"; //int nn = WSAGetLastError(); return false; } //CLogger::getInst()<<_T("连接服务器:[")<<serverAddr<<_T(":")\ // <<serverPort<<_T("]成功!\n"); return true; }
/** init() Initalises the parameters of a class instance. This must be called before use @param n_ The size of the data windows to be processed @param k_ The number of outputs wanted (autocorr size = n_ + k_). Set k_ = 0, to get default n_/2 @param rate_ The sampling rate of the incoming signal to process @param threshold_ The ratio of highest peak to the first peak allowed to be chosen */ void MyTransforms::init(int n_, int k_, double rate_, /*float threshold_, */bool equalLoudness_, int numHarmonics_) { const int myFFTMode = FFTW_ESTIMATE; //const int myFFTMode = FFTW_MEASURE; //const int myFFTMode = FFTW_PATIENT; uninit(); if(k_ == 0) k_ = (n_ + 1) / 2; n = n_; k = k_; size = n + k; rate = rate_; //_threshold = threshold_; equalLoudness = equalLoudness_; numHarmonics = numHarmonics_; dataTemp = (float*)fftwf_malloc(sizeof(float) * n); dataTime = (float*)fftwf_malloc(sizeof(float) * n); dataFFT = (float*)fftwf_malloc(sizeof(float) * n); autocorrTime = (float*)fftwf_malloc(sizeof(float) * size); autocorrFFT = (float*)fftwf_malloc(sizeof(float) * size); //storeFFT = (float*)fftwf_malloc(sizeof(float) * size); //equalLoudnessTable = (float*)fftwf_malloc(sizeof(float) * n); hanningCoeff = (float*)fftwf_malloc(sizeof(float) * n); planAutocorrTime2FFT = fftwf_plan_r2r_1d(size, autocorrTime, autocorrFFT, FFTW_R2HC, myFFTMode); planAutocorrFFT2Time = fftwf_plan_r2r_1d(size, autocorrFFT, autocorrTime, FFTW_HC2R, myFFTMode); planDataTime2FFT = fftwf_plan_r2r_1d(n, dataTime, dataFFT, FFTW_R2HC, myFFTMode); planDataFFT2Time = fftwf_plan_r2r_1d(n, dataFFT, dataTime, FFTW_HC2R, myFFTMode); //??? harmonicsAmpLeft = (float*)fftwf_malloc(numHarmonics * sizeof(float)); harmonicsPhaseLeft = (float*)fftwf_malloc(numHarmonics * sizeof(float)); harmonicsAmpCenter = (float*)fftwf_malloc(numHarmonics * sizeof(float)); harmonicsPhaseCenter = (float*)fftwf_malloc(numHarmonics * sizeof(float)); harmonicsAmpRight = (float*)fftwf_malloc(numHarmonics * sizeof(float)); harmonicsPhaseRight = (float*)fftwf_malloc(numHarmonics * sizeof(float)); //storeFFTAmp1 = (float*)malloc(n/2 * sizeof(float)); //storeFFTAmp2 = (float*)malloc(n/2 * sizeof(float)); freqPerBin = rate / double(size); //buildEqualLoudnessTable(50.0); //init hanningCoeff. The hanning windowing function hanningScalar = 0; for(int j=0; j<n; j++) { hanningCoeff[j] = (1.0 - cos(double(j+1) / double(n+1) * twoPI)) / 2.0; hanningScalar += hanningCoeff[j]; } hanningScalar /= 2; //to normalise the FFT coefficients we divide by the sum of the hanning window / 2 fastSmooth = new fast_smooth(n/8); //printf("fast_smooth size = %d\n", n/8); beenInit = true; }
static int init(struct ao *ao) { MP_DBG(ao, "Init wasapi\n"); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); struct wasapi_state *state = ao->priv; state->log = ao->log; if(!wasapi_fill_VistaBlob(state)) MP_WARN(ao, "Error loading thread priority functions\n"); state->hInitDone = CreateEventW(NULL, FALSE, FALSE, NULL); state->hWake = CreateEventW(NULL, FALSE, FALSE, NULL); if (!state->hInitDone || !state->hWake) { MP_ERR(ao, "Error creating events\n"); uninit(ao); return -1; } state->init_ret = E_FAIL; state->hAudioThread = CreateThread(NULL, 0, &AudioThread, ao, 0, NULL); if (!state->hAudioThread) { MP_ERR(ao, "Failed to create audio thread\n"); uninit(ao); return -1; } WaitForSingleObject(state->hInitDone, INFINITE); /* wait on init complete */ SAFE_RELEASE(state->hInitDone,CloseHandle(state->hInitDone)); if (state->init_ret != S_OK) { if (!ao->probing) MP_ERR(ao, "Received failure from audio thread\n"); uninit(ao); return -1; } wasapi_setup_proxies(state); MP_DBG(ao, "Init wasapi done\n"); return 0; }
Direct3DBlitter::~Direct3DBlitter() { uninit(); if (d3d) d3d->Release(); if (d3d9handle) FreeLibrary(d3d9handle); QSettings settings; settings.beginGroup("direct3dblitter"); settings.setValue("adapterIndex", adapterIndex); settings.endGroup(); }
static void parent_signal_handler(int sig) { switch(sig) { case SIGCHLD: zabbix_log( LOG_LEVEL_WARNING, "One child process died. Exiting ..."); uninit(); exit( FAIL ); break; default: child_signal_handler(sig); } }
void Tcp::loop() { if(init()) { while(_running) { //do something _tcpnet->runRecvMsg(); System::Sleep(50); } } uninit(); }
/** Forks things. @return 0 if successful and -1 otherwise. **/ int init_fork(void) { /* Creates a process monitor to avoid accidental daemonization. */ const pid_t child_pid = fork(); if (child_pid == -1) { probno = log_error(FORK_PROBLEM); return -1; } else { pid = getpid(); if (child_pid == 0) {//child shm_attach(); /* Synchronizes with the parent process. */ while (shared.pids[0] != pid); return NO_PROBLEM; } else {//parent *shared.ppid = pid; shared.pids[0] = child_pid; /* Prevents defunct processes from appearing. */ signal(SIGCHLD, SIG_IGN); while (*shared.state != HAD_ENOUGH) { napms(NAP_RESOLUTION / frame_rate); } do { bool done_quitting = TRUE; for (int save = 0; save < cfg_saves; save++) { if (shared.pids[save] != 0) { done_quitting = FALSE; } } if (done_quitting) break; napms(NAP_RESOLUTION / frame_rate); } while (TRUE); uninit(TRUE); exit(NO_PROBLEM); } } return 0; }
STDMETHODIMP GuestDirectory::Close(void) { #ifndef VBOX_WITH_GUEST_CONTROL ReturnComNotImplemented(); #else LogFlowThisFuncEnter(); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AssertPtr(mData.mSession); int rc = mData.mSession->directoryRemoveFromList(this); AssertRC(rc); HRESULT hr = S_OK; int guestRc; rc = mData.mProcessTool.Terminate(30 * 1000, &guestRc); if (RT_FAILURE(rc)) { switch (rc) { case VERR_GSTCTL_GUEST_ERROR: hr = GuestProcess::setErrorExternal(this, guestRc); break; case VERR_NOT_SUPPORTED: /* Silently skip old Guest Additions which do not support killing the * the guest directory handling process. */ break; default: hr = setError(VBOX_E_IPRT_ERROR, tr("Terminating open guest directory \"%s\" failed: %Rrc"), mData.mName.c_str(), rc); break; } } /* * Release autocaller before calling uninit. */ autoCaller.release(); uninit(); LogFlowThisFunc(("Returning rc=%Rrc\n", rc)); return hr; #endif /* VBOX_WITH_GUEST_CONTROL */ }
// ignore parameters in this sample service void CSpacService :: Run(DWORD, LPTSTR *) { if (g_SingleInstanceObj.IsAnotherInstanceRunning()){ utils_error("Another PMCSpac Daemon instance is already running.\n"); return; } // report to the SCM that we're about to start utils_trace("Starting PMC Serial Port Access Coordinator Version 1.0...\n"); ReportStatus(SERVICE_START_PENDING); m_hStop = ::CreateEvent(0, FALSE, FALSE, 0); SECURITY_ATTRIBUTES sd; ZeroMemory(&sd, sizeof(sd)); sd.nLength = sizeof(sd); m_hRestart = ::CreateEvent(&sd, FALSE, FALSE, SPAC_RESET_EVENT); HANDLE handles[2]; handles[0] = m_hStop; handles[1] = m_hRestart; // You might do some more initialization here. // Parameter processing for instance ... utils_trace("PMC Serial Port Access Coordinator Version 1.0 started...\n"); init(); // enter main-loop // If the Stop() method sets the event, then we will break out of // this loop. // report SERVICE_RUNNING immediately before you enter the main-loop // DON'T FORGET THIS! ReportStatus(SERVICE_RUNNING); bool bStop = false; while(!bStop){ switch(MsgWaitForMultipleObjects(2,handles,false,INFINITE,QS_ALLEVENTS) ){ case WAIT_OBJECT_0: bStop = true; break; case WAIT_OBJECT_0 + 1: _restart(); break; case WAIT_OBJECT_0 + 2: MSG msg; while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ TranslateMessage(&msg); DispatchMessage(&msg); break; } } } if( m_hStop ) ::CloseHandle(m_hStop); uninit(); ReportStatus(SERVICE_STOPPED); }
/* * Entry point */ int main(int argc, char** argv) { try { /* Initialize the GLUT library. */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowPosition(5, 5); glutInitWindowSize(WIDTH, HEIGHT); /* Create main window and set callbacks. */ glutCreateWindow(TITLE); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(myKeyboard); glutMouseFunc(myMouse); // uloha 6 if (spinFlag) { glutTimerFunc(33, FuncTimerCallback, 0); } createMenu(); // load the pointers to OpenGL functions (only needed in MS Windows) glewInit(); if (!GLEW_VERSION_3_0) { fprintf(stderr, "OpenGL 3.0 or higher not available\n"); return 1; } // Init context and profile glutInitContextVersion(MAJOR_VERSION, MINOR_VERSION); if ((MAJOR_VERSION >= 3) && (MINOR_VERSION >= 2)) glutInitContextProfile(PROFILE); // core or compatibiliy, as defined in OpenGL 3.2 init(); glutMainLoop(); } catch (const OpenGlException& ex) { std::cerr << "OpenGL reported an error: " << ex.GetGlError() << std::endl; } uninit(); system("PAUSE"); return 0; }