Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
timeshift: remove atomic ops for ts->last_time, variable is protected…
… using state_mutex
  • Loading branch information
perexg committed Jan 2, 2016
1 parent 780beb5 commit 46375dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/timeshift.c
Expand Up @@ -271,7 +271,7 @@ timeshift_packet( timeshift_t *ts, th_pkt_t *pkt, int deliver )

time = ts_rescale(pkt->pkt_pts, 1000000);
if (time > ts->last_time) {
atomic_exchange_s64(&ts->last_time, time);
ts->last_time = time;
timeshift_packet_flush(ts, time, deliver);
}

Expand Down
8 changes: 4 additions & 4 deletions src/timeshift/timeshift_reader.c
Expand Up @@ -647,15 +647,15 @@ void *timeshift_reader ( void *p )
i64 = tmp_file->last;
tmp_file->refcount--;
} else {
i64 = atomic_add_s64(&ts->last_time, 0);
i64 = ts->last_time;
}
cur_file = timeshift_filemgr_get(ts, i64);
if (cur_file != NULL) {
cur_file->roff = cur_file->size;
pause_time = cur_file->last;
last_time = pause_time;
} else {
pause_time = atomic_add_s64(&ts->last_time, 0);
pause_time = i64;
last_time = pause_time;
}
pthread_mutex_unlock(&ts->rdwr_mutex);
Expand Down Expand Up @@ -739,7 +739,7 @@ void *timeshift_reader ( void *p )
cur_file->roff = cur_file->size;
last_time = cur_file->last;
} else {
last_time = atomic_add_s64(&ts->last_time, 0);
last_time = ts->last_time;
}
skip_delivered = 0;
pthread_mutex_unlock(&ts->rdwr_mutex);
Expand All @@ -753,7 +753,7 @@ void *timeshift_reader ( void *p )

/* Live (stage2) */
if (ts->state == TS_LIVE) {
if (skip_time >= atomic_add_s64(&ts->last_time, 0) - TIMESHIFT_PLAY_BUF) {
if (skip_time >= ts->last_time - TIMESHIFT_PLAY_BUF) {
tvhlog(LOG_DEBUG, "timeshift", "ts %d skip ignored, already live", ts->id);
skip = NULL;
} else {
Expand Down

0 comments on commit 46375dd

Please sign in to comment.