From 085fd8946578d7b68965872c70a63ea1dd8a7ef3 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 23 Nov 2014 17:47:42 +0100 Subject: [PATCH] service: another STOP/START msg cleanup --- src/service.c | 5 ++++- src/service.h | 1 + src/subscriptions.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/service.c b/src/service.c index db1438c5..3d61043b 100644 --- a/src/service.c +++ b/src/service.c @@ -1159,7 +1159,8 @@ service_restart(service_t *t) pthread_mutex_lock(&t->s_stream_mutex); - had_components = TAILQ_FIRST(&t->s_filt_components) != NULL; + had_components = TAILQ_FIRST(&t->s_filt_components) != NULL && + t->s_running; service_build_filter(t); @@ -1172,10 +1173,12 @@ service_restart(service_t *t) streaming_pad_deliver(&t->s_streaming_pad, streaming_msg_create_data(SMT_START, service_build_stream_start(t))); + t->s_running = 1; } else { streaming_pad_deliver(&t->s_streaming_pad, streaming_msg_create_code(SMT_STOP, SM_CODE_NO_SERVICE)); + t->s_running = 0; } pthread_mutex_unlock(&t->s_stream_mutex); diff --git a/src/service.h b/src/service.h index 950f40f2..ce44900f 100644 --- a/src/service.h +++ b/src/service.h @@ -411,6 +411,7 @@ typedef struct service { * */ int s_streaming_live; + int s_running; // Live status #define TSS_LIVE 0x01 diff --git a/src/subscriptions.c b/src/subscriptions.c index 7bafb891..1b313f8d 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -100,6 +100,7 @@ subscription_link_service(th_subscription_t *s, service_t *t) // Send a START message to the subscription client streaming_target_deliver(s->ths_output, s->ths_start_message); s->ths_start_message = NULL; + t->s_running = 1; // Send status report sm = streaming_msg_create_code(SMT_SERVICE_STATUS, @@ -134,6 +135,7 @@ subscription_unlink_service0(th_subscription_t *s, int reason, int stop) // Send a STOP message to the subscription client sm = streaming_msg_create_code(SMT_STOP, reason); streaming_target_deliver(s->ths_output, sm); + t->s_running = 0; } pthread_mutex_unlock(&t->s_stream_mutex); @@ -480,6 +482,8 @@ subscription_input(void *opauqe, streaming_message_t *sm) if(s->ths_start_message != NULL) { streaming_target_deliver(s->ths_output, s->ths_start_message); s->ths_start_message = NULL; + if (s->ths_service) + s->ths_service->s_running = 1; } s->ths_state = SUBSCRIPTION_GOT_SERVICE; }