From ffa0639149d0120aad3bbce2a307972e467deb1b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 11 Mar 2015 15:09:29 +0100 Subject: [PATCH] profile: improve prch_sq destroy --- src/profile.c | 10 +++++++++- src/profile.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/profile.c b/src/profile.c index c21ededc..96e8078d 100644 --- a/src/profile.c +++ b/src/profile.c @@ -680,6 +680,7 @@ profile_chain_init(profile_chain_t *prch, profile_t *pro, void *id) prch->prch_pro = pro; prch->prch_id = id; streaming_queue_init(&prch->prch_sq, 0, 0); + prch->prch_sq_used = 1; LIST_INSERT_HEAD(&profile_chains, prch, prch_link); prch->prch_linked = 1; prch->prch_stop = 1; @@ -738,6 +739,7 @@ profile_chain_raw_open(profile_chain_t *prch, void *id, size_t qsize) prch->prch_id = id; prch->prch_flags = SUBSCRIPTION_RAW_MPEGTS; streaming_queue_init(&prch->prch_sq, SMT_PACKET, qsize); + prch->prch_sq_used = 1; prch->prch_st = &prch->prch_sq.sq_st; prch->prch_muxer = muxer_create(&c); return 0; @@ -772,8 +774,12 @@ profile_chain_close(profile_chain_t *prch) prch->prch_st = NULL; - if (prch->prch_linked) { + if (prch->prch_sq_used) { streaming_queue_deinit(&prch->prch_sq); + prch->prch_sq_used = 0; + } + + if (prch->prch_linked) { LIST_REMOVE(prch, prch_link); prch->prch_linked = 0; } @@ -782,6 +788,8 @@ profile_chain_close(profile_chain_t *prch) profile_release(prch->prch_pro); prch->prch_pro = NULL; } + + prch->prch_id = NULL; } /* diff --git a/src/profile.h b/src/profile.h index 2d8fb13a..a763dbaf 100644 --- a/src/profile.h +++ b/src/profile.h @@ -74,6 +74,7 @@ typedef struct profile_chain { int prch_flags; int prch_stop; int prch_start_pending; + int prch_sq_used; struct streaming_queue prch_sq; struct streaming_target *prch_post_share; struct streaming_target *prch_st;