[client] moved host startup sync before window creation

This commit is contained in:
Geoffrey McRae 2017-12-13 21:56:33 +11:00
parent 15830a81f7
commit 233b7755ae

View File

@ -146,24 +146,18 @@ int renderThread(void * unused)
struct KVMFRHeader header; struct KVMFRHeader header;
volatile uint32_t * updateCount = &state.shm->updateCount; volatile uint32_t * updateCount = &state.shm->updateCount;
while(state.running)
{
// poll until we have a new frame, or we time out
while(header.updateCount == *updateCount && state.running)
{
const struct timespec s = const struct timespec s =
{ {
.tv_sec = 0, .tv_sec = 0,
.tv_nsec = 1000 .tv_nsec = 1000
}; };
// flag the host that we are starting up this is important so that
// the host wakes up if it is waiting on an interrupt, the host will
// also send us the current mouse shape since we won't know it yet
__sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_RESTART);
while(state.running && (state.shm->flags & KVMFR_HEADER_FLAG_RESTART))
nanosleep(&s, NULL);
while(state.running)
{
// poll until we have a new frame, or we time out
while(header.updateCount == *updateCount && state.running)
nanosleep(&s, NULL); nanosleep(&s, NULL);
}
if (!state.running) if (!state.running)
break; break;
@ -752,6 +746,15 @@ int run()
state.shmSize = ivshmem_get_map_size(); state.shmSize = ivshmem_get_map_size();
state.shm->hostID = ivshmem_get_id(); state.shm->hostID = ivshmem_get_id();
// flag the host that we are starting up this is important so that
// the host wakes up if it is waiting on an interrupt, the host will
// also send us the current mouse shape since we won't know it yet
DEBUG_INFO("Waiting for host to signal it's ready...");
__sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_RESTART);
while(state.running && (state.shm->flags & KVMFR_HEADER_FLAG_RESTART))
usleep(1000);
DEBUG_INFO("Host ready, starting session");
if (params.useSpice) if (params.useSpice)
{ {
if (!spice_connect(params.spiceHost, params.spicePort, "")) if (!spice_connect(params.spiceHost, params.spicePort, ""))