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.c69
1 files changed, 50 insertions, 19 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..4c89041d 100644
--- a/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
+++ b/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
@@ -1,16 +1,17 @@
/*************************************************************************************************************
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
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS LISTED "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -21,10 +22,10 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Attributions: The inih library portion of the source code is licensed from
-Brush Technology and Ben Hoyt - Copyright (c) 2009, Brush Technology and Copyright (c) 2009, Ben Hoyt.
-Complete license and copyright information can be found at
+
+Attributions: The inih library portion of the source code is licensed from
+Brush Technology and Ben Hoyt - Copyright (c) 2009, Brush Technology and Copyright (c) 2009, Ben Hoyt.
+Complete license and copyright information can be found at
https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175.
*************************************************************************************************************/
@@ -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");
@@ -115,6 +122,7 @@ void openavbTlHarnessUsage(char *programName)
" -s val Stream count. Starts 'val' number of streams for each configuration file. stream_uid will be overriden.\n"
" -d val Last byte of destination address from static pool. Full address will be 91:e0:f0:00:fe:val.\n"
" -I val Use given (val) interface globally, can be overriden by giving the ifname= option to the config line.\n"
+ " -l val Filename of the log file to use. If not specified, results will be logged to stderr.\n"
"\n"
"Examples:\n"
" %s talker.ini\n"
@@ -165,6 +173,7 @@ int main(int argc, char *argv[])
bool optDestAddrSet = FALSE;
U8 destAddr[ETH_ALEN] = {0x91, 0xe0, 0xf0, 0x00, 0xfe, 0x00};
char *optIfnameGlobal = NULL;
+ char *optLogFileName = NULL;
// Talker listener vars
int iniIdx = 0;
@@ -182,8 +191,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);
@@ -218,7 +231,7 @@ int main(int argc, char *argv[])
bool optDone = FALSE;
while (!optDone) {
- int opt = getopt(argc, argv, "a:his:d:I:");
+ int opt = getopt(argc, argv, "a:his:d:I:l:");
if (opt != EOF) {
switch (opt) {
case 'a':
@@ -238,6 +251,9 @@ int main(int argc, char *argv[])
case 'I':
optIfnameGlobal = strdup(optarg);
break;
+ case 'l':
+ optLogFileName = strdup(optarg);
+ break;
case '?':
default:
openavbTlHarnessUsage(programName);
@@ -249,7 +265,7 @@ int main(int argc, char *argv[])
}
}
- osalAVBInitialize(optIfnameGlobal);
+ osalAVBInitialize(optLogFileName, optIfnameGlobal);
// Setup the talker listener counts and lists
iniIdx = optind;
@@ -354,14 +370,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 +392,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 +527,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]);
@@ -533,6 +559,11 @@ int main(int argc, char *argv[])
optStreamAddr = NULL;
}
+ if (optLogFileName) {
+ free(optLogFileName);
+ optLogFileName = NULL;
+ }
+
#ifdef AVB_FEATURE_GSTREAMER
// If we're supporting the interface modules which use GStreamer,
// De-initialize GStreamer to clean up resources.