Lines Matching refs:mtc
115 CMtCoder *mtc = t->mtCoder; in ThreadFunc2() local
128 RINOK_THREAD(Event_Wait(&mtc->readEvent)) in ThreadFunc2()
132 if (mtc->stopReading) in ThreadFunc2()
134 return Event_Set(&mtc->readEvent) == 0 ? SZ_OK : SZ_ERROR_THREAD; in ThreadFunc2()
137 res = MtProgress_GetError(&mtc->mtProgress); in ThreadFunc2()
145 size = mtc->blockSize; in ThreadFunc2()
146 if (mtc->inStream) in ThreadFunc2()
150 t->inBuf = (Byte *)ISzAlloc_Alloc(mtc->allocBig, mtc->blockSize); in ThreadFunc2()
156 res = FullRead(mtc->inStream, t->inBuf, &size); in ThreadFunc2()
157 readProcessed = mtc->readProcessed + size; in ThreadFunc2()
158 mtc->readProcessed = readProcessed; in ThreadFunc2()
162 mtc->readRes = res; in ThreadFunc2()
164 MtProgress_SetError(&mtc->mtProgress, res); in ThreadFunc2()
167 finished = (size != mtc->blockSize); in ThreadFunc2()
172 readProcessed = mtc->readProcessed; in ThreadFunc2()
173 rem = mtc->inDataSize - (size_t)readProcessed; in ThreadFunc2()
176 inData = mtc->inData + (size_t)readProcessed; in ThreadFunc2()
178 mtc->readProcessed = readProcessed; in ThreadFunc2()
179 finished = (mtc->inDataSize == (size_t)readProcessed); in ThreadFunc2()
187 if (Semaphore_Wait(&mtc->blocksSemaphore) != 0) in ThreadFunc2()
197 bi = mtc->blockIndex; in ThreadFunc2()
199 if (++mtc->blockIndex >= mtc->numBlocksMax) in ThreadFunc2()
200 mtc->blockIndex = 0; in ThreadFunc2()
205 res = MtProgress_GetError(&mtc->mtProgress); in ThreadFunc2()
212 if (mtc->numStartedThreads < mtc->numStartedThreadsLimit in ThreadFunc2()
213 && mtc->expectedDataSize != readProcessed) in ThreadFunc2()
215 res = MtCoderThread_CreateAndStart(&mtc->threads[mtc->numStartedThreads]); in ThreadFunc2()
217 mtc->numStartedThreads++; in ThreadFunc2()
220 MtProgress_SetError(&mtc->mtProgress, res); in ThreadFunc2()
227 mtc->stopReading = True; in ThreadFunc2()
229 RINOK_THREAD(Event_Set(&mtc->readEvent)) in ThreadFunc2()
236 CriticalSection_Enter(&mtc->cs); in ThreadFunc2()
237 bufIndex = mtc->freeBlockHead; in ThreadFunc2()
238 mtc->freeBlockHead = mtc->freeBlockList[bufIndex]; in ThreadFunc2()
239 CriticalSection_Leave(&mtc->cs); in ThreadFunc2()
241 res = mtc->mtCallback->Code(mtc->mtCallbackObject, t->index, bufIndex, in ThreadFunc2()
242 mtc->inStream ? t->inBuf : inData, size, finished); in ThreadFunc2()
247 MtProgress_SetError(&mtc->mtProgress, res); in ThreadFunc2()
251 CMtCoderBlock *block = &mtc->blocks[bi]; in ThreadFunc2()
258 RINOK_THREAD(Event_Set(&mtc->writeEvents[bi])) in ThreadFunc2()
263 CriticalSection_Enter(&mtc->cs); in ThreadFunc2()
264 wi = mtc->writeIndex; in ThreadFunc2()
266 mtc->writeIndex = (unsigned)(int)-1; in ThreadFunc2()
268 mtc->ReadyBlocks[bi] = True; in ThreadFunc2()
269 CriticalSection_Leave(&mtc->cs); in ThreadFunc2()
279 if (mtc->writeRes != SZ_OK) in ThreadFunc2()
280 res = mtc->writeRes; in ThreadFunc2()
286 res = mtc->mtCallback->Write(mtc->mtCallbackObject, bufIndex); in ThreadFunc2()
289 mtc->writeRes = res; in ThreadFunc2()
290 MtProgress_SetError(&mtc->mtProgress, res); in ThreadFunc2()
294 if (++wi >= mtc->numBlocksMax) in ThreadFunc2()
299 CriticalSection_Enter(&mtc->cs); in ThreadFunc2()
303 mtc->freeBlockList[bufIndex] = mtc->freeBlockHead; in ThreadFunc2()
304 mtc->freeBlockHead = bufIndex; in ThreadFunc2()
307 isReady = mtc->ReadyBlocks[wi]; in ThreadFunc2()
310 mtc->ReadyBlocks[wi] = False; in ThreadFunc2()
312 mtc->writeIndex = wi; in ThreadFunc2()
314 CriticalSection_Leave(&mtc->cs); in ThreadFunc2()
316 RINOK_THREAD(Semaphore_Release1(&mtc->blocksSemaphore)) in ThreadFunc2()
323 CMtCoderBlock *block = &mtc->blocks[wi]; in ThreadFunc2()
350 CMtCoder *mtc = t->mtCoder; in ThreadFunc() local
353 MtProgress_SetError(&mtc->mtProgress, res); in ThreadFunc()
358 unsigned numFinished = (unsigned)InterlockedIncrement(&mtc->numFinishedThreads); in ThreadFunc()
359 if (numFinished == mtc->numStartedThreads) in ThreadFunc()
360 if (Event_Set(&mtc->finishedEvent) != 0) in ThreadFunc()