Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
timeshift: fix tsf refcounting
  • Loading branch information
perexg committed Jan 1, 2016
1 parent 4c98cc8 commit a5085c8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/timeshift/timeshift_reader.c
Expand Up @@ -562,10 +562,11 @@ void *timeshift_reader ( void *p )
{
timeshift_t *ts = p;
int nfds, end, run = 1, wait = -1, skip_delivered = 0;
timeshift_file_t *cur_file = NULL;
timeshift_file_t *cur_file = NULL, *tmp_file;
int cur_speed = 100, keyframe_mode = 0;
int64_t mono_now, mono_play_time = 0, mono_last_status = 0;
int64_t deliver, deliver0, pause_time = 0, last_time = 0, skip_time = 0;
int64_t i64;
streaming_message_t *sm = NULL, *ctrl = NULL;
timeshift_index_iframe_t *tsi = NULL;
streaming_skip_t *skip = NULL;
Expand Down Expand Up @@ -641,9 +642,14 @@ void *timeshift_reader ( void *p )
ts->dobuf = 1;
skip_delivered = 1;
pthread_mutex_lock(&ts->rdwr_mutex);
cur_file = timeshift_filemgr_newest(ts);
cur_file = timeshift_filemgr_get(ts, cur_file ? cur_file->last :
atomic_add_s64(&ts->last_time, 0));
tmp_file = timeshift_filemgr_newest(ts);
if (tmp_file != NULL) {
i64 = tmp_file->last;
tmp_file->refcount--;
} else {
i64 = atomic_add_s64(&ts->last_time, 0);
}
cur_file = timeshift_filemgr_get(ts, i64);
if (cur_file != NULL) {
cur_file->roff = cur_file->size;
pause_time = cur_file->last;
Expand Down Expand Up @@ -724,8 +730,12 @@ void *timeshift_reader ( void *p )
/* Live playback (stage1) */
if (ts->state == TS_LIVE) {
pthread_mutex_lock(&ts->rdwr_mutex);
cur_file = timeshift_filemgr_newest(ts);
if (cur_file && (cur_file = timeshift_filemgr_get(ts, cur_file->last)) != NULL) {
tmp_file = timeshift_filemgr_newest(ts);
if (tmp_file) {
i64 = tmp_file->last;
tmp_file->refcount--;
}
if (tmp_file && (cur_file = timeshift_filemgr_get(ts, i64)) != NULL) {
cur_file->roff = cur_file->size;
last_time = cur_file->last;
} else {
Expand Down

0 comments on commit a5085c8

Please sign in to comment.