summaryrefslogtreecommitdiff
path: root/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c')
-rw-r--r--lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c b/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
index 71a7a6e4..115d553b 100644
--- a/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
+++ b/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
@@ -1,5 +1,6 @@
/*************************************************************************************************************
Copyright (c) 2012-2015, Symphony Teleca Corporation, a Harman International Industries, Incorporated company
+Copyright (c) 2016-2017, Harman International Industries, Incorporated
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -53,7 +54,7 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175.
bool bRunning = TRUE;
-// Platform indendent mapping modules
+// Platform independent mapping modules
extern bool openavbMapPipeInitialize(media_q_t *pMediaQ, openavb_map_cb_t *pMapCB, U32 inMaxTransitUsec);
extern bool openavbMapAVTPAudioInitialize(media_q_t *pMediaQ, openavb_map_cb_t *pMapCB, U32 inMaxTransitUsec);
extern bool openavbMapCtrlInitialize(media_q_t *pMediaQ, openavb_map_cb_t *pMapCB, U32 inMaxTransitUsec);
@@ -63,7 +64,7 @@ extern bool openavbMapMpeg2tsInitialize(media_q_t *pMediaQ, openavb_map_cb_t *pM
extern bool openavbMapNullInitialize(media_q_t *pMediaQ, openavb_map_cb_t *pMapCB, U32 inMaxTransitUsec);
extern bool openavbMapUncmpAudioInitialize(media_q_t *pMediaQ, openavb_map_cb_t *pMapCB, U32 inMaxTransitUsec);
-// Platform indendent interface modules
+// Platform independent interface modules
extern bool openavbIntfEchoInitialize(media_q_t *pMediaQ, openavb_intf_cb_t *pIntfCB);
extern bool openavbIntfCtrlInitialize(media_q_t *pMediaQ, openavb_intf_cb_t *pIntfCB);
extern bool openavbIntfLoggerInitialize(media_q_t *pMediaQ, openavb_intf_cb_t *pIntfCB);
@@ -90,9 +91,15 @@ static void openavbTLSigHandler(int signal)
{
AVB_TRACE_ENTRY(AVB_TRACE_HOST);
- if (signal == SIGINT) {
- AVB_LOG_INFO("Host shutting down");
- bRunning = FALSE;
+ if (signal == SIGINT || signal == SIGTERM) {
+ if (bRunning) {
+ AVB_LOG_INFO("Host shutting down");
+ bRunning = FALSE;
+ }
+ else {
+ // Force shutdown
+ exit(2);
+ }
}
else if (signal == SIGUSR1) {
AVB_LOG_DEBUG("Waking up streaming thread");
@@ -182,8 +189,12 @@ int main(int argc, char *argv[])
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; // not SA_RESTART
sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
+ // Ignore SIGPIPE signals.
+ signal(SIGPIPE, SIG_IGN);
+
registerStaticMapModule(openavbMapPipeInitialize);
registerStaticMapModule(openavbMapAVTPAudioInitialize);
registerStaticMapModule(openavbMapCtrlInitialize);
@@ -354,14 +365,16 @@ int main(int argc, char *argv[])
if (!optInteractive) {
// Non-interactive mode
- // Run the streams
+ // Run any streams where the stop initial state was not requested.
for (i1 = 0; i1 < tlCount; i1++) {
- printf("Starting: %s\n", tlIniList[i1]);
- openavbTLRun(tlHandleList[i1]);
+ if (openavbTLGetInitialState(tlHandleList[i1]) != TL_INIT_STATE_STOPPED) {
+ printf("Starting: %s\n", tlIniList[i1]);
+ openavbTLRun(tlHandleList[i1]);
+ }
}
while (bRunning) {
- sleep(1);
+ SLEEP_MSEC(1);
}
for (i1 = 0; i1 < tlCount; i1++) {
@@ -374,6 +387,14 @@ int main(int argc, char *argv[])
else {
// Interactive mode
+ // Run any streams where the running initial state was requested.
+ for (i1 = 0; i1 < tlCount; i1++) {
+ if (openavbTLGetInitialState(tlHandleList[i1]) == TL_INIT_STATE_RUNNING) {
+ printf("Starting: %s\n", tlIniList[i1]);
+ openavbTLRun(tlHandleList[i1]);
+ }
+ }
+
openavbTlHarnessMenu();
while (bRunning) {
char buf[16];
@@ -501,7 +522,7 @@ int main(int argc, char *argv[])
// Close the streams
for (i1 = 0; i1 < tlCount; i1++) {
if (tlHandleList[i1]) {
- printf("Stopping: %s\n", tlIniList[i1]);
+ printf("Closing: %s\n", tlIniList[i1]);
openavbTLClose(tlHandleList[i1]);