void streaming_target_deliver2(streaming_target_t *st, streaming_message_t *sm);
+static inline void streaming_start_ref(streaming_start_t *ss)
+{
+ atomic_add(&ss->ss_refcount, 1);
+}
+
void streaming_start_unref(streaming_start_t *ss);
streaming_start_t *streaming_start_copy(const streaming_start_t *src);
int fd;
timeshift_file_t *tsf_tl, *tsf_hd, *tsf_tmp;
timeshift_index_data_t *ti;
+ streaming_message_t *sm;
char path[PATH_MAX];
int64_t time;
}
}
- if (tsf_tmp) {
+ if (tsf_tmp && tsf_tl) {
/* Copy across last start message */
- if (tsf_tl && (ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_data_list))) {
- tvhtrace("timeshift", "ts %d copy smt_start to new file",
- ts->id);
+ if ((ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_data_list)) || ts->smt_start) {
+ tvhtrace("timeshift", "ts %d copy smt_start to new file%s",
+ ts->id, ti ? " (from last file)" : "");
timeshift_index_data_t *ti2 = calloc(1, sizeof(timeshift_index_data_t));
- ti2->data = streaming_msg_clone(ti->data);
+ if (ti) {
+ sm = streaming_msg_clone(ti->data);
+ } else {
+ sm = streaming_msg_create(SMT_START);
+ streaming_start_ref(ts->smt_start);
+ sm->sm_data = ts->smt_start;
+ }
+ ti2->data = sm;
TAILQ_INSERT_TAIL(&tsf_tmp->sstart, ti2, link);
}
}
{
int err;
timeshift_file_t *tsf;
+ streaming_start_t *ss;
/* Process */
switch (sm->sm_type) {
if (sm->sm_type == SMT_PACKET)
timeshift_packet_log("liv", ts, sm);
}
+ if (sm->sm_type == SMT_START) {
+ /* remember start */
+ if (ts->smt_start)
+ streaming_start_unref(ts->smt_start);
+ ss = sm->sm_data;
+ streaming_start_ref(ss);
+ ts->smt_start = ss;
+ }
if (ts->dobuf) {
if ((tsf = timeshift_filemgr_get(ts, sm->sm_time)) != NULL) {
if (tsf->wfd >= 0 || tsf->ram) {