From: Jaroslav Kysela Date: Sun, 13 Nov 2016 21:04:24 +0000 (+0100) Subject: streaming msg: add basic memoryinfo support X-Git-Tag: v4.2.1~223 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=879d532b070483ec443f28f6f0529e2038a2ec15;p=thirdparty%2Ftvheadend.git streaming msg: add basic memoryinfo support --- diff --git a/src/main.c b/src/main.c index 7f80f94b5..cdec71406 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/streaming.c b/src/streaming.c index 26ddb98df..827ab366f 100644 --- a/src/streaming.c +++ b/src/streaming.c @@ -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); +} diff --git a/src/streaming.h b/src/streaming.h index 4e7e4ca79..b35647d50 100644 --- a/src/streaming.h +++ b/src/streaming.h @@ -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_ */