Wait as short as possible after starting win32 sensor app
Do not use a fixed 5 second delay after having a started a windows sensor application, instead try to access the shared memory area repeatedly and only give up after 10 seconds. Please note that for this feature to be usable the sensor app must be found in PATH.
This commit is contained in:
parent
ff5cd65678
commit
d712ce32ce
|
@ -73,6 +73,8 @@ static gboolean
|
||||||
shm_open_or_start_app(ShmData *shm, const wchar_t *shm_name,
|
shm_open_or_start_app(ShmData *shm, const wchar_t *shm_name,
|
||||||
const gchar *app_name)
|
const gchar *app_name)
|
||||||
{
|
{
|
||||||
|
guint retries;
|
||||||
|
|
||||||
/* Try to open shared memory area and return if successful*/
|
/* Try to open shared memory area and return if successful*/
|
||||||
if (shm_open(shm, shm_name))
|
if (shm_open(shm, shm_name))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -91,11 +93,15 @@ shm_open_or_start_app(ShmData *shm, const wchar_t *shm_name,
|
||||||
"Started sensor-app %s, waiting for it to initialize\n",
|
"Started sensor-app %s, waiting for it to initialize\n",
|
||||||
app_name);
|
app_name);
|
||||||
|
|
||||||
// 5 second wait to allow sensor-app init
|
/* Wait up to retries seconds for the shared memory area to be accessible */
|
||||||
g_usleep(5 * G_USEC_PER_SEC);
|
for (retries = 10; retries > 0; --retries)
|
||||||
|
{
|
||||||
|
if (shm_open(shm, shm_name))
|
||||||
|
return TRUE;
|
||||||
|
g_usleep(1 * G_USEC_PER_SEC); /* delay to allow sensor-app to startup */
|
||||||
|
}
|
||||||
|
|
||||||
/* Retry open of shm-file */
|
return FALSE;
|
||||||
return shm_open(shm, shm_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue