~hitmuri/vjpirate/trunk

« back to all changes in this revision

Viewing changes to os/win/include/jack/session.h

  • Committer: Florent Berthaut
  • Date: 2014-07-26 18:53:16 UTC
  • mfrom: (5.1.12 mac)
  • Revision ID: flo@localhost.localdomain-20140726185316-c2ucnwmgm5kij4e2
Merged mac branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2001 Paul Davis
 
3
    Copyright (C) 2004 Jack O'Quin
 
4
    Copyright (C) 2010 Torben Hohn
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
19
*/
 
20
 
 
21
#ifndef __jack_session_h__
 
22
#define __jack_session_h__
 
23
 
 
24
#ifdef __cplusplus
 
25
extern "C" {
 
26
#endif
 
27
 
 
28
#include <jack/types.h>
 
29
#include <jack/weakmacros.h>
 
30
 
 
31
/**
 
32
 * @defgroup SessionClientFunctions Session API for clients.
 
33
 * @{
 
34
 */
 
35
 
 
36
 
 
37
/**
 
38
 * Session event type.
 
39
 *
 
40
 * If a client cant save templates, i might just do a normal save.
 
41
 *
 
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.
 
45
 */
 
46
enum JackSessionEventType {
 
47
        /**
 
48
         * Save the session completely.
 
49
         *
 
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.
 
56
         */
 
57
    JackSessionSave = 1,
 
58
 
 
59
    /**
 
60
     * Save the session completly, then quit.
 
61
     *
 
62
     * The rules for saving are exactly the same as for JackSessionSave.
 
63
     */
 
64
    JackSessionSaveAndQuit = 2,
 
65
 
 
66
    /**
 
67
     * Save a session template.
 
68
     *
 
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).
 
74
     */
 
75
    JackSessionSaveTemplate = 3
 
76
};
 
77
 
 
78
typedef enum JackSessionEventType jack_session_event_type_t;
 
79
 
 
80
/**
 
81
 * @ref jack_session_flags_t bits
 
82
 */
 
83
enum JackSessionFlags {
 
84
    /**
 
85
     * An error occured while saving.
 
86
     */
 
87
    JackSessionSaveError = 0x01,
 
88
 
 
89
    /**
 
90
     * Client needs to be run in a terminal.
 
91
     */
 
92
    JackSessionNeedTerminal = 0x02
 
93
};
 
94
 
 
95
/**
 
96
 * Session flags.
 
97
 */
 
98
typedef enum JackSessionFlags jack_session_flags_t;
 
99
 
 
100
struct _jack_session_event {
 
101
    /**
 
102
     * The type of this session event.
 
103
     */
 
104
    jack_session_event_type_t type;
 
105
 
 
106
    /**
 
107
     * Session directory path, with trailing separator.
 
108
     *
 
109
     * This directory is exclusive to the client; when saving the client may
 
110
     * create any files it likes in this directory.
 
111
     */
 
112
    const char *session_dir;
 
113
 
 
114
    /**
 
115
     * Client UUID which must be passed to jack_client_open on session load.
 
116
     *
 
117
     * The client can specify this in the returned command line, or save it
 
118
     * in a state file within the session directory.
 
119
     */
 
120
    const char *client_uuid;
 
121
 
 
122
    /**
 
123
     * Reply (set by client): the command line needed to restore the client.
 
124
     *
 
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.
 
130
     *
 
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.
 
134
     */
 
135
    char *command_line;
 
136
 
 
137
    /**
 
138
     * Reply (set by client): Session flags.
 
139
     */
 
140
    jack_session_flags_t flags;
 
141
 
 
142
    /**
 
143
     * Future flags. Set to zero for now.
 
144
     */
 
145
    uint32_t future;
 
146
};
 
147
 
 
148
typedef struct _jack_session_event jack_session_event_t;
 
149
 
 
150
/**
 
151
 * Prototype for the client supplied function that is called
 
152
 * whenever a session notification is sent via jack_session_notify().
 
153
 *
 
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.
 
156
 *
 
157
 * The client must promptly call jack_session_reply for this event.
 
158
 *
 
159
 * @param event The event structure.
 
160
 * @param arg Pointer to a client supplied structure.
 
161
 */
 
162
typedef void (*JackSessionCallback)(jack_session_event_t *event,
 
163
                                    void                 *arg);
 
164
 
 
165
/**
 
166
 * Tell the JACK server to call @a session_callback when a session event
 
167
 * is to be delivered.
 
168
 *
 
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.
 
172
 *
 
173
 * @return 0 on success, otherwise a non-zero error code
 
174
 */
 
175
int jack_set_session_callback (jack_client_t       *client,
 
176
                               JackSessionCallback  session_callback,
 
177
                               void                *arg) JACK_WEAK_EXPORT;
 
178
 
 
179
/**
 
180
 * Reply to a session event.
 
181
 *
 
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.
 
185
 *
 
186
 * @return 0 on success, otherwise a non-zero error code
 
187
 */
 
188
int jack_session_reply (jack_client_t        *client,
 
189
                        jack_session_event_t *event) JACK_WEAK_EXPORT;
 
190
 
 
191
 
 
192
/**
 
193
 * Free memory used by a jack_session_event_t.
 
194
 *
 
195
 * This also frees the memory used by the command_line pointer, if its non NULL.
 
196
 */
 
197
void jack_session_event_free (jack_session_event_t *event) JACK_WEAK_EXPORT;
 
198
 
 
199
 
 
200
/**
 
201
 * Get the assigned uuid for client.
 
202
 * Safe to call from callback and all other threads.
 
203
 *
 
204
 * The caller is responsible for calling jack_free(3) on any non-NULL
 
205
 * returned value.
 
206
 */
 
207
char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;
 
208
 
 
209
/**
 
210
 * @}
 
211
 */
 
212
 
 
213
/**
 
214
 * @defgroup JackSessionManagerAPI API for a session manager.
 
215
 *
 
216
 * @{
 
217
 */
 
218
 
 
219
typedef struct  {
 
220
        const char           *uuid;
 
221
        const char           *client_name;
 
222
        const char           *command;
 
223
        jack_session_flags_t  flags;
 
224
} jack_session_command_t;
 
225
 
 
226
/**
 
227
 * Send an event to all clients listening for session callbacks.
 
228
 *
 
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
 
232
 */
 
233
jack_session_command_t *jack_session_notify (
 
234
        jack_client_t*             client,
 
235
        const char                *target,
 
236
        jack_session_event_type_t  type,
 
237
        const char                *path) JACK_WEAK_EXPORT;
 
238
 
 
239
/**
 
240
 * Free the memory allocated by a session command.
 
241
 */
 
242
void jack_session_commands_free (jack_session_command_t *cmds) JACK_WEAK_EXPORT;
 
243
 
 
244
/**
 
245
 * Get the session ID for a client name.
 
246
 *
 
247
 * The session manager needs this to reassociate a client name to the session_id.
 
248
 *
 
249
 * The caller is responsible for calling jack_free(3) on any non-NULL
 
250
 * returned value.
 
251
 */
 
252
char *jack_get_uuid_for_client_name (jack_client_t *client,
 
253
                                     const char    *client_name) JACK_WEAK_EXPORT;
 
254
 
 
255
/**
 
256
 * Get the client name for a session_id.
 
257
 *
 
258
 * In order to snapshot the graph connections, the session manager needs to map
 
259
 * session_ids to client names.
 
260
 *
 
261
 * The caller is responsible for calling jack_free(3) on any non-NULL
 
262
 * returned value.
 
263
 */
 
264
char *jack_get_client_name_by_uuid (jack_client_t *client,
 
265
                                    const char    *client_uuid ) JACK_WEAK_EXPORT;
 
266
 
 
267
/**
 
268
 * Reserve a client name and associate it with a UUID.
 
269
 *
 
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.
 
273
 *
 
274
 * @return 0 on success, otherwise a non-zero error code
 
275
 */
 
276
int
 
277
jack_reserve_client_name (jack_client_t *client,
 
278
                          const char    *name,
 
279
                          const char    *uuid) JACK_WEAK_EXPORT;
 
280
 
 
281
/**
 
282
 * Find out whether a client has set up a session callback.
 
283
 *
 
284
 * @return 0 when the client has no session callback, 1 when it has one.
 
285
 *        -1 on error.
 
286
 */
 
287
int
 
288
jack_client_has_session_callback (jack_client_t *client, const char *client_name) JACK_WEAK_EXPORT;
 
289
 
 
290
#ifdef __cplusplus
 
291
}
 
292
#endif
 
293
#endif