]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
streaming msg: add basic memoryinfo support
authorJaroslav Kysela <perex@perex.cz>
Sun, 13 Nov 2016 21:04:24 +0000 (22:04 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 13 Nov 2016 21:04:24 +0000 (22:04 +0100)
src/main.c
src/streaming.c
src/streaming.h

index 7f80f94b59a8a94e5cd114522dbd31dd9c734846..cdec71406bffa311e5e92cb9c34c2f541cc58940 100644 (file)
@@ -72,6 +72,7 @@
 #include "bouquet.h"
 #include "tvhtime.h"
 #include "packet.h"
+#include "streaming.h"
 #include "memoryinfo.h"
 
 #ifdef PLATFORM_LINUX
@@ -1179,6 +1180,8 @@ main(int argc, char **argv)
   tvhthread_create(&mtimer_tick_tid, NULL, mtimer_tick_thread, NULL, "mtick");
   tvhthread_create(&tasklet_tid, NULL, tasklet_thread, NULL, "tasklet");
 
+  streaming_init();
+
   tvh_hardware_init();
 
   dbus_server_init(opt_dbus, opt_dbus_session);
@@ -1352,6 +1355,7 @@ main(int argc, char **argv)
   tvhlog(LOG_NOTICE, LS_STOP, "Exiting HTS Tvheadend");
   tvhlog_end();
 
+  tvhftrace(LS_MAIN, streaming_done);
   tvhftrace(LS_MAIN, config_done);
   tvhftrace(LS_MAIN, hts_settings_done);
 
index 26ddb98dfcbacf3d4ea752ca3eb2bfecb7e3a6ec..827ab366fd326657b23f64143201fe56e6a0f0a7 100644 (file)
@@ -26,6 +26,8 @@
 #include "service.h"
 #include "timeshift.h"
 
+static memoryinfo_t streaming_msg_memoryinfo = { .my_name = "Streaming message" };
+
 void
 streaming_pad_init(streaming_pad_t *sp)
 {
@@ -196,6 +198,7 @@ streaming_message_t *
 streaming_msg_create(streaming_message_type_t type)
 {
   streaming_message_t *sm = malloc(sizeof(streaming_message_t));
+  memoryinfo_alloc(&streaming_msg_memoryinfo, sizeof(*sm));
   sm->sm_type = type;
 #if ENABLE_TIMESHIFT
   sm->sm_time      = 0;
@@ -251,6 +254,8 @@ streaming_msg_clone(streaming_message_t *src)
   streaming_message_t *dst = malloc(sizeof(streaming_message_t));
   streaming_start_t *ss;
 
+  memoryinfo_alloc(&streaming_msg_memoryinfo, sizeof(*dst));
+
   dst->sm_type      = src->sm_type;
 #if ENABLE_TIMESHIFT
   dst->sm_time      = src->sm_time;
@@ -376,6 +381,7 @@ streaming_msg_free(streaming_message_t *sm)
   default:
     abort();
   }
+  memoryinfo_free(&streaming_msg_memoryinfo, sizeof(*sm));
   free(sm);
 }
 
@@ -576,3 +582,18 @@ streaming_component_audio_type2desc(int audio_type)
 
   return N_("Reserved");
 }
+
+/*
+ *
+ */
+void streaming_init(void)
+{
+  memoryinfo_register(&streaming_msg_memoryinfo);
+}
+
+void streaming_done(void)
+{
+  pthread_mutex_lock(&global_lock);
+  memoryinfo_unregister(&streaming_msg_memoryinfo);
+  pthread_mutex_unlock(&global_lock);
+}
index 4e7e4ca798f723f897392e7b0d711b3e9a374932..b35647d50ebedd24f023afe037c65e2aca69194e 100644 (file)
@@ -129,6 +129,7 @@ const char *streaming_code2txt(int code);
 
 streaming_start_component_t *streaming_start_component_find_by_index(streaming_start_t *ss, int idx);
 
-
+void streaming_init(void);
+void streaming_done(void);
 
 #endif /* STREAMING_H_ */