BOOL CEffectManager::ForcedEndEffect(HEFFPROC handle) { if(m_bInited == FALSE) return TRUE; ASSERT(handle); CEffect* pEffect = GetEffect(handle); if(pEffect == NULL) return TRUE; EFFECTPARAM param; param.Copy(pEffect->GetEffectParam()); DWORD Key = (DWORD)pEffect->GetEffectID(); DWORD NextEffect = pEffect->GetNextEffect(); DWORD RefCount = pEffect->GetRefCount(); int EffectKind = pEffect->GetEffectKind(); pEffect->DecRefCount(); if(pEffect->GetRefCount() > 0) return FALSE; EndProcess(pEffect); // if(NextEffect) // { // HEFFPROC proc = StartEffectProcess(EffectKind,NextEffect,¶m,Key,RefCount); // CEffect* pNextEffect = GetEffect(proc); //// ASSERT(pNextEffect); // if(pNextEffect) // pNextEffect->SetEndFlag(); // } // 080425 NYJ --- NextEffect가 여러개인 경우 루프를 돌면서 모두 중단시킴 int nCnt = 0; while(NextEffect) { if( 99 < nCnt) break; HEFFPROC proc = StartEffectProcess(EffectKind,NextEffect,¶m,Key,RefCount); NextEffect = 0; CEffect* pNextEffect = GetEffect(proc); if(pNextEffect) { EndProcess(pNextEffect); NextEffect = pNextEffect->GetNextEffect(); } nCnt++; } return TRUE; }
opzThread::~opzThread() { TerminateThread(_hThread, 0); EndProcess(); if (_hThread) CloseHandle(_hThread); }
void CEffectManager::OnEffectTimeOut(HEFFPROC handle) { ASSERT(handle); CEffect* pEffect = GetEffect(handle); if(pEffect == NULL) return; BOOL bEndFlag = pEffect->IsEndFlag(); if(pEffect->IsRepeatEffect() && bEndFlag == FALSE) ResetProcess(pEffect); else { EFFECTPARAM param; param.Copy(pEffect->GetEffectParam()); param.m_DamageRate = 0; DWORD Key = (DWORD)pEffect->GetEffectID(); DWORD NextEffect = pEffect->GetNextEffect(); DWORD RefCount = pEffect->GetRefCount(); int EffectKind = pEffect->GetEffectKind(); EndProcess(pEffect); if(NextEffect) { HEFFPROC proc = StartEffectProcess(EffectKind,NextEffect,¶m,Key,RefCount); if(bEndFlag) { SetEffectEndFlag(proc); } } } }
Parser::~Parser() { // para dar tempo de terminar algum processo pendente sleep(2); EndProcess(); }
void Opc_client_ae_DriverThread::TerminateProtocol() // parent requests the thread close { IT_IT("Opc_client_ae_DriverThread::TerminateProtocol"); EndProcess(nIndex); //stop the child process fRequestHalt = true; };
void GatewayInProcess::ExecuteRecv(){ char received[RECEIVE_MAX_MSG]; char lenRead[HEADER_LEN+1]; int lenght_received; string read; while( true ){ lenght_received = HEADER_LEN; memset( lenRead , 0 , sizeof(lenRead)); if(!m_server->Receive(m_ServerChild, lenRead, &lenght_received) ) { EndProcess( "ExecuteRecv ERR: 0" ); SetEvent(m_parallel[3]); return; } if( lenght_received != 4 ) { EndProcess( "read Lenght diff from ExecuteRecv" ); SetEvent(m_parallel[3]); return; } lenght_received = atoi(lenRead); memset( received , 0 , sizeof(received)); if(!m_server->Receive(m_ServerChild, received, &lenght_received) ) { EndProcess( "ExecuteRecv ERR: 1" ); SetEvent(m_parallel[3]); return; } read = lenRead; read += received; if( !g_running ) break; WaitForSingleObject(m_RecvMutex, INFINITE); //Mutex Lock m_QRecv.push( read ); ReleaseSemaphore(m_RecvSem,1, NULL); ReleaseMutex(m_RecvMutex); //Mutex Unlock } EndProcess( "" ); //ReleaseSemaphore(m_RecvSem,1, NULL); SetEvent(m_parallel[3]); }
void GatewayInProcess::ExecuteSend(){ string read; while( true ) { if( !g_running ) break; WaitForSingleObject(m_SendSem,INFINITE); //Wait for producer; WaitForSingleObject(m_SendMutex, INFINITE); //Mutext Lock while(m_QSend.size()>0){ read = m_QSend.front(); m_QSend.pop(); if( !m_server->Send(m_ServerChild , read.c_str() , read.length()) ){ EndProcess("Message cannot be sended"); SetEvent(m_parallel[2]); ReleaseMutex(m_SendMutex); //Mutex Unlock return; } } ReleaseMutex(m_SendMutex); //Mutex Unlock } EndProcess(""); SetEvent(m_parallel[2]); }
void CEffectManager::RemoveAllEffect() { m_EffectProcessTable.SetPositionHead(); for(CEffect* effect = (CEffect*)m_EffectProcessTable.GetData(); 0 <effect; effect = (CEffect*)m_EffectProcessTable.GetData()) { EndProcess( effect); } m_EffectProcessTable.RemoveAll(); }
void GatewayInProcess::ExecuteUpdateInterface(){ char msg[100]; while( true ) { if( !g_running ) break; sprintf(msg , "%d" , this->GetSizeRecvList() ); GatewayInProperties::getInstance()->ShowTPIn(msg); sprintf(msg , "%d" , this->GetSizeSendList() ); GatewayInProperties::getInstance()->ShowTPOut(msg); sprintf(msg , "%d" , g_nThreads ); GatewayInProperties::getInstance()->ShowNProc(msg); Sleep(1000); } EndProcess( "" ); SetEvent(m_parallel[0]); }
//ExecuteProcessMEssage void GatewayInProcess::ExecuteProcessMessage(){ string read; while(true){ if( !g_running ) break; WaitForSingleObject(m_RecvSem,INFINITE); //Wait for producer; WaitForSingleObject(m_RecvMutex, INFINITE); //Mutext Lock while(m_QRecv.size()>0){ read = m_QRecv.front(); m_QRecv.pop(); ProcessIso2DB *proc = new ProcessIso2DB(this, read); CreateThread(NULL, 0, ExecuteProcessIso2DBThread, proc, 0, 0); } ReleaseMutex(m_RecvMutex); //Mutex Unlock } //ReleaseMutex(m_RecvMutex); //Mutex Unlock EndProcess( "" ); //escondido no ExecuteProcessIso2DBThread SetEvent(m_parallel[1]); }
extern "C" int sfkl_Decode(const char *InFileName, const char *ReqOutFileName) { char OutFileName[MAX_FILEPATH]; // File name for current output file int NumLoops; // Number of loops before screen update etc. BLOCK_DATA Blk; memset(&Blk, 0, sizeof(Blk)); V2_FILEHEADER *FileHeader = &Blk.FileHeader; // NB: We keep 2 buffers with pointers in Blk->SrcBuf and Blk->DstBuf // Generally we process from SrcBuf to DstBuf then swap the pointers, // so that current data is always at SrcBuf // NB: On MacOS/GNU C, the following allocation of Zbuf1 and Zbuf2 causes "segmentation fault" // BYTE Zbuf1[ZBUF_SIZE]; // Buffer1 // BYTE Zbuf2[ZBUF_SIZE]; // Buffer2 // so instead... #if 0 static BYTE Zbuf1[ZBUF_SIZE]; // Buffer1 static BYTE Zbuf2[ZBUF_SIZE]; // Buffer2 #else if (Zbuf1 == NULL) Zbuf1 = (BYTE *) calloc(ZBUF_SIZE, sizeof(BYTE)); if (Zbuf2 == NULL) Zbuf2 = (BYTE *) calloc(ZBUF_SIZE, sizeof(BYTE)); if (Zbuf1 == NULL || Zbuf2 == NULL) return EndProcess(SFARKLIB_ERR_MALLOC); #endif Blk.SrcBuf = (AWORD *) Zbuf1; // Point to Zbuf1 Blk.DstBuf = (AWORD *) Zbuf2; // Point to Zbuf2 // Initialisation... BioDecompInit(); // Initialise bit i/o LPCinit(); // Init LPC GlobalErrorFlag = SFARKLIB_SUCCESS; // Open input (.sfArk) file and read the header... OpenInputFile(InFileName); if (GlobalErrorFlag) return EndProcess(GlobalErrorFlag); // Something went wrong? ReadHeader(FileHeader, Zbuf1, ZBUF_SIZE); if (GlobalErrorFlag) return EndProcess(GlobalErrorFlag); // Something went wrong? if (ReqOutFileName == NULL) // If no output filename requested ReqOutFileName = FileHeader->FileName; if ((FileHeader->Flags & FLAGS_License) != 0) // License file exists? { if (ExtractTextFile(&Blk, FLAGS_License) == 0) return EndProcess(GlobalErrorFlag); } if ((FileHeader->Flags & FLAGS_Notes) != 0) // Notes file exists? { if (ExtractTextFile(&Blk, FLAGS_Notes) == 0) return EndProcess(GlobalErrorFlag); } // Use original file extension for OutFileName... strncpy(OutFileName, ReqOutFileName, sizeof(OutFileName)); // Copy output filename OpenOutputFile(OutFileName); // Create the main output file... // Set the decompression parameters... switch (FileHeader->CompMethod) // Depending on compression method that was used... { case COMPRESSION_v2Max: { //msg("Compression: Max\n"); Blk.ReadSize = 4096; Blk.MaxLoops = 3; Blk.MaxBD4Loops = 5; Blk.nc = 128; Blk.WinSize = OPTWINSIZE; NumLoops = 2 * 4096 / Blk.ReadSize; break; } case COMPRESSION_v2Standard: { //printf("Compression: Standard\n"); Blk.MaxLoops = 3; Blk.MaxBD4Loops = 3; Blk.ReadSize = 4096; Blk.nc = 8; Blk.WinSize = OPTWINSIZE; NumLoops = 50 * 4096 / Blk.ReadSize; break; } case COMPRESSION_v2Fast: { //printf("Compression: Fast\n"); Blk.MaxLoops = 20; Blk.MaxBD4Loops = 20; Blk.ReadSize = 1024; Blk.WinSize = OPTWINSIZE; NumLoops = 300 * 4096 / Blk.ReadSize; break; } case COMPRESSION_v2Turbo: { //printf("Compression: Turbo\n"); Blk.MaxLoops = 3; Blk.MaxBD4Loops = 0; Blk.ReadSize = 4096; Blk.WinSize = OPTWINSIZE << 3; NumLoops = 400 * 4096 / Blk.ReadSize; break; } default: { sprintf(MsgTxt, "Unknown Compression Method: %d%s", FileHeader->CompMethod, CorruptedMsg); GlobalErrorFlag = SFARKLIB_ERR_INCOMPATIBLE; msg(MsgTxt, MSG_PopUp); return EndProcess(GlobalErrorFlag); } } // Process the main file... Blk.FileSection = PRE_AUDIO; // We start with pre-audio data ULONG ProgressUpdateInterval = Blk.FileHeader.OriginalSize / 100; // Calculate progress update ULONG NextProgressUpdate = ProgressUpdateInterval; int ProgressPercent = 0; UpdateProgress(0); //int BlockNum = 0; for (Blk.FileSection = PRE_AUDIO; Blk.FileSection != FINISHED; ) { for (int BlockCount = 0; BlockCount < NumLoops && Blk.FileSection != FINISHED; BlockCount++) { //printf("Block: %d\n", ++BlockNum); ProcessNextBlock(&Blk); while (Blk.TotBytesWritten >= NextProgressUpdate) // Further 1% done since last UpdateProgress? { UpdateProgress(++ProgressPercent); NextProgressUpdate += ProgressUpdateInterval; } if (GlobalErrorFlag) return EndProcess(GlobalErrorFlag); } // CheckForCancel(); if (GlobalErrorFlag) return EndProcess(GlobalErrorFlag); } if (ProgressPercent != 100) UpdateProgress(100); // Check the CheckSum... if (Blk.FileCheck != FileHeader->FileCheck) { sprintf(MsgTxt, "CheckSum Fail!%s",CorruptedMsg); msg(MsgTxt, MSG_PopUp); //sprintf(MsgTxt, "Calc check %lx", Blk.FileCheck); //msg(MsgTxt, MSG_PopUp); GlobalErrorFlag = SFARKLIB_ERR_FILECHECK; return EndProcess(GlobalErrorFlag); } sprintf(MsgTxt, "Created %s (%ld kb) successfully.", ReqOutFileName, Blk.TotBytesWritten/1024); msg(MsgTxt, 0); return EndProcess(GlobalErrorFlag); }
// ============================================================== // Extract License & Notes files // These are stored as 4-bytes length, followed by length-bytes of compressed data int ExtractTextFile(BLOCK_DATA *Blk, ULONG FileType) { ULONG n, m; BYTE *zSrcBuf = (BYTE *) Blk->SrcBuf; BYTE *zDstBuf = (BYTE *) Blk->DstBuf; const char *FileExt; if (FileType == FLAGS_License) FileExt = LicenseExt; else if (FileType == FLAGS_Notes) FileExt = NotesExt; else return 0; // NB:Can't use BioReadBuf... aligment problems? Yet it works for ProcessNextBlock() !!?? // Ok, can use ReadInputFile here cause everythjing is whole no. of bytes... //BioReadBuf((BYTE *)&n, sizeof(n)); // Read length of block from file ReadInputFile((BYTE *)&n, sizeof(n)); // Read length of block from file FixEndian(&n, sizeof(n)); // Fix endian if (n <= 0 || n > ZBUF_SIZE) // Check for valid block length { sprintf(MsgTxt, "ERROR - Invalid length for %s file (apparently %ld bytes) %s", FileExt, n, CorruptedMsg); msg(MsgTxt, MSG_PopUp); GlobalErrorFlag = SFARKLIB_ERR_CORRUPT; return 0; } //BioReadBuf(zSrcBuf, n); // Read the block ReadInputFile((BYTE *)zSrcBuf, n); // Read the block m = UnMemcomp(zSrcBuf, n, zDstBuf, ZBUF_SIZE); // Uncompress Blk->FileCheck = adler32(Blk->FileCheck, zDstBuf, m); // Accumulate checksum if (GlobalErrorFlag || m > ZBUF_SIZE) // Uncompressed ok & size is valid? return 0; // Write file - Use original file name plus specified extension for OutFileName... char OutFileName[MAX_FILENAME]; strncpy(OutFileName, Blk->FileHeader.FileName, sizeof(OutFileName)); // copy output filename ChangeFileExt(OutFileName, FileExt, sizeof(OutFileName)); OpenOutputFile(OutFileName); // Create notes / license file WriteOutputFile(zDstBuf, m); // and write to output file CloseOutputFile(); if (FileType == FLAGS_License) { sprintf(MsgTxt, "Created license file: %s", OutFileName); msg(MsgTxt, 0); if (GetLicenseAgreement((const char *)zDstBuf, OutFileName) == 0) { GlobalErrorFlag = SFARKLIB_ERR_LICENSE; return EndProcess(0); } } else if (FileType == FLAGS_Notes) { sprintf(MsgTxt, "Created notes file: %s", OutFileName); msg(MsgTxt, 0); DisplayNotes((const char *)zDstBuf, OutFileName); } return 1; }
VOID WINAPI ServiceHandler(DWORD fdwControl) { switch(fdwControl) { case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_SHUTDOWN: ProcessStarted = FALSE; ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwCurrentState = SERVICE_STOPPED; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; // terminate all processes started by this service before shutdown { for(int i = MAX_NUM_OF_PROCESS - 1 ; i >= 0; i--) { EndProcess(i); delete ProcessNames[i]; } } break; case SERVICE_CONTROL_PAUSE: ServiceStatus.dwCurrentState = SERVICE_PAUSED; break; case SERVICE_CONTROL_CONTINUE: ServiceStatus.dwCurrentState = SERVICE_RUNNING; break; case SERVICE_CONTROL_INTERROGATE: break; default: if(fdwControl>=128&&fdwControl<256) { int nIndex = fdwControl&0x7F; // bounce a single process if(nIndex >= 0 && nIndex < MAX_NUM_OF_PROCESS) { EndProcess(nIndex); StartProcess(nIndex); } // bounce all processes else if(nIndex==127) { for(int i = MAX_NUM_OF_PROCESS-1; i >= 0; i--) { EndProcess(i); } for(int i = 0; i < MAX_NUM_OF_PROCESS; i++) { StartProcess(i); } } } else { char pTemp[121]; sprintf_s(pTemp, "Unrecognized opcode %d\n", fdwControl); WriteLog(pLogFile, pTemp); } }; if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { long nError = GetLastError(); char pTemp[121]; sprintf_s(pTemp, "SetServiceStatus failed, error code = %d\n", nError); WriteLog(pLogFile, pTemp); } }
/** * Adds a radio distortion to the input buffer if the radio effect is enabled. * * @param InputProcessParameterCount Number of elements in pInputProcessParameters. * @param pInputProcessParameters Input buffer containing audio samples. * @param OutputProcessParameterCount Number of elements in pOutputProcessParameters. * @param pOutputProcessParameters Output buffer, which is not touched by this xAPO. * @param IsEnabled true if this effect is enabled; false, otherwise. */ STDMETHOD_( void, Process )( UINT32 InputProcessParameterCount, const XAPO_PROCESS_BUFFER_PARAMETERS *pInputProcessParameters, UINT32 OutputProcessParameterCount, XAPO_PROCESS_BUFFER_PARAMETERS *pOutputProcessParameters, BOOL IsEnabled ) { // Verify several condition based on the registration // properties we used to create the class. check( IsLocked() ); check( InputProcessParameterCount == 1 ); check( OutputProcessParameterCount == 1 ); check( pInputProcessParameters[0].pBuffer == pOutputProcessParameters[0].pBuffer ); // Check the global volume multiplier because this effect // will continue to play if the editor loses focus. if (IsEnabled && FApp::GetVolumeMultiplier() != 0.0f) { FAudioRadioEffect* RadioParameters = ( FAudioRadioEffect* )BeginProcess(); check( RadioParameters ); // The total sample size must account for multiple channels. const uint32 SampleSize = pInputProcessParameters[0].ValidFrameCount * WaveFormat.nChannels; const float ChebyshevPowerMultiplier = Radio_ChebyshevPowerMultiplier->GetValueOnAnyThread(); const float ChebyshevPower = Radio_ChebyshevPower->GetValueOnAnyThread(); const float ChebyshevCubedMultiplier = Radio_ChebyshevCubedMultiplier->GetValueOnAnyThread(); const float ChebyshevMultiplier = Radio_ChebyshevMultiplier->GetValueOnAnyThread(); // If we have a silent buffer, then allocate the samples. Then, set the sample values // to zero to avoid getting NANs. Otherwise, the user may hear an annoying popping noise. if( pInputProcessParameters[0].BufferFlags == XAPO_BUFFER_VALID ) { float* SampleData = ( float* )pInputProcessParameters[0].pBuffer; // Process each sample one at a time for( uint32 SampleIndex = 0; SampleIndex < SampleSize; ++SampleIndex ) { float Sample = SampleData[SampleIndex]; // Early-out of processing if the sample is zero because a zero sample // will still create some static even if no audio is playing. if( Sample == 0.0f ) { continue; } // Waveshape it const float SampleCubed = Sample * Sample * Sample; Sample = ( ChebyshevPowerMultiplier * FMath::Pow( Sample, ChebyshevPower ) ) - ( ChebyshevCubedMultiplier * SampleCubed ) + ( ChebyshevMultiplier * Sample ); // Again with the bandpass Sample = GFinalBandPassFilter.Process( Sample ); // Store the value after done processing SampleData[SampleIndex] = Sample; } EndProcess(); } } }
////////////////////////////////////////////////////////////////////// // // This routine responds to events concerning your service, like start/stop // VOID WINAPI XYNTServiceHandler(DWORD fdwControl) { switch(fdwControl) { case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_SHUTDOWN: serviceStatus.dwWin32ExitCode = 0; serviceStatus.dwCurrentState = SERVICE_STOPPED; serviceStatus.dwCheckPoint = 0; serviceStatus.dwWaitHint = 0; // terminate all processes started by this service before shutdown { for(int i=nMaxProcCount-1;i>=0;i--) { EndProcess(i); } if (!SetServiceStatus(hServiceStatusHandle, &serviceStatus)) { long nError = GetLastError(); char pTemp[121]; sprintf(pTemp, "SetServiceStatus failed, error code = %d", nError); WriteLog(pTemp); } } return; case SERVICE_CONTROL_PAUSE: serviceStatus.dwCurrentState = SERVICE_PAUSED; break; case SERVICE_CONTROL_CONTINUE: serviceStatus.dwCurrentState = SERVICE_RUNNING; break; case SERVICE_CONTROL_INTERROGATE: break; default: // bounce processes started by this service if(fdwControl>=128&&fdwControl<256) { int nIndex = fdwControl&0x7F; // bounce a single process if(nIndex>=0&&nIndex<nMaxProcCount) { EndProcess(nIndex); StartProcess(nIndex); } // bounce all processes else if(nIndex==127) { for(int i=nMaxProcCount-1;i>=0;i--) { EndProcess(i); } for(int i=0;i<nMaxProcCount;i++) { StartProcess(i); } } } else { long nError = GetLastError(); char pTemp[121]; sprintf(pTemp, "Unrecognized opcode %d", fdwControl); WriteLog(pTemp); } }; if (!SetServiceStatus(hServiceStatusHandle, &serviceStatus)) { long nError = GetLastError(); char pTemp[121]; sprintf(pTemp, "SetServiceStatus failed, error code = %d", nError); WriteLog(pTemp); } }