[Mvpmc-cvs] mvpmc/src mythtv.c,1.93,1.94
Status: Alpha
Brought to you by:
gettler
From: Jon G. <ge...@us...> - 2006-02-02 05:31:55
|
Update of /cvsroot/mvpmc/mvpmc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28827/src Modified Files: mythtv.c Log Message: Change mythtv_size() so that it only sends repeated size requests to the backend for in-progress recordings. Index: mythtv.c =================================================================== RCS file: /cvsroot/mvpmc/mvpmc/src/mythtv.c,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** mythtv.c 29 Jan 2006 02:32:53 -0000 1.93 --- mythtv.c 2 Feb 2006 05:31:46 -0000 1.94 *************** *** 2329,2332 **** --- 2329,2334 ---- mythtv_size(void) { + static int unchanged = 0; + static long long size = 0; static struct timeval last = { 0, 0 }; static cmyth_proginfo_t prog = NULL; *************** *** 2337,2342 **** cmyth_conn_t ctrl = cmyth_hold(control); - cmyth_dbg(CMYTH_DBG_DEBUG, "%s [%s:%d]: (trace) {\n", - __FUNCTION__, __FILE__, __LINE__); gettimeofday(&now, NULL); --- 2339,2342 ---- *************** *** 2350,2353 **** --- 2350,2367 ---- goto out; } + /* + * If the size value is not changing, then the recording is not + * still in-progress, and we can simply believe the current value. + */ + if ((prog == loc_prog) && unchanged) { + ret = cmyth_proginfo_length(loc_prog); + goto out; + } + if (prog != loc_prog) { + size = 0; + unchanged = 0; + } + cmyth_dbg(CMYTH_DBG_DEBUG, "%s [%s:%d]: (trace) {\n", + __FUNCTION__, __FILE__, __LINE__); pthread_mutex_lock(&myth_mutex); *************** *** 2371,2374 **** --- 2385,2394 ---- ret = cmyth_proginfo_length(new_prog); + if (ret == size) { + unchanged = 1; + } else { + size = ret; + } + memcpy(&last, &now, sizeof(last)); CHANGE_GLOBAL_REF(current_prog, new_prog); *************** *** 2377,2387 **** unlock: pthread_mutex_unlock(&myth_mutex); - cmyth_release(ctrl); - cmyth_release(loc_prog); - cmyth_release(new_prog); - out: cmyth_dbg(CMYTH_DBG_DEBUG, "%s [%s:%d]: (trace) %lld}\n", __FUNCTION__, __FILE__, __LINE__, ret); return ret; } --- 2397,2409 ---- unlock: pthread_mutex_unlock(&myth_mutex); cmyth_dbg(CMYTH_DBG_DEBUG, "%s [%s:%d]: (trace) %lld}\n", __FUNCTION__, __FILE__, __LINE__, ret); + + out: + cmyth_release(new_prog); + cmyth_release(loc_prog); + cmyth_release(ctrl); + return ret; } |