jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
5.4KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004 Jack O'Quin
  4. Copyright (C) 2010 Torben Hohn
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. */
  17. #ifndef __jack_session_h__
  18. #define __jack_session_h__
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #include <jack/weakmacros.h>
  23. /**
  24. * @defgroup SessionClientFunctions Session API for clients.
  25. * @{
  26. */
  27. /**
  28. * session event types.
  29. *
  30. * if a client cant save templates, i might just do a normal save.
  31. *
  32. * the rationale, why there is no quit without save, is that a client
  33. * might refuse to quit when it has unsaved data.
  34. * however some other clients might have already quit.
  35. * this results in too much confusion, so we just dont support that.
  36. * the session manager can check, if the saved state is different from a previous
  37. * save, and just remove the saved stuff.
  38. *
  39. * (an inquiry function, whether a quit is ok, followed by a quit event
  40. * would have a race)
  41. */
  42. enum JackSessionEventType {
  43. JackSessionSave = 1,
  44. JackSessionSaveAndQuit = 2,
  45. JackSessionSaveTemplate = 3
  46. };
  47. typedef enum JackSessionEventType jack_session_event_type_t;
  48. struct _jack_session_event {
  49. /**
  50. * the actual type of this session event.
  51. */
  52. jack_session_event_type_t type;
  53. /**
  54. * session_directory with trailing separator
  55. * this is per client. so the client can do whatever it likes in here.
  56. */
  57. const char *session_dir;
  58. /**
  59. * client_uuid which must be specified to jack_client_open on session reload.
  60. * client can specify it in the returned commandline as an option, or just save it
  61. * with the state file.
  62. */
  63. const char *client_uuid;
  64. /**
  65. * the command_line is the reply of the client.
  66. * it specifies in a platform dependent way, how the client must be restarted upon session reload.
  67. *
  68. * probably it should contain ${SESSION_DIR} instead of the actual session dir.
  69. * this would basically make the session dir moveable.
  70. *
  71. * ownership of the memory is handed to jack.
  72. * initially set to NULL by jack;
  73. */
  74. char *command_line;
  75. };
  76. typedef struct _jack_session_event jack_session_event_t;
  77. /**
  78. * Prototype for the client supplied function that is called
  79. * whenever a session notification is sent via jack_session_notify().
  80. *
  81. * The session_id must be passed to jack_client_open on session reload (this can be
  82. * done by specifying it somehow on the returned command line).
  83. *
  84. * @param event the event_structure.
  85. * @param arg pointer to a client supplied structure
  86. */
  87. typedef void (*JackSessionCallback)(jack_session_event_t *event, void *arg);
  88. /**
  89. * Tell the JACK server to call @a save_callback the session handler wants
  90. * to save.
  91. *
  92. * @return 0 on success, otherwise a non-zero error code
  93. */
  94. int jack_set_session_callback(jack_client_t *client,
  95. JackSessionCallback session_callback,
  96. void *arg) JACK_WEAK_EXPORT;
  97. /**
  98. * reply to a session_event
  99. *
  100. * this can either be called directly from the callback, or later from a different thread.
  101. * so its possible to just stick the event pointer into a pipe and execute the save code
  102. * from the gui thread.
  103. *
  104. * @return 0 on success, otherwise a non-zero error code
  105. */
  106. int jack_session_reply( jack_client_t *client, jack_session_event_t *event ) JACK_WEAK_EXPORT;
  107. /*@}*/
  108. /**
  109. * @defgroup JackSessionManagerAPI this API is intended for a sessionmanager.
  110. * this API could be server specific. if we dont reach consensus here,
  111. * we can just drop it.
  112. * i know its a bit clumsy.
  113. * but this api isnt required to be as stable as the client api.
  114. * @{
  115. */
  116. typedef struct {
  117. char uuid[16];
  118. char client_name[33];
  119. char command[256];
  120. } jack_session_command_t;
  121. /**
  122. * send a save or quit event, to all clients listening for session
  123. * callbacks. the returned strings of the clients are accumulated and
  124. * returned as an array of jack_session_command_t.
  125. * its terminated by ret[i].uuid[0]='\0'
  126. * target == NULL means send to all interested clients. otherwise a clientname
  127. */
  128. jack_session_command_t *jack_session_notify (jack_client_t* client,
  129. const char *target,
  130. jack_session_event_type_t type,
  131. const char *path ) JACK_WEAK_EXPORT;
  132. /**
  133. * get the sessionid for a client name.
  134. * the sessionmanager needs this to reassociate a client_name to the session_id.
  135. */
  136. char *jack_get_uuid_for_client_name( jack_client_t *client, const char *client_name ) JACK_WEAK_EXPORT;
  137. /**
  138. * get the client name for a session_id.
  139. * in order to snapshot the graph connections, the sessionmanager needs to map
  140. * session_ids to client names.
  141. */
  142. char *jack_get_client_name_for_uuid( jack_client_t *client, const char *client_uuid ) JACK_WEAK_EXPORT;
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif