(GX) Start using sthread wrapper functions for device notification thread

This commit is contained in:
twinaphex 2015-04-11 23:37:00 +02:00
parent 89a5196403
commit 867ee391dd
2 changed files with 18 additions and 18 deletions

View File

@ -100,21 +100,19 @@ static struct {
const DISC_INTERFACE *interface; const DISC_INTERFACE *interface;
const char *name; const char *name;
} gx_devices[GX_DEVICE_END]; } gx_devices[GX_DEVICE_END];
static mutex_t gx_device_mutex;
static mutex_t gx_device_cond_mutex; static slock_t *gx_device_mutex;
static cond_t gx_device_cond; static slock_t *gx_device_cond_mutex;
static scond_t *gx_device_cond;
static void *gx_devthread(void *a) static void *gx_devthread(void *a)
{ {
struct timespec timeout = {0};
timeout.tv_sec = 1;
timeout.tv_nsec = 0;
while (1) while (1)
{ {
LWP_MutexLock(gx_device_mutex);
unsigned i; unsigned i;
slock_lock(gx_device_mutex);
for (i = 0; i < GX_DEVICE_END; i++) for (i = 0; i < GX_DEVICE_END; i++)
{ {
if (gx_devices[i].mounted && if (gx_devices[i].mounted &&
@ -126,10 +124,12 @@ static void *gx_devthread(void *a)
fatUnmount(n); fatUnmount(n);
} }
} }
LWP_MutexUnlock(gx_device_mutex);
LWP_MutexLock(gx_device_cond_mutex); slock_unlock(gx_device_mutex);
LWP_CondTimedWait(gx_device_cond, gx_device_cond_mutex, &timeout);
LWP_MutexUnlock(gx_device_cond_mutex); slock_lock(gx_device_cond_mutex);
scond_wait_timeout(gx_device_cond, gx_device_cond_mutex, 1000000);
slock_unlock(gx_device_cond_mutex);
} }
return NULL; return NULL;
@ -305,9 +305,9 @@ static void frontend_gx_init(void *data)
gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].name,
gx_devices[GX_DEVICE_USB].interface); gx_devices[GX_DEVICE_USB].interface);
OSInitMutex(&gx_device_cond_mutex); gx_device_cond_mutex = slock_new();
OSInitCond(&gx_device_cond); gx_device_cond = scond_new();
OSInitMutex(&gx_device_mutex); gx_device_mutex = slock_new();
OSCreateThread(&gx_device_thread, gx_devthread, 0, NULL, NULL, 0, 66, 0); OSCreateThread(&gx_device_thread, gx_devthread, 0, NULL, NULL, 0, 66, 0);
#endif #endif
} }

View File

@ -349,14 +349,14 @@ int menu_entries_parse_list(
} }
#if defined(GEKKO) && defined(HW_RVL) #if defined(GEKKO) && defined(HW_RVL)
LWP_MutexLock(gx_device_mutex); slock_lock(gx_device_mutex);
device = gx_get_device_from_path(dir); device = gx_get_device_from_path(dir);
if (device != -1 && !gx_devices[device].mounted && if (device != -1 && !gx_devices[device].mounted &&
gx_devices[device].interface->isInserted()) gx_devices[device].interface->isInserted())
fatMountSimple(gx_devices[device].name, gx_devices[device].interface); fatMountSimple(gx_devices[device].name, gx_devices[device].interface);
LWP_MutexUnlock(gx_device_mutex); slock_unlock(gx_device_mutex);
#endif #endif
path_is_compressed = path_is_compressed_file(dir); path_is_compressed = path_is_compressed_file(dir);