Lines Matching refs:frt
47 SDLOSXCAGuard* (*GetGuard)(struct S_FileReaderThread *frt);
48 void (*AddReader)(struct S_FileReaderThread *frt);
49 void (*RemoveReader)(struct S_FileReaderThread *frt, AudioFileManager* inItem);
50 int (*TryNextRead)(struct S_FileReaderThread *frt, AudioFileManager* inItem);
64 void (*ReadNextChunk)(struct S_FileReaderThread *frt);
65 int (*StartFixedPriorityThread)(struct S_FileReaderThread *frt);
73 static SDLOSXCAGuard* FileReaderThread_GetGuard(FileReaderThread *frt)
75 return frt->mGuard;
79 static int FileReaderThread_TryNextRead (FileReaderThread *frt, AudioFileManager* inItem)
83 if (frt->mGuard->Try(frt->mGuard, &didLock))
85 /*frt->mFileData.push_back (inItem);*/
87 FileData *i = frt->mFileData;
96 frt->mFileData = newfd;
100 frt->mGuard->Notify(frt->mGuard);
104 frt->mGuard->Unlock(frt->mGuard);
110 static void FileReaderThread_AddReader(FileReaderThread *frt)
112 if (frt->mNumReaders == 0)
114 frt->mThreadShouldDie = 0;
115 frt->StartFixedPriorityThread (frt);
117 frt->mNumReaders++;
120 static void FileReaderThread_RemoveReader (FileReaderThread *frt, AudioFileManager* inItem)
122 if (frt->mNumReaders > 0)
124 int bNeedsRelease = frt->mGuard->Lock(frt->mGuard);
126 /*frt->mFileData.remove (inItem);*/
127 FileData *i = frt->mFileData;
137 frt->mFileData = next;
145 if (--frt->mNumReaders == 0) {
146 frt->mThreadShouldDie = 1;
147 frt->mGuard->Notify(frt->mGuard); /* wake up thread so it will quit */
148 frt->mGuard->Wait(frt->mGuard); /* wait for thread to die */
151 if (bNeedsRelease) frt->mGuard->Unlock(frt->mGuard);
155 static int FileReaderThread_StartFixedPriorityThread (FileReaderThread *frt)
166 result = pthread_create (&pThread, &theThreadAttrs, frt->DiskReaderEntry, frt);
184 relativePriority = frt->mThreadPriority - frt->GetThreadBasePriority(pthread_self());
236 FileReaderThread *frt = (FileReaderThread *)inRefCon;
237 frt->ReadNextChunk(frt);
245 static void FileReaderThread_ReadNextChunk (FileReaderThread *frt)
254 int bNeedsRelease = frt->mGuard->Lock(frt->mGuard);
256 if (frt->mThreadShouldDie) {
257 frt->mGuard->Notify(frt->mGuard);
258 if (bNeedsRelease) frt->mGuard->Unlock(frt->mGuard);
262 /*if (frt->mFileData.empty())*/
263 if (frt->mFileData == NULL)
265 frt->mGuard->Wait(frt->mGuard);
269 if (frt->mThreadShouldDie) {
271 frt->mGuard->Notify(frt->mGuard);
272 if (bNeedsRelease) frt->mGuard->Unlock(frt->mGuard);
276 /*theItem = frt->mFileData.front();*/
277 /*frt->mFileData.pop_front();*/
279 if (frt->mFileData != NULL)
281 FileData *next = frt->mFileData->next;
282 theItem = frt->mFileData->obj;
283 SDL_free(frt->mFileData);
284 frt->mFileData = next;
287 if (bNeedsRelease) frt->mGuard->Unlock(frt->mGuard);
329 void delete_FileReaderThread(FileReaderThread *frt)
331 if (frt != NULL)
333 delete_SDLOSXCAGuard(frt->mGuard);
334 SDL_free(frt);
340 FileReaderThread *frt = (FileReaderThread *) SDL_malloc(sizeof (FileReaderThread));
341 if (frt == NULL)
343 SDL_memset(frt, '\0', sizeof (*frt));
345 frt->mGuard = new_SDLOSXCAGuard();
346 if (frt->mGuard == NULL)
348 SDL_free(frt);
352 #define SET_FILEREADERTHREAD_METHOD(m) frt->m = FileReaderThread_##m
363 frt->mThreadPriority = 62;
364 return frt;