mirror of
https://github.com/dborth/fceugx.git
synced 2024-10-31 22:45:05 +01:00
improve device thread
This commit is contained in:
parent
aa53a572ba
commit
a6fa5c982d
@ -78,7 +78,7 @@ static void ExitCleanup()
|
||||
ShutdownAudio();
|
||||
StopGX();
|
||||
|
||||
LWP_SuspendThread (devicethread);
|
||||
HaltDeviceThread();
|
||||
UnmountAllFAT();
|
||||
|
||||
#ifdef HW_RVL
|
||||
@ -267,7 +267,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// go back to checking if devices were inserted/removed
|
||||
// since we're entering the menu
|
||||
LWP_ResumeThread (devicethread);
|
||||
ResumeDeviceThread();
|
||||
|
||||
ConfigRequested = 1;
|
||||
SwitchAudioMode(1);
|
||||
@ -287,7 +287,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're starting emulation again
|
||||
LWP_SuspendThread (devicethread);
|
||||
HaltDeviceThread();
|
||||
|
||||
ResetVideo_Emu();
|
||||
SetControllers();
|
||||
|
@ -48,7 +48,35 @@ bool isMounted[9] = { false, false, false, false, false, false, false, false, fa
|
||||
/****************************************************************************
|
||||
* deviceThreading
|
||||
***************************************************************************/
|
||||
lwp_t devicethread = LWP_THREAD_NULL;
|
||||
static lwp_t devicethread = LWP_THREAD_NULL;
|
||||
static bool deviceHalt = true;
|
||||
|
||||
/****************************************************************************
|
||||
* ResumeDeviceThread
|
||||
*
|
||||
* Signals the device thread to start, and resumes the thread.
|
||||
***************************************************************************/
|
||||
void
|
||||
ResumeDeviceThread()
|
||||
{
|
||||
deviceHalt = false;
|
||||
LWP_ResumeThread(devicethread);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* HaltGui
|
||||
*
|
||||
* Signals the device thread to stop.
|
||||
***************************************************************************/
|
||||
void
|
||||
HaltDeviceThread()
|
||||
{
|
||||
deviceHalt = true;
|
||||
|
||||
// wait for thread to finish
|
||||
while(!LWP_ThreadIsSuspended(devicethread))
|
||||
usleep(100);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* devicecallback
|
||||
@ -101,7 +129,10 @@ devicecallback (void *arg)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
sleep(1); // suspend thread for 1 sec
|
||||
if(deviceHalt)
|
||||
LWP_SuspendThread(devicethread);
|
||||
else
|
||||
sleep(1); // suspend thread for 1 sec
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -403,7 +434,7 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're loading a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
HaltDeviceThread();
|
||||
|
||||
file = fopen (filepath, "rb");
|
||||
if (file > 0)
|
||||
@ -417,7 +448,7 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
ResumeDeviceThread();
|
||||
|
||||
return size;
|
||||
}
|
||||
@ -449,7 +480,7 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're loading a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
HaltDeviceThread();
|
||||
|
||||
// open the file
|
||||
while(!size && retry == 1)
|
||||
@ -525,7 +556,7 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
ResumeDeviceThread();
|
||||
CancelAction();
|
||||
return size;
|
||||
}
|
||||
@ -561,7 +592,7 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're saving a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
HaltDeviceThread();
|
||||
|
||||
while(!written && retry == 1)
|
||||
{
|
||||
@ -597,7 +628,7 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
ResumeDeviceThread();
|
||||
|
||||
CancelAction();
|
||||
return written;
|
||||
|
@ -22,6 +22,8 @@
|
||||
#define SAVEBUFFERSIZE (1024 * 512)
|
||||
|
||||
void InitDeviceThread();
|
||||
void ResumeDeviceThread();
|
||||
void HaltDeviceThread();
|
||||
void MountAllFAT();
|
||||
void UnmountAllFAT();
|
||||
bool ChangeInterface(int method, bool silent);
|
||||
@ -38,6 +40,5 @@ extern unsigned char * savebuffer;
|
||||
extern FILE * file;
|
||||
extern bool unmountRequired[];
|
||||
extern bool isMounted[];
|
||||
extern lwp_t devicethread;
|
||||
|
||||
#endif
|
||||
|
@ -131,7 +131,7 @@ bool DownloadUpdate()
|
||||
{
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're saving a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
HaltDeviceThread();
|
||||
|
||||
FILE * hfile;
|
||||
char updateFile[50];
|
||||
@ -162,7 +162,7 @@ bool DownloadUpdate()
|
||||
updateFound = false; // updating is finished (successful or not!)
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
ResumeDeviceThread();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user