]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: Split timeshift_index_t in two separate datatypes.
authorKristofer Karlsson <kristofer.karlsson@gmail.com>
Thu, 29 Nov 2012 09:55:48 +0000 (10:55 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Wed, 9 Jan 2013 21:26:51 +0000 (21:26 +0000)
src/timeshift/private.h
src/timeshift/timeshift_filemgr.c
src/timeshift/timeshift_reader.c
src/timeshift/timeshift_writer.c

index 22022ac14f3b6ae69bc0c343aa34f644592500ba..1f79593e8e6a7d22c5f0d9e6807d25ebbbabbf06 100644 (file)
 /**
  * Indexes of import data in the stream
  */
-typedef struct timeshift_index
+typedef struct timeshift_index_iframe
 {
-  off_t                        pos;    ///< Position in the file
-  union {
-    int64_t                    time;   ///< Packet time
-    void                      *data;   ///< Associated data
-  };
-  TAILQ_ENTRY(timeshift_index) link;   ///< List entry
-} timeshift_index_t;
+  off_t                               pos;    ///< Position in the file
+  int64_t                             time;   ///< Packet time
+  TAILQ_ENTRY(timeshift_index_iframe) link;   ///< List entry
+} timeshift_index_iframe_t;
 
-typedef TAILQ_HEAD(timeshift_index_list,timeshift_index) timeshift_index_list_t;
+typedef TAILQ_HEAD(timeshift_index_iframe_list,timeshift_index_iframe) timeshift_index_iframe_list_t;
+
+/**
+ * Indexes of import data in the stream
+ */
+typedef struct timeshift_index_data
+{
+  off_t                             pos;    ///< Position in the file
+  void                             *data;   ///< Associated data
+  TAILQ_ENTRY(timeshift_index_data) link;   ///< List entry
+} timeshift_index_data_t;
+
+typedef TAILQ_HEAD(timeshift_index_data_list,timeshift_index_data) timeshift_index_data_list_t;
 
 /**
  * Timeshift file
  */
 typedef struct timeshift_file
 {
-  int                         fd;       ///< Write descriptor
-  char                        *path;    ///< Full path to file
+  int                           fd;       ///< Write descriptor
+  char                          *path;    ///< Full path to file
 
-  time_t                      time;     ///< Files coarse timestamp
-  size_t                      size;     ///< Current file size;
-  int64_t                     last;     ///< Latest timestamp
+  time_t                        time;     ///< Files coarse timestamp
+  size_t                        size;     ///< Current file size;
+  int64_t                       last;     ///< Latest timestamp
 
-  uint8_t                     bad;      ///< File is broken
+  uint8_t                       bad;      ///< File is broken
 
-  int                         refcount; ///< Reader ref count
+  int                           refcount; ///< Reader ref count
 
-  timeshift_index_list_t      iframes;  ///< I-frame indexing
-  timeshift_index_list_t      sstart;   ///< Stream start messages
+  timeshift_index_iframe_list_t iframes;  ///< I-frame indexing
+  timeshift_index_data_list_t   sstart;   ///< Stream start messages
 
   TAILQ_ENTRY(timeshift_file) link;     ///< List entry
 } timeshift_file_t;
index ff00ff8ba6ff671bd9e9878fb6a07f4508408032..01c2dd1501c59c32a6ffea49473c6af07f5ff346 100644 (file)
@@ -46,7 +46,8 @@ static void* timeshift_reaper_callback ( void *p )
 {
   char *dpath;
   timeshift_file_t *tsf;
-  timeshift_index_t *ti;
+  timeshift_index_iframe_t *ti;
+  timeshift_index_data_t *tid;
   streaming_message_t *sm;
   pthread_mutex_lock(&timeshift_reaper_lock);
   while (timeshift_reaper_run) {
@@ -77,11 +78,11 @@ static void* timeshift_reaper_callback ( void *p )
       TAILQ_REMOVE(&tsf->iframes, ti, link);
       free(ti);
     }
-    while ((ti = TAILQ_FIRST(&tsf->sstart))) {
-      TAILQ_REMOVE(&tsf->sstart, ti, link);
-      sm = ti->data;
+    while ((tid = TAILQ_FIRST(&tsf->sstart))) {
+      TAILQ_REMOVE(&tsf->sstart, tid, link);
+      sm = tid->data;
       streaming_msg_free(sm);
-      free(ti);
+      free(tid);
     }
     free(tsf->path);
     free(tsf);
@@ -161,7 +162,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
   int fd;
   struct timespec tp;
   timeshift_file_t *tsf_tl, *tsf_hd, *tsf_tmp;
-  timeshift_index_t *ti;
+  timeshift_index_data_t *ti;
   char path[512];
 
   /* Return last file */
@@ -218,13 +219,12 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
         TAILQ_INSERT_TAIL(&ts->files, tsf_tmp, link);
 
         /* Copy across last start message */
-        if (tsf_tl && (ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_list))) {
+        if (tsf_tl && (ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_data_list))) {
 #ifdef TSHFT_TRACE
           tvhlog(LOG_DEBUG, "timeshift", "ts %d copy smt_start to new file",
                  ts->id);
 #endif
-          timeshift_index_t *ti2 = calloc(1, sizeof(timeshift_index_t));
-          ti2->pos  = ti->pos;
+          timeshift_index_data_t *ti2 = calloc(1, sizeof(timeshift_index_data_t));
           ti2->data = streaming_msg_clone(ti->data);
           TAILQ_INSERT_TAIL(&tsf_tmp->sstart, ti2, link);
         }
index a8f3006565ca983a598ae5a47fa38be200550c0e..25968f241dd4bafa3851eedda335c18c33bacfc0 100644 (file)
@@ -180,7 +180,7 @@ void *timeshift_reader ( void *p )
   int64_t now, deliver;
   streaming_message_t *sm = NULL, *ctrl;
   timeshift_file_t *cur_file = NULL, *tsi_file = NULL;
-  timeshift_index_t *tsi = NULL;
+  timeshift_index_iframe_t *tsi = NULL;
 
   /* Poll */
   struct epoll_event ev;
@@ -311,7 +311,7 @@ void *timeshift_reader ( void *p )
       if (cur_speed < 0) {
         if (!tsi) {
           TAILQ_FOREACH_REVERSE(tsi, &tsi_file->iframes,
-                                timeshift_index_list, link) {
+                                timeshift_index_iframe_list, link) {
             if (tsi->time < last_time) break;
           }
         }
@@ -378,7 +378,7 @@ void *timeshift_reader ( void *p )
 
         /* Next index */
         if (cur_speed < 0)
-          tsi = TAILQ_PREV(tsi, timeshift_index_list, link);
+          tsi = TAILQ_PREV(tsi, timeshift_index_iframe_list, link);
         else
           tsi = TAILQ_NEXT(tsi, link);
 
index a66e6e1b14d7b54c93381906dc27c284271303ce..0fb3129f8a7799fb2814b801951d31abf632df19 100644 (file)
@@ -188,7 +188,7 @@ static inline ssize_t _process_msg0
   streaming_message_t *sm = *smp;
   if (sm->sm_type == SMT_START) {
     err = 0;
-    timeshift_index_t *ti = calloc(1, sizeof(timeshift_index_t));
+    timeshift_index_data_t *ti = calloc(1, sizeof(timeshift_index_data_t));
     ti->pos  = tsf->size;
     ti->data = sm;
     *smp = NULL;
@@ -209,7 +209,7 @@ static inline ssize_t _process_msg0
       /* Index video iframes */
       if (pkt->pkt_componentindex == ts->vididx &&
           pkt->pkt_frametype      == PKT_I_FRAME) {
-        timeshift_index_t *ti = calloc(1, sizeof(timeshift_index_t));
+        timeshift_index_iframe_t *ti = calloc(1, sizeof(timeshift_index_iframe_t));
         ti->pos  = tsf->size;
         ti->time = sm->sm_time;
         TAILQ_INSERT_TAIL(&tsf->iframes, ti, link);