summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoehring <Thomas.Goehring@continental-corporation.com>2013-03-18 11:37:39 +0100
committerChristian Linke <christian.linke@bmw.de>2013-03-18 15:50:41 +0100
commitdc67e14b676265b51d896dd0e7fbd63471eb93c1 (patch)
tree638935ceb2db55a0bac385f187a949e90debad62
parentbffaebb2ae000e64daf82e67d1614883d9ab1da9 (diff)
downloadaudiomanager-dc67e14b676265b51d896dd0e7fbd63471eb93c1.tar.gz
Audiomanagerhandling of signals in excalibur release incorrect
Signed-off-by: Goehring <Thomas.Goehring@continental-corporation.com>
-rw-r--r--AudioManagerDaemon/include/CAmControlSender.h38
-rw-r--r--AudioManagerDaemon/src/CAmControlReceiver.cpp5
-rw-r--r--AudioManagerDaemon/src/CAmControlSender.cpp44
-rw-r--r--AudioManagerDaemon/src/CAmRoutingReceiver.cpp2
-rwxr-xr-xAudioManagerDaemon/src/main.cpp38
-rw-r--r--AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp2
-rw-r--r--AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt2
-rw-r--r--AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp2
-rw-r--r--AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt2
-rw-r--r--AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp2
-rw-r--r--AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt2
-rw-r--r--AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp2
-rw-r--r--AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt2
-rw-r--r--AudioManagerDaemon/test/AmSocketHandlerTest/CMakeLists.txt3
-rw-r--r--PluginControlInterface/src/CAmControlSenderBase.cpp24
-rw-r--r--PluginRoutingInterfaceAsync/test/CMakeLists.txt5
16 files changed, 154 insertions, 21 deletions
diff --git a/AudioManagerDaemon/include/CAmControlSender.h b/AudioManagerDaemon/include/CAmControlSender.h
index 2a9c0fa..495f5d8 100644
--- a/AudioManagerDaemon/include/CAmControlSender.h
+++ b/AudioManagerDaemon/include/CAmControlSender.h
@@ -27,6 +27,8 @@
#endif
#include "control/IAmControlSend.h"
+#include "shared/CAmSocketHandler.h"
+#include "unistd.h"
namespace am
{
@@ -37,7 +39,7 @@ namespace am
class CAmControlSender
{
public:
- CAmControlSender(std::string controlPluginFile);
+ CAmControlSender(std::string controlPluginFile,CAmSocketHandler* sockethandler);
~CAmControlSender();
am_Error_e startupController(IAmControlReceive* controlreceiveinterface) ;
void setControllerReady() ;
@@ -87,12 +89,46 @@ public:
void confirmCommandRundown() ;
void confirmRoutingRundown() ;
+ void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ bool checkerCallback(const sh_pollHandle_t handle, void* userData);
+ bool dispatcherCallback(const sh_pollHandle_t handle, void* userData);
+
+ void setControllerRundownSafe()
+ {
+ int16_t dummy(0);
+ write(mPipe[1], &dummy, sizeof(dummy));
+ }
+
+ TAmShPollFired<CAmControlSender> receiverCallbackT;
+ TAmShPollCheck<CAmControlSender> checkerCallbackT;
+ TAmShPollDispatch<CAmControlSender> dispatcherCallbackT;
+
+ //we need this here to call the rundown from the signal handler. In case everything screwed up
+ static void CallsetControllerRundown()
+ {
+ if (mInstance)
+ {
+ mInstance->setControllerRundown();
+ }
+ }
+
+ //this static callback is used from the signal handler. It is used when a normal rundown is assumed and the mainloop is used to call rundown.
+ static void CallsetControllerRundownSafe()
+ {
+ if (mInstance)
+ {
+ mInstance->setControllerRundownSafe();
+ }
+ }
+
#ifdef UNIT_TEST
friend class IAmControlBackdoor;
#endif
private:
+ int mPipe[2];
void* mlibHandle; //!< pointer to the loaded control plugin interface
IAmControlSend* mController; //!< pointer to the ControlSend interface
+ static CAmControlSender* mInstance;
};
}
diff --git a/AudioManagerDaemon/src/CAmControlReceiver.cpp b/AudioManagerDaemon/src/CAmControlReceiver.cpp
index a6506ad..79a5f65 100644
--- a/AudioManagerDaemon/src/CAmControlReceiver.cpp
+++ b/AudioManagerDaemon/src/CAmControlReceiver.cpp
@@ -21,6 +21,7 @@
#include "CAmControlReceiver.h"
#include <cassert>
+#include <stdlib.h>
#include "config.h"
#include "CAmDatabaseHandler.h"
#include "CAmRoutingSender.h"
@@ -483,6 +484,10 @@ void CAmControlReceiver::confirmControllerReady()
void CAmControlReceiver::confirmControllerRundown()
{
//todo: one time implement here system interaction with NSM
+ logInfo("CAmControlReceiver::confirmControllerRundown got called");
+
+ logInfo("exit ...");
+ exit(0);
}
am_Error_e CAmControlReceiver::getSocketHandler(CAmSocketHandler *& socketHandler)
diff --git a/AudioManagerDaemon/src/CAmControlSender.cpp b/AudioManagerDaemon/src/CAmControlSender.cpp
index 77cec9f..67457f3 100644
--- a/AudioManagerDaemon/src/CAmControlSender.cpp
+++ b/AudioManagerDaemon/src/CAmControlSender.cpp
@@ -23,6 +23,7 @@
#include <cassert>
#include <fstream>
#include <iostream>
+#include <stdlib.h>
#include <sstream>
#include <stdexcept>
#include "TAmPluginTemplate.h"
@@ -34,10 +35,16 @@ namespace am
#define REQUIRED_INTERFACE_VERSION_MAJOR 1 //!< major interface version. All versions smaller than this will be rejected
#define REQUIRED_INTERFACE_VERSION_MINOR 0 //!< minor interface version. All versions smaller than this will be rejected
-CAmControlSender::CAmControlSender(std::string controlPluginFile) :
+CAmControlSender* CAmControlSender::mInstance=NULL;
+CAmControlSender::CAmControlSender(std::string controlPluginFile,CAmSocketHandler* sockethandler) :
+ receiverCallbackT(this, &CAmControlSender::receiverCallback),//
+ checkerCallbackT(this, &CAmControlSender::checkerCallback),//
+ dispatcherCallbackT(this, &CAmControlSender::dispatcherCallback), //
+ mPipe(), //
mlibHandle(NULL), //
mController(NULL)
{
+ assert(sockethandler);
std::ifstream isfile(controlPluginFile.c_str());
if (!isfile)
{
@@ -45,6 +52,7 @@ CAmControlSender::CAmControlSender(std::string controlPluginFile) :
}
else if (!controlPluginFile.empty())
{
+ mInstance=this;
IAmControlSend* (*createFunc)();
createFunc = getCreateFunction<IAmControlSend*()>(controlPluginFile, mlibHandle);
assert(createFunc!=NULL);
@@ -67,6 +75,15 @@ CAmControlSender::CAmControlSender(std::string controlPluginFile) :
{
logError("ControlSender::ControlSender: No controller loaded !");
}
+ if (pipe(mPipe) == -1)
+ {
+ logError("CAmControlSender could not create pipe!");
+ }
+
+ short event = 0;
+ sh_pollHandle_t handle;
+ event |= POLLIN;
+ sockethandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, handle);
}
CAmControlSender::~CAmControlSender()
@@ -360,4 +377,29 @@ void CAmControlSender::confirmRoutingRundown()
assert(mController);
mController->confirmRoutingRundown();
}
+
+void CAmControlSender::receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
+{
+ (void) handle;
+ (void) userData;
+ //get the signal number from the socket
+ int16_t dummy;
+ read(pollfd.fd, &dummy, sizeof(dummy));
+}
+
+bool CAmControlSender::checkerCallback(const sh_pollHandle_t handle, void* userData)
+{
+ (void) handle;
+ (void) userData;
+ return (true);
+}
+
+bool CAmControlSender::dispatcherCallback(const sh_pollHandle_t handle, void* userData)
+{
+ (void)handle;
+ (void)userData;
+ setControllerRundown();
+ return (false);
+}
+
}
diff --git a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp
index 40ebd8d..f0821a9 100644
--- a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp
+++ b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp
@@ -356,7 +356,7 @@ void CAmRoutingReceiver::confirmRoutingRundown(const uint16_t handle)
{
mListRundownHandles.erase(std::remove(mListRundownHandles.begin(), mListRundownHandles.end(), handle), mListRundownHandles.end());
if (mWaitRundown && mListRundownHandles.empty())
- mpControlSender->confirmCommandRundown();
+ mpControlSender->confirmRoutingRundown();
}
uint16_t am::CAmRoutingReceiver::getStartupHandle()
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index b9eade1..b82d1ff 100755
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -264,10 +264,37 @@ static void signalHandler(int sig, siginfo_t *siginfo, void *context)
(void) sig;
(void) siginfo;
(void) context;
- logError("signal handler was called, exit now...");
- gDispatchDone = 1;
- //todo: maually fire the mainloop
- exit(1);
+
+ switch (sig)
+ {
+ /*ctl +c lets call direct controllerRundown, because we might be blocked at the moment.
+ But there is the risk of interrupting something important */
+ case SIGINT:
+ logInfo("signal handler was called SIGINT");
+ CAmControlSender::CallsetControllerRundown();
+ break;
+
+ /* huch- we are getting killed. Better take the fast but risky way: */
+ case SIGQUIT:
+ logInfo("signal handler was called SIGQUIT");
+ CAmControlSender::CallsetControllerRundown();
+ break;
+
+ /* more friendly here assuming systemd wants to stop us, so we can use the mainloop */
+ case SIGTERM:
+ logInfo("signal handler was called SIGTERM");
+ CAmControlSender::CallsetControllerRundownSafe();
+ break;
+
+ /* looks friendly, too, so lets take the long run */
+ case SIGHUP:
+ logInfo("signal handler was called SIGHUP");
+ CAmControlSender::CallsetControllerRundownSafe();
+ break;
+ default:
+ logInfo("signal handler was called", sig);
+ break;
+ }
}
void mainProgram()
@@ -286,7 +313,7 @@ void mainProgram()
CAmDatabaseHandler iDatabaseHandler(databasePath);
CAmRoutingSender iRoutingSender(listRoutingPluginDirs);
CAmCommandSender iCommandSender(listCommandPluginDirs);
- CAmControlSender iControlSender(controllerPlugin);
+ CAmControlSender iControlSender(controllerPlugin, &iSocketHandler);
CAmRouter iRouter(&iDatabaseHandler, &iControlSender);
#ifdef WITH_DBUS_WRAPPER
@@ -354,7 +381,6 @@ int main(int argc, char *argv[], char** envp)
sigaction(SIGQUIT, &signalAction, NULL);
sigaction(SIGTERM, &signalAction, NULL);
sigaction(SIGHUP, &signalAction, NULL);
- sigaction(SIGQUIT, &signalAction, NULL);
struct sigaction signalChildAction;
memset(&signalChildAction, '\0', sizeof(signalChildAction));
diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
index c4f71e1..e80287b 100644
--- a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
@@ -43,7 +43,7 @@ CAmControlInterfaceTest::CAmControlInterfaceTest() :
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
pControlInterfaceBackdoor(), //
- pControlSender(std::string("")), //
+ pControlSender(std::string(""), &pSocketHandler), //
pRouter(&pDatabaseHandler,&pControlSender), //
pDatabaseObserver(&pCommandSender, &pRoutingSender, &pSocketHandler), //
pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), //
diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt
index 213ccb1..dcb5ed4 100644
--- a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt
@@ -66,6 +66,8 @@ TARGET_LINK_LIBRARIES(AmControlInterfaceTest
${CMAKE_THREAD_LIBS_INIT}
${GTEST_LIBRARIES}
gmock
+ ${CMAKE_DL_LIBS}
+ rt
)
INSTALL(TARGETS AmControlInterfaceTest
diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp
index a1b7e39..f81e66d 100644
--- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp
+++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp
@@ -45,7 +45,7 @@ CAmDatabaseHandlerTest::CAmDatabaseHandlerTest() :
pMockInterface(), //
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
- pControlSender(""), //
+ pControlSender("", &pSocketHandler), //
pRouter(&pDatabaseHandler, &pControlSender), //
pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), //
pObserver(&pCommandSender,&pRoutingSender, &pSocketHandler)
diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt
index 6d5b685..ea8ee0c 100644
--- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt
@@ -65,6 +65,8 @@ TARGET_LINK_LIBRARIES( AmDatabaseHandlerTest
${CMAKE_THREAD_LIBS_INIT}
${GTEST_LIBRARIES}
gmock
+ ${CMAKE_DL_LIBS}
+ rt
)
INSTALL(TARGETS AmDatabaseHandlerTest
diff --git a/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp b/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp
index 0758a01..ac2dd6a 100644
--- a/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp
+++ b/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp
@@ -30,7 +30,7 @@ CAmRouterTest::CAmRouterTest() :
plistCommandPluginDirs(), //
pSocketHandler(), //
pDatabaseHandler(std::string(":memory:")), //
- pControlSender(std::string("")), //
+ pControlSender(std::string(""), &pSocketHandler), //
pRouter(&pDatabaseHandler, &pControlSender), //
pRoutingSender(plistRoutingPluginDirs), //
pCommandSender(plistCommandPluginDirs), //
diff --git a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt
index 906fe1a..a2f8860 100644
--- a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt
@@ -65,6 +65,8 @@ TARGET_LINK_LIBRARIES( AmRouterTest
${CMAKE_THREAD_LIBS_INIT}
${GTEST_LIBRARIES}
gmock
+ ${CMAKE_DL_LIBS}
+ rt
)
INSTALL(TARGETS AmRouterTest
diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
index 47181b3..ee9f55c 100644
--- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
@@ -31,7 +31,7 @@ CAmRoutingInterfaceTest::CAmRoutingInterfaceTest() :
pDatabaseHandler(std::string(":memory:")), //
pRoutingSender(plistRoutingPluginDirs), //
pCommandSender(plistCommandPluginDirs), //
- pControlSender(""), //
+ pControlSender("", &pSocketHandler), //
pRouter(&pDatabaseHandler, &pControlSender), //
pMockInterface(), //
pRoutingInterfaceBackdoor(), //
diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt
index a797b67..5f8bcd6 100644
--- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt
@@ -66,6 +66,8 @@ TARGET_LINK_LIBRARIES(AmRoutingInterfaceTest
${CMAKE_THREAD_LIBS_INIT}
${GTEST_LIBRARIES}
gmock
+ ${CMAKE_DL_LIBS}
+ rt
)
INSTALL(TARGETS AmRoutingInterfaceTest
diff --git a/AudioManagerDaemon/test/AmSocketHandlerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmSocketHandlerTest/CMakeLists.txt
index c5edaa7..dbfc40c 100644
--- a/AudioManagerDaemon/test/AmSocketHandlerTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmSocketHandlerTest/CMakeLists.txt
@@ -61,6 +61,9 @@ TARGET_LINK_LIBRARIES(AmSocketHandlerTest
${CMAKE_THREAD_LIBS_INIT}
gtest
gmock
+ ${CMAKE_DL_LIBS}
+ rt
+ pthread
)
INSTALL(TARGETS AmSocketHandlerTest
diff --git a/PluginControlInterface/src/CAmControlSenderBase.cpp b/PluginControlInterface/src/CAmControlSenderBase.cpp
index 2878306..aa21503 100644
--- a/PluginControlInterface/src/CAmControlSenderBase.cpp
+++ b/PluginControlInterface/src/CAmControlSenderBase.cpp
@@ -72,9 +72,11 @@ am_Error_e CAmControlSenderBase::startupController(IAmControlReceive *controlrec
void CAmControlSenderBase::setControllerReady()
{
+ logInfo("ControlSenderPlugin set Controller Ready");
+
//here is a good place to insert Source and SinkClasses into the database...
+
mControlReceiveInterface->setRoutingReady();
- mControlReceiveInterface->setCommandReady();
}
am_Error_e CAmControlSenderBase::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
@@ -558,6 +560,13 @@ void CAmControlSenderBase::cbAckSetSinkSoundProperties(const am_Handle_s handle,
void CAmControlSenderBase::setControllerRundown()
{
+ logInfo("ControlSenderPlugin set Controller Rundown");
+
+ mControlReceiveInterface->setCommandRundown();
+ mControlReceiveInterface->setRoutingRundown();
+
+ logInfo("ControlSenderPlugin confirming Controller Rundown");
+ mControlReceiveInterface->confirmControllerRundown();
}
am_Error_e CAmControlSenderBase::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_ConnectionFormat_e> listPossibleConnectionFormats, std::vector<am_ConnectionFormat_e> & listPrioConnectionFormats)
@@ -577,17 +586,22 @@ void CAmControlSenderBase::getInterfaceVersion(std::string & version) const
void CAmControlSenderBase::confirmCommandReady()
{
- logInfo("ControlSenderPlugin got Routing Ready confirmed");
+ logInfo("ControlSenderPlugin got Command Ready confirmed");
+
+ logInfo("ControlSenderPlugin confirming Controller Ready");
+ mControlReceiveInterface->confirmControllerReady();
}
void CAmControlSenderBase::confirmRoutingReady()
{
- logInfo("ControlSenderPlugin got Command Ready confirmed");
+ logInfo("ControlSenderPlugin got Routing Ready confirmed");
+
+ mControlReceiveInterface->setCommandReady();
}
void CAmControlSenderBase::confirmRoutingRundown()
{
- logInfo("ControlSenderPlugin got Command Rundown confirmed");
+ logInfo("ControlSenderPlugin got Routing Rundown confirmed");
}
void CAmControlSenderBase::disconnect(am_mainConnectionID_t connectionID)
@@ -621,7 +635,7 @@ void CAmControlSenderBase::disconnect(am_mainConnectionID_t connectionID)
void CAmControlSenderBase::confirmCommandRundown()
{
- logInfo("ControlSenderPlugin got Routing Rundown confirmed");
+ logInfo("ControlSenderPlugin got Command Rundown confirmed");
}
void CAmControlSenderBase::connect(am_sourceID_t sourceID, am_sinkID_t sinkID, am_mainConnectionID_t mainConnectionID)
diff --git a/PluginRoutingInterfaceAsync/test/CMakeLists.txt b/PluginRoutingInterfaceAsync/test/CMakeLists.txt
index 039239d..cb57180 100644
--- a/PluginRoutingInterfaceAsync/test/CMakeLists.txt
+++ b/PluginRoutingInterfaceAsync/test/CMakeLists.txt
@@ -25,9 +25,8 @@ FIND_PACKAGE(GTest REQUIRED)
find_package (Threads)
FIND_PACKAGE(PkgConfig)
FIND_PACKAGE(DBUS REQUIRED)
-IF(WITH_DLT)
- pkg_check_modules(DLT REQUIRED automotive-dlt)
-)
+IF(WITH_DLT)
+ pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
ENDIF(WITH_DLT)
pkg_check_modules(SQLITE REQUIRED sqlite3)