Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
streaming msg: add basic memoryinfo support
  • Loading branch information
perexg committed Nov 13, 2016
1 parent 2411090 commit 879d532
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main.c
Expand Up @@ -72,6 +72,7 @@
#include "bouquet.h"
#include "tvhtime.h"
#include "packet.h"
#include "streaming.h"
#include "memoryinfo.h"

#ifdef PLATFORM_LINUX
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
21 changes: 21 additions & 0 deletions src/streaming.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -376,6 +381,7 @@ streaming_msg_free(streaming_message_t *sm)
default:
abort();
}
memoryinfo_free(&streaming_msg_memoryinfo, sizeof(*sm));
free(sm);
}

Expand Down Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion src/streaming.h
Expand Up @@ -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_ */

0 comments on commit 879d532

Please sign in to comment.