Permalink
Browse files

libloc_api: xtra injection improvements

* Hold the locks only for copying buffer data to reduce the wait time
  for xtra injection.
* Remove some incorrect locks while doing deferred xtra injection.
* Switch to buffering the injection if the engine is on, as doing so
  now functions as intended.

Change-Id: I1b75945907242e960ce4b275f10b7f9f8dc17606
  • Loading branch information...
1 parent 4c43268 commit c025b7d5f7f78320769906dcce6097341d7c1fed @zinx zinx committed with cyanogen Apr 29, 2011
Showing with 15 additions and 16 deletions.
  1. +0 −4 loc_api/libloc_api/loc_eng.cpp
  2. +15 −12 loc_api/libloc_api/loc_eng_xtra.cpp
View
4 loc_api/libloc_api/loc_eng.cpp
@@ -2190,11 +2190,7 @@ static void loc_eng_deferred_action_thread(void* arg)
if (loc_eng_data.engine_status != GPS_STATUS_ENGINE_ON &&
loc_eng_data.xtra_module_data.xtra_data_for_injection != NULL)
{
- pthread_mutex_unlock(&loc_eng_data.deferred_action_mutex);
-
loc_eng_inject_xtra_data_in_buffer();
-
- pthread_mutex_lock(&loc_eng_data.deferred_action_mutex);
}
//Process connectivity manager events at this point
View
27 loc_api/libloc_api/loc_eng_xtra.cpp
@@ -60,8 +60,8 @@ const GpsXtraInterface sLocEngXTRAInterface =
{
sizeof(GpsXtraInterface),
qct_loc_eng_xtra_init,
- qct_loc_eng_inject_xtra_data,
- /* qct_loc_eng_inject_xtra_data_proxy, */ // This func buffers xtra data if GPS is in-session
+ /* qct_loc_eng_inject_xtra_data, */
+ qct_loc_eng_inject_xtra_data_proxy, // This func buffers xtra data if GPS is in-session
};
/*===========================================================================
@@ -215,28 +215,31 @@ SIDE EFFECTS
int loc_eng_inject_xtra_data_in_buffer()
{
int rc = 0;
+ char *data;
+ int length;
pthread_mutex_lock(&loc_eng_data.xtra_module_data.lock);
- if (loc_eng_data.xtra_module_data.xtra_data_for_injection)
+ data = loc_eng_data.xtra_module_data.xtra_data_for_injection;
+ length = loc_eng_data.xtra_module_data.xtra_data_len;
+
+ loc_eng_data.xtra_module_data.xtra_data_for_injection = NULL;
+ loc_eng_data.xtra_module_data.xtra_data_len = 0;
+
+ pthread_mutex_unlock(&loc_eng_data.xtra_module_data.lock);
+
+ if (data)
{
- if (qct_loc_eng_inject_xtra_data(
- loc_eng_data.xtra_module_data.xtra_data_for_injection,
- loc_eng_data.xtra_module_data.xtra_data_len))
+ if (qct_loc_eng_inject_xtra_data(data, length))
{
// FIXME gracefully handle injection error
LOC_LOGE("XTRA injection failed.");
rc = -1;
}
- // Clears buffered data
- free(loc_eng_data.xtra_module_data.xtra_data_for_injection);
- loc_eng_data.xtra_module_data.xtra_data_for_injection = NULL;
- loc_eng_data.xtra_module_data.xtra_data_len = 0;
+ free(data);
}
- pthread_mutex_unlock(&loc_eng_data.xtra_module_data.lock);
-
return rc;
}

0 comments on commit c025b7d

Please sign in to comment.