+ added header translation of jack/session.h to libjack

This commit is contained in:
Nikolay Nikolov 2025-01-05 18:18:38 +02:00
parent 2a017b7f2b
commit cca6fe9f98
5 changed files with 343 additions and 0 deletions

View File

@ -51,6 +51,14 @@ begin
AddUnit('jack');
end;
T:=P.Targets.AddUnit('jacksession.pp');
with T.Dependencies do
begin
AddInclude('session.inc');
AddInclude('session.inc');
AddUnit('jack');
end;
P.ExamplePath.Add('examples');
P.Targets.AddExampleProgram('simple_client.pp');
P.Targets.AddExampleProgram('latent_client.pp');

View File

@ -0,0 +1,3 @@
unit Api.Jack.Session;
{$DEFINE FPC_DOTTEDUNITS}
{$i jacksession.pp}

View File

@ -1,5 +1,6 @@
src/jack.pp=namespaced/Api.Jack.pp
src/jackringbuffer.pp=namespaced/Api.Jack.RingBuffer.pp
src/jackuuid.pp=namespaced/Api.Jack.Uuid.pp
src/jacksession.pp=namespaced/Api.Jack.Session.pp
{s*:src/}=namespaced/
{i+:src/}

View File

@ -0,0 +1,21 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit jacksession;
{$ENDIF FPC_DOTTEDUNITS}
interface
{$packrecords C}
uses
{$IFDEF FPC_DOTTEDUNITS}
System.CTypes, Api.Jack;
{$ELSE FPC_DOTTEDUNITS}
ctypes, jack;
{$ENDIF FPC_DOTTEDUNITS}
{$I session.inc}
implementation
end.

View File

@ -0,0 +1,310 @@
{
Copyright (C) 2001 Paul Davis
Copyright (C) 2004 Jack O'Quin
Copyright (C) 2010 Torben Hohn
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
{$ifndef __jack_session_h__}
{$define __jack_session_h__}
//#ifdef __cplusplus
//extern "C" {
//#endif
//#include <jack/types.h>
//#include <jack/weakmacros.h>
{$I weakmacros.inc}
(**
* @defgroup SessionClientFunctions Session API for clients.
*
* @deprecated Use of JACK-Session is currently deprecated and unsupported.
* JACK developers recommend the use of NSM instead.
* See https://new-session-manager.jackaudio.org/
* @{
*)
(**
* Session event type.
*
* If a client can't save templates, i might just do a normal save.
*
* There is no "quit without saving" event because a client might refuse to
* quit when it has unsaved data, but other clients may have already quit.
* This results in too much confusion, so it is unsupported.
*)
type
JackSessionEventType = (
(**
* Save the session completely.
*
* The client may save references to data outside the provided directory,
* but it must do so by creating a link inside the provided directory and
* referring to that in any save files. The client must not refer to data
* files outside the provided directory directly in save files, because
* this makes it impossible for the session manager to create a session
* archive for distribution or archival.
*)
JackSessionSave = 1,
(**
* Save the session completely, then quit.
*
* The rules for saving are exactly the same as for JackSessionSave.
*)
JackSessionSaveAndQuit = 2,
(**
* Save a session template.
*
* A session template is a "skeleton" of the session, but without any data.
* Clients must save a session that, when restored, will create the same
* ports as a full save would have. However, the actual data contained in
* the session may not be saved (e.g. a DAW would create the necessary
* tracks, but not save the actual recorded data).
*)
JackSessionSaveTemplate = 3
);
PPjack_session_event_type_t = ^Pjack_session_event_type_t;
Pjack_session_event_type_t = ^jack_session_event_type_t;
jack_session_event_type_t = JackSessionEventType;
(**
* @ref jack_session_flags_t bits
*)
JackSessionFlags = (
(**
* An error occurred while saving.
*)
JackSessionSaveError = $01,
(**
* Client needs to be run in a terminal.
*)
JackSessionNeedTerminal = $02
);
(**
* Session flags.
*)
PPjack_session_flags_t = ^Pjack_session_flags_t;
Pjack_session_flags_t = ^jack_session_flags_t;
jack_session_flags_t = JackSessionFlags;
PPjack_session_event_t = ^Pjack_session_event_t;
Pjack_session_event_t = ^jack_session_event_t;
jack_session_event_t = record
(**
* The type of this session event.
*)
_type: jack_session_event_type_t;
(**
* Session directory path, with trailing separator.
*
* This directory is exclusive to the client; when saving the client may
* create any files it likes in this directory.
*)
session_dir: PChar;
(**
* Client UUID which must be passed to jack_client_open on session load.
*
* The client can specify this in the returned command line, or save it
* in a state file within the session directory.
*)
client_uuid: PChar;
(**
* Reply (set by client): the command line needed to restore the client.
*
* This is a platform dependent command line. It must contain
* ${SESSION_DIR} instead of the actual session directory path. More
* generally, just as in session files, clients should not include any
* paths outside the session directory here as this makes
* archival/distribution impossible.
*
* This field is set to NULL by Jack when the event is delivered to the
* client. The client must set to allocated memory that is safe to
* free(). This memory will be freed by jack_session_event_free.
*)
command_line: PChar;
(**
* Reply (set by client): Session flags.
*)
flags: jack_session_flags_t;
(**
* Future flags. Set to zero for now.
*)
future: uint32_t;
end;
(**
* Prototype for the client supplied function that is called
* whenever a session notification is sent via jack_session_notify().
*
* Ownership of the memory of @a event is passed to the application.
* It must be freed using jack_session_event_free when its not used anymore.
*
* The client must promptly call jack_session_reply for this event.
*
* @deprecated Use of JACK-Session is currently deprecated and unsupported.
* JACK developers recommend the use of NSM instead.
* See https://github.com/linuxaudio/new-session-manager
*
* @param event The event structure.
* @param arg Pointer to a client supplied structure.
*)
TJackSessionCallback = procedure(event: Pjack_session_event_t;
arg: Pointer); cdecl;
(**
* Tell the JACK server to call @a session_callback when a session event
* is to be delivered.
*
* setting more than one session_callback per process is probably a design
* error. if you have a multiclient application its more sensible to create
* a jack_client with only a session callback set.
*
* @deprecated Use of JACK-Session is currently deprecated and unsupported.
* JACK developers recommend the use of NSM instead.
* See https://github.com/linuxaudio/new-session-manager
*
* @return 0 on success, otherwise a non-zero error code
*)
function jack_set_session_callback (client: Pjack_client_t;
session_callback: TJackSessionCallback;
arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
(**
* Reply to a session event.
*
* This can either be called directly from the callback, or later from a
* different thread. For example, it is possible to push the event through a
* queue and execute the save code from the GUI thread.
*
* @deprecated Use of JACK-Session is currently deprecated and unsupported.
* JACK developers recommend the use of NSM instead.
* See https://github.com/linuxaudio/new-session-manager
*
* @return 0 on success, otherwise a non-zero error code
*)
function jack_session_reply (client: Pjack_client_t;
event: Pjack_session_event_t): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
(**
* Free memory used by a jack_session_event_t.
*
* This also frees the memory used by the command_line pointer, if its non NULL.
*
* @deprecated Use of JACK-Session is currently deprecated and unsupported.
* JACK developers recommend the use of NSM instead.
* See https://github.com/linuxaudio/new-session-manager
*)
procedure jack_session_event_free (event: Pjack_session_event_t); cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
(**
* Get the assigned uuid for client.
* Safe to call from callback and all other threads.
*
* The caller is responsible for calling jack_free(3) on any non-NULL
* returned value.
*)
function jack_client_get_uuid (client: Pjack_client_t): PChar; cdecl; JACK_WEAK_EXPORT;
///**
// * @}
// */
(**
* @defgroup JackSessionManagerAPI API for a session manager.
*
* @{
*)
type
PPjack_session_command_t = ^Pjack_session_command_t;
Pjack_session_command_t = ^jack_session_command_t;
jack_session_command_t = record
uuid: PChar;
client_name: PChar;
command: PChar;
flags: jack_session_flags_t;
end;
(**
* Send an event to all clients listening for session callbacks.
*
* The returned strings of the clients are accumulated and returned as an array
* of jack_session_command_t. its terminated by ret[i].uuid == NULL target ==
* NULL means send to all interested clients. otherwise a clientname
*)
function jack_session_notify (
client: Pjack_client_t;
target: PChar;
_type: jack_session_event_type_t;
path: PChar): Pjack_session_command_t; cdecl; JACK_WEAK_EXPORT;
(**
* Free the memory allocated by a session command.
*
* @deprecated Use of JACK-Session is currently deprecated and unsupported.
* JACK developers recommend the use of NSM instead.
* See https://github.com/linuxaudio/new-session-manager
*)
procedure jack_session_commands_free (cmds: Pjack_session_command_t); cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
(**
* Reserve a client name and associate it with a UUID.
*
* When a client later calls jack_client_open() and specifies the UUID, jackd
* will assign the reserved name. This allows a session manager to know in
* advance under which client name its managed clients will appear.
*
* @return 0 on success, otherwise a non-zero error code
*)
function
jack_reserve_client_name (client: Pjack_client_t;
name: PChar;
uuid: PChar): cint; cdecl; JACK_WEAK_EXPORT;
(**
* Find out whether a client has set up a session callback.
*
* @deprecated Use of JACK-Session is currently deprecated and unsupported.
* JACK developers recommend the use of NSM instead.
* See https://github.com/linuxaudio/new-session-manager
*
* @return 0 when the client has no session callback, 1 when it has one.
* -1 on error.
*)
function
jack_client_has_session_callback (client: Pjack_client_t; client_name: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
///**
// * @}
// */
//#ifdef __cplusplus
//}
//#endif
{$endif}