2
Copyright (C) 2001 Paul Davis
3
Copyright (C) 2004 Jack O'Quin
4
Copyright (C) 2010 Torben Hohn
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU Lesser General Public License as published by
8
the Free Software Foundation; either version 2.1 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#ifndef __jack_session_h__
22
#define __jack_session_h__
28
#include <jack/types.h>
29
#include <jack/weakmacros.h>
32
* @defgroup SessionClientFunctions Session API for clients.
40
* If a client cant save templates, i might just do a normal save.
42
* There is no "quit without saving" event because a client might refuse to
43
* quit when it has unsaved data, but other clients may have already quit.
44
* This results in too much confusion, so it is unsupported.
46
enum JackSessionEventType {
48
* Save the session completely.
50
* The client may save references to data outside the provided directory,
51
* but it must do so by creating a link inside the provided directory and
52
* referring to that in any save files. The client must not refer to data
53
* files outside the provided directory directly in save files, because
54
* this makes it impossible for the session manager to create a session
55
* archive for distribution or archival.
60
* Save the session completly, then quit.
62
* The rules for saving are exactly the same as for JackSessionSave.
64
JackSessionSaveAndQuit = 2,
67
* Save a session template.
69
* A session template is a "skeleton" of the session, but without any data.
70
* Clients must save a session that, when restored, will create the same
71
* ports as a full save would have. However, the actual data contained in
72
* the session may not be saved (e.g. a DAW would create the necessary
73
* tracks, but not save the actual recorded data).
75
JackSessionSaveTemplate = 3
78
typedef enum JackSessionEventType jack_session_event_type_t;
81
* @ref jack_session_flags_t bits
83
enum JackSessionFlags {
85
* An error occured while saving.
87
JackSessionSaveError = 0x01,
90
* Client needs to be run in a terminal.
92
JackSessionNeedTerminal = 0x02
98
typedef enum JackSessionFlags jack_session_flags_t;
100
struct _jack_session_event {
102
* The type of this session event.
104
jack_session_event_type_t type;
107
* Session directory path, with trailing separator.
109
* This directory is exclusive to the client; when saving the client may
110
* create any files it likes in this directory.
112
const char *session_dir;
115
* Client UUID which must be passed to jack_client_open on session load.
117
* The client can specify this in the returned command line, or save it
118
* in a state file within the session directory.
120
const char *client_uuid;
123
* Reply (set by client): the command line needed to restore the client.
125
* This is a platform dependent command line. It must contain
126
* ${SESSION_DIR} instead of the actual session directory path. More
127
* generally, just as in session files, clients should not include any
128
* paths outside the session directory here as this makes
129
* archival/distribution impossible.
131
* This field is set to NULL by Jack when the event is delivered to the
132
* client. The client must set to allocated memory that is safe to
133
* free(). This memory will be freed by jack_session_event_free.
138
* Reply (set by client): Session flags.
140
jack_session_flags_t flags;
143
* Future flags. Set to zero for now.
148
typedef struct _jack_session_event jack_session_event_t;
151
* Prototype for the client supplied function that is called
152
* whenever a session notification is sent via jack_session_notify().
154
* Ownership of the memory of @a event is passed to the application.
155
* It must be freed using jack_session_event_free when its not used anymore.
157
* The client must promptly call jack_session_reply for this event.
159
* @param event The event structure.
160
* @param arg Pointer to a client supplied structure.
162
typedef void (*JackSessionCallback)(jack_session_event_t *event,
166
* Tell the JACK server to call @a session_callback when a session event
167
* is to be delivered.
169
* setting more than one session_callback per process is probably a design
170
* error. if you have a multiclient application its more sensible to create
171
* a jack_client with only a session callback set.
173
* @return 0 on success, otherwise a non-zero error code
175
int jack_set_session_callback (jack_client_t *client,
176
JackSessionCallback session_callback,
177
void *arg) JACK_WEAK_EXPORT;
180
* Reply to a session event.
182
* This can either be called directly from the callback, or later from a
183
* different thread. For example, it is possible to push the event through a
184
* queue and execute the save code from the GUI thread.
186
* @return 0 on success, otherwise a non-zero error code
188
int jack_session_reply (jack_client_t *client,
189
jack_session_event_t *event) JACK_WEAK_EXPORT;
193
* Free memory used by a jack_session_event_t.
195
* This also frees the memory used by the command_line pointer, if its non NULL.
197
void jack_session_event_free (jack_session_event_t *event) JACK_WEAK_EXPORT;
201
* Get the assigned uuid for client.
202
* Safe to call from callback and all other threads.
204
* The caller is responsible for calling jack_free(3) on any non-NULL
207
char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;
214
* @defgroup JackSessionManagerAPI API for a session manager.
221
const char *client_name;
223
jack_session_flags_t flags;
224
} jack_session_command_t;
227
* Send an event to all clients listening for session callbacks.
229
* The returned strings of the clients are accumulated and returned as an array
230
* of jack_session_command_t. its terminated by ret[i].uuid == NULL target ==
231
* NULL means send to all interested clients. otherwise a clientname
233
jack_session_command_t *jack_session_notify (
234
jack_client_t* client,
236
jack_session_event_type_t type,
237
const char *path) JACK_WEAK_EXPORT;
240
* Free the memory allocated by a session command.
242
void jack_session_commands_free (jack_session_command_t *cmds) JACK_WEAK_EXPORT;
245
* Get the session ID for a client name.
247
* The session manager needs this to reassociate a client name to the session_id.
249
* The caller is responsible for calling jack_free(3) on any non-NULL
252
char *jack_get_uuid_for_client_name (jack_client_t *client,
253
const char *client_name) JACK_WEAK_EXPORT;
256
* Get the client name for a session_id.
258
* In order to snapshot the graph connections, the session manager needs to map
259
* session_ids to client names.
261
* The caller is responsible for calling jack_free(3) on any non-NULL
264
char *jack_get_client_name_by_uuid (jack_client_t *client,
265
const char *client_uuid ) JACK_WEAK_EXPORT;
268
* Reserve a client name and associate it with a UUID.
270
* When a client later calls jack_client_open() and specifies the UUID, jackd
271
* will assign the reserved name. This allows a session manager to know in
272
* advance under which client name its managed clients will appear.
274
* @return 0 on success, otherwise a non-zero error code
277
jack_reserve_client_name (jack_client_t *client,
279
const char *uuid) JACK_WEAK_EXPORT;
282
* Find out whether a client has set up a session callback.
284
* @return 0 when the client has no session callback, 1 when it has one.
288
jack_client_has_session_callback (jack_client_t *client, const char *client_name) JACK_WEAK_EXPORT;