[spice] prepare spice for external usage

This commit is contained in:
Geoffrey McRae 2020-01-19 06:51:21 +11:00
parent e6154e685f
commit 4d0f019ad5
5 changed files with 11 additions and 10 deletions

View file

@ -1 +1 @@
B1-100-g2c59b5f557+1
B1-101-ge6154e685f+1

View file

@ -19,6 +19,7 @@ add_library(spice STATIC
target_link_libraries(spice
lg_common
${SPICE_PKGCONFIG_LIBRARIES}
gmp
)
target_include_directories(spice

View file

@ -40,7 +40,7 @@ typedef void (*SpiceClipboardRequest)(const SpiceDataType type);
bool spice_connect(const char * host, const unsigned short port, const char * password);
void spice_disconnect();
bool spice_process();
bool spice_process(int timeout);
bool spice_ready();
bool spice_key_down (uint32_t code);
@ -61,4 +61,4 @@ bool spice_set_clipboard_cb(
SpiceClipboardNotice cbNoticeFn,
SpiceClipboardData cbDataFn,
SpiceClipboardRelease cbReleaseFn,
SpiceClipboardRequest cbRequestFn);
SpiceClipboardRequest cbRequestFn);

View file

@ -236,18 +236,18 @@ bool spice_ready()
// ============================================================================
bool spice_process()
bool spice_process(int timeout)
{
fd_set readSet;
FD_ZERO(&readSet);
FD_SET(spice.scMain.socket , &readSet);
FD_SET(spice.scInputs.socket, &readSet);
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
struct timeval tv;
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
int rc = select(FD_SETSIZE, &readSet, NULL, NULL, &timeout);
int rc = select(FD_SETSIZE, &readSet, NULL, NULL, &tv);
if (rc < 0)
{
DEBUG_ERROR("select failure");

View file

@ -464,7 +464,7 @@ static int frameThread(void * unused)
int spiceThread(void * arg)
{
while(state.running)
if (!spice_process())
if (!spice_process(1000))
{
if (state.running)
{
@ -1215,7 +1215,7 @@ static int lg_run()
}
while(state.running && !spice_ready())
if (!spice_process())
if (!spice_process(1000))
{
state.running = false;
DEBUG_ERROR("Failed to process spice messages");