]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: another stream start cleanup
authorJaroslav Kysela <perex@perex.cz>
Tue, 5 Jan 2016 10:14:55 +0000 (11:14 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 5 Jan 2016 10:14:55 +0000 (11:14 +0100)
src/timeshift/timeshift_writer.c

index 6c08b1ac063582341fae9e0d4200087dc2801f75..e5c47cf67238875b4800c731922bc2ae576595ba 100644 (file)
@@ -231,20 +231,18 @@ ssize_t timeshift_write_eof ( timeshift_file_t *tsf )
 }
 
 /*
- * Stream start handling
+ * Update smt_start
  */
-static void _handle_sstart ( timeshift_t *ts, timeshift_file_t *tsf, streaming_message_t *sm )
+static void _update_smt_start ( timeshift_t *ts, streaming_start_t *ss )
 {
-  timeshift_index_data_t *ti = calloc(1, sizeof(timeshift_index_data_t));
-  streaming_start_t *ss;
   int i;
 
-  ti->pos  = tsf->size;
-  ti->data = sm;
-  TAILQ_INSERT_TAIL(&tsf->sstart, ti, link);
+  if (ts->smt_start)
+    streaming_start_unref(ts->smt_start);
+  streaming_start_ref(ss);
+  ts->smt_start = ss;
 
   /* Update video index */
-  ss = sm->sm_data;
   for (i = 0; i < ss->ss_num_components; i++)
     if (SCT_ISVIDEO(ss->ss_components[i].ssc_type)) {
       ts->vididx = ss->ss_components[i].ssc_index;
@@ -252,6 +250,18 @@ static void _handle_sstart ( timeshift_t *ts, timeshift_file_t *tsf, streaming_m
     }
 }
 
+/*
+ * Stream start handling
+ */
+static void _handle_sstart ( timeshift_t *ts, timeshift_file_t *tsf, streaming_message_t *sm )
+{
+  timeshift_index_data_t *ti = calloc(1, sizeof(timeshift_index_data_t));
+
+  ti->pos  = tsf->size;
+  ti->data = sm;
+  TAILQ_INSERT_TAIL(&tsf->sstart, ti, link);
+}
+
 /* **************************************************************************
  * Thread
  * *************************************************************************/
@@ -302,7 +312,6 @@ static void _process_msg
 {
   int err;
   timeshift_file_t *tsf;
-  streaming_start_t *ss;
 
   /* Process */
   switch (sm->sm_type) {
@@ -342,14 +351,8 @@ static void _process_msg
         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 (sm->sm_type == SMT_START)
+        _update_smt_start(ts, (streaming_start_t *)sm->sm_data);
       if (ts->dobuf) {
         if ((tsf = timeshift_filemgr_get(ts, sm->sm_time)) != NULL) {
           if (tsf->wfd >= 0 || tsf->ram) {