From 433e55a10b95cbb649b0c5edbe6feeb2eaf39440 Mon Sep 17 00:00:00 2001 From: Torben Hohn Date: Fri, 27 Nov 2009 20:57:42 +0100 Subject: [PATCH 1/2] Tidy-up-session-stuff-nitpicks-for-upstream by drobilla --- example-clients/simple_client.c | 38 +++++++++++++++++++-------------- jack/types.h | 10 ++++----- libjack/client.c | 1 + 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/example-clients/simple_client.c b/example-clients/simple_client.c index 2ab8328..3190285 100644 --- a/example-clients/simple_client.c +++ b/example-clients/simple_client.c @@ -21,33 +21,34 @@ jack_client_t *client; * special realtime thread once for each audio cycle. * * This client does nothing more than copy data from its input - * port to its output port. It will exit when stopped by + * port to its output port. It will exit when stopped by * the user (e.g. using Ctrl-C on a unix-ish operating system) */ int process (jack_nframes_t nframes, void *arg) { jack_default_audio_sample_t *in, *out; - + in = jack_port_get_buffer (input_port, nframes); out = jack_port_get_buffer (output_port, nframes); memcpy (out, in, sizeof (jack_default_audio_sample_t) * nframes); - return 0; + return 0; } -char *session_callback( jack_session_event_t code, const char *path, const char *prefix, void *arg ) +char * +session_callback (jack_session_event_t code, const char *path, const char *uuid, void *arg) { char retval[100]; - printf( "session notification\n" ); - printf( "path %s, prefix %s, type: %s\n", path, prefix, code == JackSessionSave ? "save" : "quit" ); + printf ("session notification\n"); + printf ("path %s, uuid %s, type: %s\n", path, uuid, code == JackSessionSave ? "save" : "quit"); - if( code == JackSessionQuit ) - exit(1); + if (code == JackSessionQuit) + exit (1); - snprintf( retval, 100, "jack_simple_client %s", prefix ); - return strdup( retval ); + snprintf (retval, 100, "jack_simple_client %s", uuid); + return strdup (retval); } /** @@ -68,7 +69,7 @@ main (int argc, char *argv[]) const char *server_name = NULL; jack_options_t options = JackNullOption; jack_status_t status; - + /* open a client connection to the JACK server */ if( argc == 1 ) @@ -96,8 +97,8 @@ main (int argc, char *argv[]) there is work to be done. */ - jack_client_set_cookie( client, "info", "simple" ); - jack_client_set_cookie( client, "info2", "no" ); + jack_client_set_cookie (client, "info", "simple"); + jack_client_set_cookie (client, "info2", "no"); jack_set_process_callback (client, process, 0); /* tell the JACK server to call `jack_shutdown()' if @@ -107,8 +108,13 @@ main (int argc, char *argv[]) jack_on_shutdown (client, jack_shutdown, 0); - jack_set_session_callback( client, session_callback, NULL ); - /* display the current sample rate. + /* tell the JACK server to call `session_callback()' if + the session is saved. + */ + + jack_set_session_callback (client, session_callback, NULL); + + /* display the current sample rate. */ printf ("engine sample rate: %" PRIu32 "\n", @@ -156,7 +162,7 @@ main (int argc, char *argv[]) } free (ports); - + ports = jack_get_ports (client, NULL, NULL, JackPortIsPhysical|JackPortIsInput); if (ports == NULL) { diff --git a/jack/types.h b/jack/types.h index 6ef9312..078de85 100644 --- a/jack/types.h +++ b/jack/types.h @@ -365,7 +365,7 @@ typedef void (*JackShutdownCallback)(void *arg); * to release client ressources. Warning: jack_client_close() cannot be * safely used inside the shutdown callback and has to be called outside of * the callback context. - + * * @param code a shuntdown code * @param reason a string discribing the shuntdown reason (backend failure, server crash... etc...) * @param arg pointer to a client supplied structure @@ -382,16 +382,14 @@ typedef void (*JackInfoShutdownCallback)(jack_status_t code, const char* reason, * the prefix also acts as uuid, which the client needs to specify * to jack_client_open() upon session reload. * - * the return value is a commandline, which will restore the state. + * The return value is a commandline, which will restore the state. * - * @param code the type of the Event (Save or Quit) * @param session_dir with trailing separator. - * @param prefix for saved files. + * @param prefix for saved files. * @param arg pointer to a client supplied structure */ - -typedef char *(*JackSessionCallback)(jack_session_event_t code, const char* session_dir, const char* prefix, void *arg); +typedef char *(*JackSessionCallback)(jack_session_event_t code, const char* session_dir, const char* uuid, void *arg); /** * Used for the type argument of jack_port_register() for default diff --git a/libjack/client.c b/libjack/client.c index 1633ea5..49b081a 100644 --- a/libjack/client.c +++ b/libjack/client.c @@ -2531,6 +2531,7 @@ jack_set_session_callback(jack_client_t* client, JackSessionCallback callback, v client->control->session_cbset = (callback != NULL); return 0; } + int jack_get_process_done_fd (jack_client_t *client) { From c3a962fabaf3e4d02b349d394f220a7cd32a6c1e Mon Sep 17 00:00:00 2001 From: Torben Hohn Date: Fri, 27 Nov 2009 21:12:19 +0100 Subject: [PATCH 2/2] wrap and use client_open... also check client pointer for Null --- python/libjack.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/libjack.py b/python/libjack.py index 8d2493a..b03967b 100644 --- a/python/libjack.py +++ b/python/libjack.py @@ -17,6 +17,10 @@ client_new = libjack.jack_client_new client_new.argtypes = [ c_char_p ] client_new.restype = client_p +client_open = libjack.jack_client_open +client_open.argtypes = [ c_char_p, c_uint, POINTER( c_uint ) ] +client_open.restype = client_p + client_close = libjack.jack_client_close client_close.argtypes = [ client_p ] client_close.restype = None @@ -267,7 +271,9 @@ class NotifyReply(object): class JackClient(object): def __init__( self, name ): - self.client = client_new( name ) + self.client = client_open( name, 0, None ) + if not self.client: + raise Exception( "got no client name" ) self.reg_cb = PortRegistrationCallback( self.port_registration_cb ) set_port_registration_callback( self.client, self.reg_cb, None ) self.port_queue = Queue()