]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
factor out subscription byte count updates to separate functions. This has the added...
authorSam Stenvall <sam.stenvall@nordsoftware.com>
Tue, 1 Sep 2015 21:30:35 +0000 (00:30 +0300)
committerJaroslav Kysela <perex@perex.cz>
Wed, 2 Sep 2015 18:43:45 +0000 (20:43 +0200)
src/dvr/dvr_rec.c
src/epggrab/module/eit.c
src/epggrab/module/opentv.c
src/htsp_server.c
src/satip/rtp.c
src/subscriptions.c
src/subscriptions.h
src/webui/webui.c

index aac4a2a7950c151e2b86deb8c3bfc14fe993b94c..396f0f1baebad7ca6be319fa323d1f83e5bc3c5c 100644 (file)
@@ -915,7 +915,7 @@ dvr_thread(void *aux)
         }
       }
       if (pb)
-        atomic_add(&ts->ths_bytes_out, pktbuf_len(pb));
+        subscription_add_bytes_out(ts, pktbuf_len(pb));
     }
 
     streaming_queue_remove(sq, sm);
index af1b9965ef0ef60bda5ac89c914314bdf56d3339..876e2b7ed69423365f6909398137286eca56ffe2 100644 (file)
@@ -597,8 +597,8 @@ _eit_callback
   /* Statistics */
   ths = mpegts_mux_find_subscription_by_name(mm, "epggrab");
   if (ths) {
-    ths->ths_bytes_in += len;
-    ths->ths_bytes_out += len;
+    subscription_add_bytes_in(ths, len);
+    subscription_add_bytes_out(ths, len);
   }
 
   /* Validate */
index 9ff7d1bc1ebf7e5de4effef16455de7268d3dfea..ece8433d01b62b16d9d77a134ea720b0bdca5383 100644 (file)
@@ -563,8 +563,8 @@ opentv_table_callback
   /* Statistics */
   ths = mpegts_mux_find_subscription_by_name(mt->mt_mux, "epggrab");
   if (ths) {
-    ths->ths_bytes_in += len;
-    ths->ths_bytes_out += len;
+    subscription_add_bytes_in(ths, len);
+    subscription_add_bytes_out(ths, len);
   }
 
 
@@ -642,8 +642,8 @@ opentv_bat_callback
   /* Statistics */
   ths = mpegts_mux_find_subscription_by_name(mt->mt_mux, "epggrab");
   if (ths) {
-    ths->ths_bytes_in += len;
-    ths->ths_bytes_out += len;
+    subscription_add_bytes_in(ths, len);
+    subscription_add_bytes_out(ths, len);
   }
 
   r = dvb_bat_callback(mt, buf, len, tableid);
index 553bdd2d716c7dd70ae244cc199727fc46dfc52e..742fa5bc323cfabc76779dcf7d0dd2d6ae870063 100644 (file)
@@ -3415,7 +3415,7 @@ htsp_stream_deliver(htsp_subscription_t *hs, th_pkt_t *pkt)
   payloadlen = pktbuf_len(pkt->pkt_payload);
   htsmsg_add_binptr(m, "payload", pktbuf_ptr(pkt->pkt_payload), payloadlen);
   htsp_send_subscription(htsp, m, pkt->pkt_payload, hs, payloadlen);
-  atomic_add(&hs->hs_s->ths_bytes_out, payloadlen);
+  subscription_add_bytes_out(hs->hs_s, payloadlen);
 
   if(hs->hs_last_report != dispatch_clock) {
 
index 00d71a31f795b55694597486894e06d0ec72f648..cf3b8c6069125154050b72ca027519ccd5f0f85a 100644 (file)
@@ -189,7 +189,7 @@ satip_rtp_thread(void *aux)
     switch (sm->sm_type) {
     case SMT_MPEGTS:
       pb = sm->sm_data;
-      atomic_add(&subs->ths_bytes_out, pktbuf_len(pb));
+      subscription_add_bytes_out(subs, pktbuf_len(pb));
       pthread_mutex_lock(&rtp->lock);
       r = satip_rtp_loop(rtp, pktbuf_ptr(pb), pktbuf_len(pb));
       pthread_mutex_unlock(&rtp->lock);
index e5a50707463ea3655757c825edddc4a8e0b0e6bd..787da3c8c028421ee78541fad75c2e9f20877ab1 100644 (file)
@@ -457,11 +457,11 @@ subscription_input_direct(void *opauqe, streaming_message_t *sm)
     th_pkt_t *pkt = sm->sm_data;
     s->ths_total_err += pkt->pkt_err;
     if (pkt->pkt_payload)
-      s->ths_bytes_in += pkt->pkt_payload->pb_size;
+      subscription_add_bytes_in(s, pkt->pkt_payload->pb_size);
   } else if(sm->sm_type == SMT_MPEGTS) {
     pktbuf_t *pb = sm->sm_data;
     s->ths_total_err += pb->pb_err;
-    s->ths_bytes_in += pb->pb_size;
+    subscription_add_bytes_in(s, pb->pb_size);
   }
 
   /* Pass to output */
@@ -951,6 +951,22 @@ subscription_done(void)
  * Subscription control
  * *************************************************************************/
 
+/**
+ * Update incoming byte count
+ */
+void subscription_add_bytes_in(th_subscription_t *s, size_t in)
+{
+  atomic_add(&s->ths_bytes_in, in);
+}
+
+/**
+ * Update outgoing byte count
+ */
+void subscription_add_bytes_out(th_subscription_t *s, size_t out)
+{
+  atomic_add(&s->ths_bytes_out, out);
+}
+
 /**
  * Change weight
  */
index f6f85f7881c872dd5c6a6fdfa1fccc3690b7a076..1f7c9bbc3383ead10979a4ad5b557615c16ac456 100644 (file)
@@ -201,6 +201,9 @@ void subscription_unlink_service(th_subscription_t *s, int reason);
 
 void subscription_dummy_join(const char *id, int first);
 
+void subscription_add_bytes_in(th_subscription_t *s, size_t in);
+
+void subscription_add_bytes_out(th_subscription_t *s, size_t out);
 
 static inline int subscriptions_active(void)
   { return LIST_FIRST(&subscriptions) != NULL; }
index 9be36cf8f8ae0a90e50299dac378ef9105a1a5ab..6dfdb61b6cccc81dc9cb34f70c47d3e00d86a87f 100644 (file)
@@ -349,7 +349,7 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch,
           pb = ((th_pkt_t*)sm->sm_data)->pkt_payload;
         else
           pb = sm->sm_data;
-        atomic_add(&s->ths_bytes_out, pktbuf_len(pb));
+        subscription_add_bytes_out(s, pktbuf_len(pb));
         muxer_write_pkt(mux, sm->sm_type, sm->sm_data);
         sm->sm_data = NULL;
       }
@@ -1500,8 +1500,8 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
       }
       content_len -= r;
       if (sub) {
-        sub->ths_bytes_in += r;
-        sub->ths_bytes_out += r;
+        subscription_add_bytes_in(sub, r);
+        subscription_add_bytes_out(sub, r);
       }
     }
   }