]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: little optimization
authorJaroslav Kysela <perex@perex.cz>
Mon, 4 Jan 2016 20:43:17 +0000 (21:43 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 4 Jan 2016 20:43:17 +0000 (21:43 +0100)
src/timeshift.c

index bbc2eebe4a732a4fce94d642a3e9e34b95eb666f..aa96aa0fae26c8f4a373508a9c06f96699c987dc 100644 (file)
@@ -270,16 +270,14 @@ timeshift_packet_flush ( timeshift_t *ts, int64_t time )
 }
 
 static void
-timeshift_packet( timeshift_t *ts, th_pkt_t *pkt )
+timeshift_packet( timeshift_t *ts, streaming_message_t *sm )
 {
-  streaming_message_t *sm;
+  th_pkt_t *pkt = sm->sm_data;
   int64_t time;
 
   if (pkt->pkt_componentindex >= TIMESHIFT_BACKLOG_MAX)
     return;
 
-  sm = streaming_msg_create_pkt(pkt);
-
   time = ts_rescale(pkt->pkt_pts, 1000000);
   if (time > ts->last_time) {
     ts->last_time = time;
@@ -306,7 +304,7 @@ static void timeshift_input
 {
   int type = sm->sm_type;
   timeshift_t *ts = opaque;
-  th_pkt_t *pkt = sm->sm_data, *pkt2;
+  th_pkt_t *pkt, *pkt2;
 
   /* Control */
   if (type == SMT_SKIP) {
@@ -322,11 +320,12 @@ static void timeshift_input
 
     /* Change PTS/DTS offsets */
     else if (ts->packet_mode && ts->start_pts && type == SMT_PACKET) {
+      pkt = sm->sm_data;
       pkt2 = pkt_copy_shallow(pkt);
       pkt_ref_dec(pkt);
-      sm->sm_data = pkt = pkt2;
-      pkt->pkt_pts += ts->start_pts;
-      pkt->pkt_dts += ts->start_pts;
+      sm->sm_data = pkt2;
+      pkt2->pkt_pts += ts->start_pts;
+      pkt2->pkt_dts += ts->start_pts;
     }
 
     /* Check for exit */
@@ -341,8 +340,7 @@ static void timeshift_input
     if (ts->packet_mode) {
       sm->sm_time = ts->last_wr_time;
       if (type == SMT_PACKET) {
-        timeshift_packet(ts, pkt);
-        streaming_msg_free(sm);
+        timeshift_packet(ts, sm);
         goto _exit;
       }
     } else {