Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timeshift: for initial pts value, scan more packets (now 6)
- Loading branch information
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,8 +170,21 @@ static void timeshift_input | |
|
||
/* Record (one-off) PTS delta */ | ||
if (sm->sm_type == SMT_PACKET && ts->pts_delta == PTS_UNSET) { | ||
if (pkt->pkt_pts != PTS_UNSET) | ||
ts->pts_delta = getmonoclock() - ts_rescale(pkt->pkt_pts, 1000000); | ||
if (pkt->pkt_pts != PTS_UNSET) { | ||
int i; | ||
int64_t smallest = INT64_MAX; | ||
for (i = 0; i < ARRAY_SIZE(ts->pts_val); i++) { | ||
int64_t i64 = ts->pts_val[i]; | ||
if (i64 == PTS_UNSET) { | ||
ts->pts_val[i] = pkt->pkt_pts; | ||
break; | ||
} | ||
if (i64 < smallest) | ||
smallest = i64; | ||
} | ||
if (i >= ARRAY_SIZE(ts->pts_val)) | ||
ts->pts_delta = getmonoclock() - ts_rescale(smallest, 1000000); | ||
} | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
perexg
Author
Contributor
|
||
|
||
/* Buffer to disk */ | ||
|
@@ -256,6 +269,7 @@ streaming_target_t *timeshift_create | |
(streaming_target_t *out, time_t max_time) | ||
{ | ||
timeshift_t *ts = calloc(1, sizeof(timeshift_t)); | ||
int i; | ||
|
||
/* Must hold global lock */ | ||
lock_assert(&global_lock); | ||
|
@@ -271,6 +285,8 @@ streaming_target_t *timeshift_create | |
ts->id = timeshift_index; | ||
ts->ondemand = timeshift_ondemand; | ||
ts->pts_delta = PTS_UNSET; | ||
for (i = 0; i < ARRAY_SIZE(ts->pts_val); i++) | ||
ts->pts_val[i] = PTS_UNSET; | ||
pthread_mutex_init(&ts->rdwr_mutex, NULL); | ||
pthread_mutex_init(&ts->state_mutex, NULL); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@perexg Could you please add some comments here? My feeling is that after some weeks nobody will ever remember what this "magic" code is good for.