21 #include <sys/prctl.h>
25 #ifdef ENABLE_BREAKPAD
26 #include <client/linux/handler/exception_handler.h>
29 #include "rdkmediaplayer.h"
31 #include "glib_tools.h"
32 #include "hangdetector_utils.h"
34 #ifdef BCM_SVP_ENABLED
35 #include "nexus_config.h"
36 #include "nexus_platform.h"
40 #ifdef ENABLE_SIGNAL_HANDLE
47 GMainLoop *gMainLoop = 0;
50 #ifdef ENABLE_BREAKPAD
55 bool breakpadCallback(
const google_breakpad::MinidumpDescriptor& ,
void* ,
bool succeeded) {
60 void installExceptionHandler() {
61 static google_breakpad::ExceptionHandler* excHandler = NULL;
63 excHandler =
new google_breakpad::ExceptionHandler(
64 google_breakpad::MinidumpDescriptor(
"/opt/minidumps"),
75 #ifdef ENABLE_SIGNAL_HANDLER
76 void signalHandler(
int signum)
78 printf(
"signalHandler %d\n", signum);
79 rtError e = rtRemoteShutdown();
82 printf(
"rtRemoteShutdown failed: %s \n", rtStrError(e));
84 signal(signum, SIG_DFL);
85 kill(getpid(), signum);
89 void rtMainLoopCb(
void*)
91 rtError err = rtRemoteProcessSingleItem();
92 if(err != RT_OK && err != RT_ERROR_QUEUE_EMPTY)
94 LOG_WARNING(
"rtRemoteProcessSingleItem() returned %d", err);
98 void rtRemoteCallback(
void*)
102 int ret = HANDLE_EINTR_EAGAIN(write(gPipefd[PIPE_WRITE], temp, 1));
104 perror(
"can't write to pipe");
107 int main(
int argc,
char *argv[]) {
109 hangDetector.start();
110 prctl(PR_SET_PDEATHSIG, SIGHUP);
112 #ifdef ENABLE_BREAKPAD
113 installExceptionHandler();
116 #ifdef ENABLE_SIGNAL_HANDLER
117 signal(SIGINT, signalHandler);
118 signal(SIGQUIT, signalHandler);
119 signal(SIGTERM, signalHandler);
120 signal(SIGILL, signalHandler);
121 signal(SIGABRT, signalHandler);
122 signal(SIGFPE, signalHandler);
123 signal(SIGSEGV, signalHandler);
125 #ifdef BCM_SVP_ENABLED
127 rt = NxClient_Join(NULL);
128 ASSERT(rt == NEXUS_SUCCESS);
136 gMainLoop = g_main_loop_new(0, FALSE);
139 g_source_attach(source, g_main_loop_get_context(gMainLoop));
141 rtRemoteRegisterQueueReadyHandler( rtEnvironmentGetGlobal(), rtRemoteCallback,
nullptr );
146 const char* objectName = getenv(
"PX_WAYLAND_CLIENT_REMOTE_OBJECT_NAME");
147 if (!objectName) objectName =
"rdkmediaplayer";
148 LOG_INFO(
"Register: %s", objectName);
151 rc = rtRemoteRegisterObject(objectName, playerRef);
156 g_main_loop_run(gMainLoop);
157 g_main_loop_unref(gMainLoop);
164 rc = rtRemoteShutdown();
168 #ifdef BCM_SVP_ENABLED
171 g_source_unref(source);