Skip to content

Commit

Permalink
libloc_api: xtra injection improvements
Browse files Browse the repository at this point in the history
* 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
zinx authored and hyperb1iss committed May 6, 2011
1 parent 4c43268 commit c025b7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
4 changes: 0 additions & 4 deletions loc_api/libloc_api/loc_eng.cpp
Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions loc_api/libloc_api/loc_eng_xtra.cpp
Expand Up @@ -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
};

/*===========================================================================
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c025b7d

Please sign in to comment.