From 11e72f25bfc05bef01ef1198dc9c9f5f7ee4ec52 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Mon, 14 Feb 2011 23:54:04 -0500 Subject: Fix emulator GPS support Use create_thread_cb instead of pthread_create to create gps_state_thread so it can safely call into the Java framework. BUG: 3375089 Change-Id: Ie7b2bd4bea519702d4238ba375bf83b059095b9e Signed-off-by: Mike Lockwood --- emulator/gps/gps_qemu.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'emulator') diff --git a/emulator/gps/gps_qemu.c b/emulator/gps/gps_qemu.c index ce14fcb..a4699d3 100644 --- a/emulator/gps/gps_qemu.c +++ b/emulator/gps/gps_qemu.c @@ -660,7 +660,7 @@ epoll_deregister( int epoll_fd, int fd ) * when started, messages from the QEMU GPS daemon. these are simple NMEA sentences * that must be parsed to be converted into GPS fixes sent to the framework */ -static void* +static void gps_state_thread( void* arg ) { GpsState* state = (GpsState*) arg; @@ -693,7 +693,7 @@ gps_state_thread( void* arg ) for (ne = 0; ne < nevents; ne++) { if ((events[ne].events & (EPOLLERR|EPOLLHUP)) != 0) { LOGE("EPOLLERR or EPOLLHUP after epoll_wait() !?"); - goto Exit; + return; } if ((events[ne].events & EPOLLIN) != 0) { int fd = events[ne].data.fd; @@ -709,7 +709,7 @@ gps_state_thread( void* arg ) if (cmd == CMD_QUIT) { D("gps thread quitting on demand"); - goto Exit; + return; } else if (cmd == CMD_START) { if (!started) { @@ -754,13 +754,11 @@ gps_state_thread( void* arg ) } } } -Exit: - return NULL; } static void -gps_state_init( GpsState* state ) +gps_state_init( GpsState* state, GpsCallbacks* callbacks ) { state->init = 1; state->control[0] = -1; @@ -781,11 +779,15 @@ gps_state_init( GpsState* state ) goto Fail; } - if ( pthread_create( &state->thread, NULL, gps_state_thread, state ) != 0 ) { + state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state ); + + if ( !state->thread ) { LOGE("could not create gps thread: %s", strerror(errno)); goto Fail; } + state->callbacks = *callbacks; + D("gps state initialized"); return; @@ -809,13 +811,11 @@ qemu_gps_init(GpsCallbacks* callbacks) GpsState* s = _gps_state; if (!s->init) - gps_state_init(s); + gps_state_init(s, callbacks); if (s->fd < 0) return -1; - s->callbacks = *callbacks; - return 0; } -- cgit v1.1