]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
profile: improve prch_sq destroy
authorJaroslav Kysela <perex@perex.cz>
Wed, 11 Mar 2015 14:09:29 +0000 (15:09 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 11 Mar 2015 20:41:13 +0000 (21:41 +0100)
src/profile.c
src/profile.h

index c21ededc44be48ef54f07442cb1af171f62f42a1..96e8078dc822e04db8333be79431504a7e2f26db 100644 (file)
@@ -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;
 }
 
 /*
index 2d8fb13ae36fb4878e03b7c0ab47a39af2d668d9..a763dbaffd824e47d7cf598270cc799eb7392fd9 100644 (file)
@@ -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;