int uhAsyncDataTest(UrlHandlerParam* param) { int ret = FLAG_DATA_STREAM | FLAG_TO_FREE; HANDLER_DATA* hdata = (HANDLER_DATA*)param->hs->ptr; if (param->pucBuffer) { if (!hdata) { // first invoke hdata = param->hs->ptr = calloc(1, sizeof(HANDLER_DATA)); ThreadCreate(&hdata->thread, WriteContent, hdata); param->dataBytes = 0; } else { if (hdata->state == 1) { // done ret = 0; } else if (ThreadWait(hdata->thread, 10, 0)) { // data not ready param->dataBytes = 0; } else { // data ready strcpy(param->pucBuffer, hdata->result); param->dataBytes = strlen(param->pucBuffer); hdata->state = 1; } } } else { // cleanup ret = 0; } param->fileType=HTTPFILETYPE_TEXT; return ret; }
void cleanUp() { threadRun = false; ThreadWait(t); ThreadDestroy(t); MutexDestroy(mutex); getClientSocket().close(); Net::cleanup(); }
void Decoder::abort(FrameQueue *fq) { queue->abort(); fq->signal(); ThreadWait(decoder_tid, NULL); free(decoder_tid); decoder_tid = NULL; queue->flush(); }
void VDAudioOutputDirectSoundW32::Shutdown() { mMutex.Lock(); mThreadState = kThreadStateExit; mMutex.Unlock(); mUpdateEvent.signal(); ThreadWait(); }
void VDFileAsync9x::FastWriteEnd() { FastWrite(NULL, mSectorSize - 1); mState = kStateFlush; mWriteOccurred.signal(); ThreadWait(); if (mpError) ThrowError(); }
void VDFileAsyncNT::FastWriteEnd() { if (mhFileFast != INVALID_HANDLE_VALUE) { FastWrite(NULL, mSectorSize - 1); mState = kStateFlush; mWriteOccurred.signal(); ThreadWait(); } if (mpError) ThrowError(); }
//--------------------------------------------------------------------------- longword TSnapThread::WaitFor(uint64_t Timeout) { if (Started) { if (!Closed) return ThreadWait(Timeout); else return WAIT_OBJECT_0; } else return WAIT_OBJECT_0; }
void VDCallbackTimer::Shutdown() { if (isThreadActive()) { mbExit = true; msigExit.signal(); ThreadWait(); } if (mTimerAccuracy) { timeEndPeriod(mTimerAccuracy); mTimerAccuracy = 0; } }
void VDFileAsync9x::SafeTruncateAndClose(sint64 pos) { if (mhFileSlow != INVALID_HANDLE_VALUE) { FastWrite(NULL, mSectorSize - 1); mState = kStateFlush; mWriteOccurred.signal(); ThreadWait(); Extend(pos); Close(); } }
void VDFileAsync9x::Close() { mState = kStateAbort; mWriteOccurred.signal(); ThreadWait(); if (mhFileSlow != INVALID_HANDLE_VALUE) { CloseHandle(mhFileSlow); mhFileSlow = INVALID_HANDLE_VALUE; } if (mhFileFast != INVALID_HANDLE_VALUE) { CloseHandle(mhFileFast); mhFileFast = INVALID_HANDLE_VALUE; } }
void VDFileAsyncNT::SafeTruncateAndClose(sint64 pos) { if (isThreadAttached()) { mState = kStateAbort; mWriteOccurred.signal(); ThreadWait(); if (mpError) { delete mpError; mpError = NULL; } } if (mhFileSlow != INVALID_HANDLE_VALUE) { Extend(pos); Close(); } }
void VDFileAsyncNT::Close() { mState = kStateAbort; mWriteOccurred.signal(); ThreadWait(); if (mpError) { delete mpError; mpError = NULL; } if (mhFileSlow != INVALID_HANDLE_VALUE) { CloseHandle(mhFileSlow); mhFileSlow = INVALID_HANDLE_VALUE; } if (mhFileFast != INVALID_HANDLE_VALUE) { CloseHandle(mhFileFast); mhFileFast = INVALID_HANDLE_VALUE; } mpBlocks = NULL; }
int WindDecoder::Seek (double pos) { //pos is seconds based. mOperationLock.Lock (); mbQuit = true; mVideoQueue.flush (); mAudioQueue.flush (); DEBUG ("begin wait thread!"); ThreadWait (); DEBUG ("end wait thread!"); mVideoQueue.init (); mAudioQueue.init (); mbQuit = false; if (AvSeekFrame (pos) < 0) { ERROR ("seek fail!"); } else { ThreadExec (); } mOperationLock.Unlock (); return 0; }
int WindDecoder::Stop () { mOperationLock.Lock (); if (mpFormatCtx) { mbQuit = true; mVideoQueue.flush (); mAudioQueue.flush (); DEBUG ("begin wait thread!"); ThreadWait (); DEBUG ("end wait thread!"); if (miVideoStream >= 0) { WARN ("todo:clear video decoder!"); } if (miAudioStream >= 0) { WARN ("todo:clear audio decoder!"); } //mVideoQueue.init (); //mAudioQueue.init (); //mbQuit = false; } mOperationLock.Unlock (); return 0; }
int WindDecoder::Clear () { if (mpFormatCtx) { mbQuit = true; mVideoQueue.flush (); mAudioQueue.flush (); DEBUG ("begin wait thread!"); ThreadWait (); DEBUG ("end wait thread!"); if (miVideoStream >= 0) { WARN ("todo:clear video decoder!"); } if (miAudioStream >= 0) { WARN ("todo:clear audio decoder!"); } av_close_input_file (mpFormatCtx); mpFormatCtx = NULL; miVideoStream = -1; miAudioStream = -1; mVideoQueue.init (); mAudioQueue.init (); mbQuit = false; } return 0; }
VDThread::~VDThread() throw() { if (isThreadAttached()) ThreadWait(); }
void Stop() { mbRunning = false; ThreadWait(); }