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