Commit a6a2d8f0 authored by sletz's avatar sletz
Browse files

In control API, UNIX like sigset_t replaced by more abstract jackctl_sigmask_t * opaque struct.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4775 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 916f55ee
......@@ -36,6 +36,10 @@ John Emmas
Jackdmp changes log
---------------------------
2012-02-09 Stephane Letz <letz@grame.fr>
* In control API, UNIX like sigset_t replaced by more abstract jackctl_sigmask_t * opaque struct.
2012-02-01 Stephane Letz <letz@grame.fr>
* Check server API callback from notification thread.
......
......@@ -440,32 +440,37 @@ jackctl_server_free_parameters(
#ifdef WIN32
static HANDLE waitEvent;
struct jackctl_sigmask
{
HANDLE wait_event;
};
static jackctl_sigmask sigmask;
static void do_nothing_handler(int signum)
static void signal_handler(int signum)
{
printf("Jack main caught signal %d\n", signum);
(void) signal(SIGINT, SIG_DFL);
SetEvent(waitEvent);
SetEvent(sigmask.wait_event);
}
sigset_t
jackctl_sigmask_t *
jackctl_setup_signals(
unsigned int flags)
{
if ((waitEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL) {
if ((sigmask.wait_event = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL) {
jack_error("CreateEvent fails err = %ld", GetLastError());
return 0;
}
(void) signal(SIGINT, do_nothing_handler);
(void) signal(SIGABRT, do_nothing_handler);
(void) signal(SIGTERM, do_nothing_handler);
(void) signal(SIGINT, signal_handler);
(void) signal(SIGABRT, signal_handler);
(void) signal(SIGTERM, signal_handler);
return (sigset_t)waitEvent;
return &sigmask;
}
void jackctl_wait_signals(sigset_t signals)
void jackctl_wait_signals(jackctl_sigmask_t * signals)
{
if (WaitForSingleObject(waitEvent, INFINITE) != WAIT_OBJECT_0) {
jack_error("WaitForSingleObject fails err = %ld", GetLastError());
......@@ -474,23 +479,29 @@ void jackctl_wait_signals(sigset_t signals)
#else
struct jackctl_sigmask
{
sigset_t signals;
};
static jackctl_sigmask sigmask;
static
void
do_nothing_handler(int sig)
signal_handler(int sig)
{
/* this is used by the child (active) process, but it never
gets called unless we are already shutting down after
another signal.
*/
char buf[64];
snprintf (buf, sizeof(buf), "Received signal %d during shutdown (ignored)\n", sig);
snprintf(buf, sizeof(buf), "Received signal %d during shutdown (ignored)\n", sig);
}
SERVER_EXPORT sigset_t
SERVER_EXPORT jackctl_sigmask_t *
jackctl_setup_signals(
unsigned int flags)
{
sigset_t signals;
sigset_t allsignals;
struct sigaction action;
int i;
......@@ -529,52 +540,52 @@ jackctl_setup_signals(
after a return from sigwait().
*/
sigemptyset(&signals);
sigaddset(&signals, SIGHUP);
sigaddset(&signals, SIGINT);
sigaddset(&signals, SIGQUIT);
sigaddset(&signals, SIGPIPE);
sigaddset(&signals, SIGTERM);
sigaddset(&signals, SIGUSR1);
sigaddset(&signals, SIGUSR2);
sigemptyset(&sigmask.signals);
sigaddset(&sigmask.signals, SIGHUP);
sigaddset(&sigmask.signals, SIGINT);
sigaddset(&sigmask.signals, SIGQUIT);
sigaddset(&sigmask.signals, SIGPIPE);
sigaddset(&sigmask.signals, SIGTERM);
sigaddset(&sigmask.signals, SIGUSR1);
sigaddset(&sigmask.signals, SIGUSR2);
/* all child threads will inherit this mask unless they
* explicitly reset it
*/
pthread_sigmask(SIG_BLOCK, &signals, 0);
pthread_sigmask(SIG_BLOCK, &sigmask.signals, 0);
/* install a do-nothing handler because otherwise pthreads
behaviour is undefined when we enter sigwait.
*/
sigfillset(&allsignals);
action.sa_handler = do_nothing_handler;
action.sa_handler = signal_handler;
action.sa_mask = allsignals;
action.sa_flags = SA_RESTART|SA_RESETHAND;
for (i = 1; i < NSIG; i++)
{
if (sigismember (&signals, i))
if (sigismember (&sigmask.signals, i))
{
sigaction(i, &action, 0);
}
}
return signals;
return &sigmask;
}
SERVER_EXPORT void
jackctl_wait_signals(sigset_t signals)
jackctl_wait_signals(jackctl_sigmask_t * sigmask)
{
int sig;
bool waiting = true;
while (waiting) {
#if defined(sun) && !defined(__sun__) // SUN compiler only, to check
sigwait(&signals);
sigwait(&sigmask->signals);
#else
sigwait(&signals, &sig);
sigwait(&sigmask->signals, &sig);
#endif
fprintf(stderr, "Jack main caught signal %d\n", sig);
......@@ -598,7 +609,7 @@ jackctl_wait_signals(sigset_t signals)
// unblock signals so we can see them during shutdown.
// this will help prod developers not to lose sight of
// bugs that cause segfaults etc. during shutdown.
sigprocmask(SIG_UNBLOCK, &signals, 0);
sigprocmask(SIG_UNBLOCK, &sigmask->signals, 0);
}
}
#endif
......
......@@ -25,15 +25,6 @@
#include "jslist.h"
#include "JackCompilerDeps.h"
#ifdef WIN32
#ifdef __MINGW32__
#include <sys/types.h>
typedef _sigset_t sigset_t;
#else
typedef HANDLE sigset_t;
#endif
#endif
/** Parameter types, intentionally similar to jack_driver_param_type_t */
typedef enum
{
......@@ -80,6 +71,9 @@ typedef struct jackctl_internal jackctl_internal_t;
/** opaque type for parameter object */
typedef struct jackctl_parameter jackctl_parameter_t;
/** opaque type for sigmask object */
typedef struct jackctl_sigmask jackctl_sigmask_t;
#ifdef __cplusplus
extern "C" {
#endif
......@@ -87,13 +81,13 @@ extern "C" {
} /* Adjust editor indent */
#endif
SERVER_EXPORT sigset_t
SERVER_EXPORT jackctl_sigmask_t *
jackctl_setup_signals(
unsigned int flags);
SERVER_EXPORT void
jackctl_wait_signals(
sigset_t signals);
jackctl_sigmask_t * signals);
SERVER_EXPORT jackctl_server_t *
jackctl_server_create(
......
......@@ -221,7 +221,6 @@ struct JackNetExtMaster : public JackNetMasterInterface {
}
if (rx_bytes == sizeof(session_params_t )) {
switch (GetPacketType(&fParams)) {
case SLAVE_AVAILABLE:
......@@ -245,7 +244,7 @@ struct JackNetExtMaster : public JackNetMasterInterface {
}
while (fRunning);
// Set result paramaters
// Set result parameters
result->audio_input = fParams.fSendAudioChannels;
result->audio_output = fParams.fReturnAudioChannels;
result->midi_input = fParams.fSendMidiChannels;
......
......@@ -711,6 +711,7 @@ namespace Jack
session_params_t net_params;
rx_bytes = fSocket.CatchHost(&net_params, sizeof(session_params_t), 0);
SessionParamsNToH(&net_params, &host_params);
if ((rx_bytes == SOCKET_ERROR) && (fSocket.GetError() != NET_NO_DATA)) {
jack_error("Error in receive : %s", StrError(NET_ERROR_CODE));
if (++attempt == 10) {
......
......@@ -227,7 +227,7 @@ int main(int argc, char** argv)
int do_unlock = 0;
int loopback = 0;
bool show_version = false;
sigset_t signals;
jackctl_sigmask_t * sigmask;
jackctl_parameter_t* param;
union jackctl_parameter_value value;
......@@ -450,7 +450,7 @@ int main(int argc, char** argv)
}
// Setup signals
signals = jackctl_setup_signals(0);
sigmask = jackctl_setup_signals(0);
// Open server
if (! jackctl_server_open(server_ctl, master_driver_ctl)) {
......@@ -520,7 +520,7 @@ int main(int argc, char** argv)
return_value = 0;
// Waits for signal
jackctl_wait_signals(signals);
jackctl_wait_signals(sigmask);
stop_server:
if (!jackctl_server_stop(server_ctl)) {
......
......@@ -28,7 +28,7 @@
#ifndef JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED
#define JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED
#include <types.h>
#include <jack/jslist.h>
#include <jack/systemdeps.h>
......@@ -82,6 +82,12 @@ typedef struct jackctl_internal jackctl_internal_t;
/** opaque type for parameter object */
typedef struct jackctl_parameter jackctl_parameter_t;
/** opaque type for parameter object */
typedef struct jackctl_parameter jackctl_parameter_t;
/** opaque type for sigmask object */
typedef struct jackctl_sigmask jackctl_sigmask_t;
#ifdef __cplusplus
extern "C" {
#endif
......@@ -103,7 +109,7 @@ extern "C" {
*
* @return the configurated signal set.
*/
sigset_t
jackctl_sigmask_t *
jackctl_setup_signals(
unsigned int flags);
......@@ -114,7 +120,7 @@ jackctl_setup_signals(
*/
void
jackctl_wait_signals(
sigset_t signals);
jackctl_sigmask_t * signals);
/**
* Call this function to create server object.
......
......@@ -76,6 +76,11 @@ jack_get_version(
const char *
jack_get_version_string() JACK_OPTIONAL_WEAK_EXPORT;
/**
* @defgroup ClientFunctions Creating & manipulating clients
* @{
*/
/**
* Open an external client session with a JACK server. This interface
* is more complex but more powerful than jack_client_new(). With it,
......@@ -170,7 +175,7 @@ int jack_internal_client_new (const char *client_name,
/**
* Remove an internal client from a JACK server.
*
* @deprecated Please use jack_internal_client_load().
* @deprecated Please use jack_internal_client_unload().
*/
void jack_internal_client_close (const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
......@@ -198,9 +203,9 @@ int jack_get_client_pid (const char *name) JACK_OPTIONAL_WEAK_EXPORT;
/**
* @return the pthread ID of the thread running the JACK client side
* code.
* real-time code.
*/
jack_native_thread_t jack_client_thread_id (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT;
jack_native_thread_t jack_client_thread_id (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
/*@}*/
......@@ -224,7 +229,7 @@ int jack_is_realtime (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
*
* @deprecated Please use jack_cycle_wait() and jack_cycle_signal() functions.
*/
jack_nframes_t jack_thread_wait (jack_client_t*, int status) JACK_OPTIONAL_WEAK_EXPORT;
jack_nframes_t jack_thread_wait (jack_client_t *client, int status) JACK_OPTIONAL_WEAK_EXPORT;
/**
* Wait until this JACK client should process data.
......@@ -432,9 +437,9 @@ int jack_set_sample_rate_callback (jack_client_t *client,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_client_registration_callback (jack_client_t *,
JackClientRegistrationCallback
registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
int jack_set_client_registration_callback (jack_client_t *client,
JackClientRegistrationCallback
registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
/**
* Tell the JACK server to call @a registration_callback whenever a
......@@ -449,7 +454,7 @@ int jack_set_client_registration_callback (jack_client_t *,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_port_registration_callback (jack_client_t *,
int jack_set_port_registration_callback (jack_client_t *client,
JackPortRegistrationCallback
registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
......@@ -466,7 +471,7 @@ int jack_set_client_registration_callback (jack_client_t *,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_port_connect_callback (jack_client_t *,
int jack_set_port_connect_callback (jack_client_t *client,
JackPortConnectCallback
connect_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
......@@ -483,7 +488,7 @@ int jack_set_port_connect_callback (jack_client_t *,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_port_rename_callback (jack_client_t *,
int jack_set_port_rename_callback (jack_client_t *client,
JackPortRenameCallback
rename_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
......@@ -500,7 +505,7 @@ int jack_set_port_rename_callback (jack_client_t *,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_graph_order_callback (jack_client_t *,
int jack_set_graph_order_callback (jack_client_t *client,
JackGraphOrderCallback graph_callback,
void *) JACK_OPTIONAL_WEAK_EXPORT;
......@@ -517,7 +522,7 @@ int jack_set_graph_order_callback (jack_client_t *,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_xrun_callback (jack_client_t *,
int jack_set_xrun_callback (jack_client_t *client,
JackXRunCallback xrun_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
/*@}*/
......@@ -575,7 +580,7 @@ int jack_set_xrun_callback (jack_client_t *,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_latency_callback (jack_client_t *,
int jack_set_latency_callback (jack_client_t *client,
JackLatencyCallback latency_callback,
void *) JACK_WEAK_EXPORT;
/*@}*/
......@@ -713,7 +718,7 @@ jack_port_t * jack_port_register (jack_client_t *client,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_port_unregister (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXPORT;
int jack_port_unregister (jack_client_t *client, jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
/**
* This returns a pointer to the memory area associated with the
......@@ -734,7 +739,7 @@ int jack_port_unregister (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXP
* Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining").
* Port buffers have to be retrieved in each callback for proper functionning.
*/
void * jack_port_get_buffer (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
void * jack_port_get_buffer (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
/**
* @return the full name of the jack_port_t (including the @a
......@@ -771,7 +776,7 @@ jack_port_type_id_t jack_port_type_id (const jack_port_t *port) JACK_OPTIONAL_WE
/**
* @return TRUE if the jack_port_t belongs to the jack_client_t.
*/
int jack_port_is_mine (const jack_client_t *, const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
int jack_port_is_mine (const jack_client_t *client, const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
/**
* @return number of connections to or from @a port.
......@@ -931,7 +936,7 @@ int jack_port_monitoring_input (jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
* @return 0 on success, EEXIST if the connection is already made,
* otherwise a non-zero error code
*/
int jack_connect (jack_client_t *,
int jack_connect (jack_client_t *client,
const char *source_port,
const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
......@@ -948,7 +953,7 @@ int jack_connect (jack_client_t *,
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_disconnect (jack_client_t *,
int jack_disconnect (jack_client_t *client,
const char *source_port,
const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT;
......@@ -961,7 +966,7 @@ int jack_disconnect (jack_client_t *,
* while generic connection clients (e.g. patchbays) would use
* jack_disconnect().
*/
int jack_port_disconnect (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXPORT;
int jack_port_disconnect (jack_client_t *client, jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT;
/**
* @return the maximum number of characters in a full JACK port name
......@@ -1052,7 +1057,7 @@ size_t jack_port_type_get_buffer_size (jack_client_t *client, const char *port_t
* be replaced by a latency callback that calls @ref
* jack_port_set_latency_range().
*/
void jack_port_set_latency (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
void jack_port_set_latency (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
/**
* return the latency range defined by @a mode for
......@@ -1147,7 +1152,7 @@ void jack_port_set_latency_range (jack_port_t *port, jack_latency_callback_mode_
* @return zero for successful execution of the request. non-zero
* otherwise.
*/
int jack_recompute_total_latencies (jack_client_t*) JACK_OPTIONAL_WEAK_EXPORT;
int jack_recompute_total_latencies (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
/**
* @return the time (in frames) between data being available or
......@@ -1176,7 +1181,7 @@ jack_nframes_t jack_port_get_latency (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPR
* be replaced by jack_port_get_latency_range() in any existing
* use cases.
*/
jack_nframes_t jack_port_get_total_latency (jack_client_t *,
jack_nframes_t jack_port_get_total_latency (jack_client_t *client,
jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
/**
......@@ -1220,7 +1225,7 @@ int jack_recompute_total_latency (jack_client_t*, jack_port_t* port) JACK_OPTION
*
* @see jack_port_name_size(), jack_port_type_size()
*/
const char ** jack_get_ports (jack_client_t *,
const char ** jack_get_ports (jack_client_t *client,
const char *port_name_pattern,
const char *type_name_pattern,
unsigned long flags) JACK_OPTIONAL_WEAK_EXPORT;
......@@ -1230,7 +1235,7 @@ const char ** jack_get_ports (jack_client_t *,
*
* @see jack_port_name_size()
*/
jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
jack_port_t * jack_port_by_name (jack_client_t *client, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT;
/**
* @return address of the jack_port_t of a @a port_id.
......
......@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
const JSList * drivers;
const JSList * internals;
const JSList * node_ptr;
sigset_t signals;
jackctl_sigmask_t * sigmask;
int opt, option_index;
const char* driver_name = "dummy";
const char* client_name = "audioadapter";
......@@ -234,8 +234,8 @@ int main(int argc, char *argv[])
*/
signals = jackctl_setup_signals(0);
jackctl_wait_signals(signals);
sigmask = jackctl_setup_signals(0);
jackctl_wait_signals(sigmask);
jackctl_server_stop(server);
jackctl_server_close(server);
jackctl_server_destroy(server);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment