Start of 1.9.14 development
[jack2.git] / android / JackControlAPIAndroid.cpp
bloba915b4ddaadeba65b433b84be444527fcdf9a25b
1 // u/* -*- Mode: C++ ; c-basic-offset: 4 -*- */
2 /*
3 JACK control API implementation
5 Copyright (C) 2008 Nedko Arnaudov
6 Copyright (C) 2008 Grame
7 Copyright (C) 2013 Samsung Electronics
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef WIN32
25 #include <stdint.h>
26 #include <dirent.h>
27 #include <pthread.h>
28 #endif
30 #include "types.h"
31 #include <string.h>
32 #include <errno.h>
33 #include <stdio.h>
34 #include <assert.h>
35 #include <signal.h>
37 #include "JackControlAPIAndroid.h"
38 #include "JackConstants.h"
39 #include "JackServerGlobals.h"
41 using namespace Jack;
43 struct jackctl_sigmask
45 sigset_t signals;
48 static jackctl_sigmask sigmask;
50 SERVER_EXPORT int
51 jackctl_wait_signals_and_return(jackctl_sigmask_t * sigmask)
53 int sig;
54 bool waiting = true;
56 while (waiting) {
57 #if defined(sun) && !defined(__sun__) // SUN compiler only, to check
58 sigwait(&sigmask->signals);
59 #else
60 sigwait(&sigmask->signals, &sig);
61 #endif
62 fprintf(stderr, "Jack main caught signal %d\n", sig);
64 switch (sig) {
65 case SIGUSR1:
66 //jack_dump_configuration(engine, 1);
67 break;
68 case SIGUSR2:
69 // driver exit
70 waiting = false;
71 break;
72 case SIGTTOU:
73 break;
74 default:
75 waiting = false;
76 break;
80 if (sig != SIGSEGV) {
81 // unblock signals so we can see them during shutdown.
82 // this will help prod developers not to lose sight of
83 // bugs that cause segfaults etc. during shutdown.
84 sigprocmask(SIG_UNBLOCK, &sigmask->signals, 0);
87 return sig;