jack2 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.

248 lines
8.4KB

  1. /*
  2. Copyright (C) 2002 Paul Davis
  3. Copyright (C) 2003 Jack O'Quin
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. #ifndef __jack_transport_h__
  17. #define __jack_transport_h__
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include <jack/types.h>
  22. #include <jack/weakmacros.h>
  23. /**
  24. * @defgroup TransportControl Transport and Timebase control
  25. * @{
  26. */
  27. /**
  28. * Called by the timebase master to release itself from that
  29. * responsibility.
  30. *
  31. * If the timebase master releases the timebase or leaves the JACK
  32. * graph for any reason, the JACK engine takes over at the start of
  33. * the next process cycle. The transport state does not change. If
  34. * rolling, it continues to play, with frame numbers as the only
  35. * available position information.
  36. *
  37. * @see jack_set_timebase_callback
  38. *
  39. * @param client the JACK client structure.
  40. *
  41. * @return 0 on success, otherwise a non-zero error code.
  42. */
  43. int jack_release_timebase (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  44. /**
  45. * Register (or unregister) as a slow-sync client, one that cannot
  46. * respond immediately to transport position changes.
  47. *
  48. * The @a sync_callback will be invoked at the first available
  49. * opportunity after its registration is complete. If the client is
  50. * currently active this will be the following process cycle,
  51. * otherwise it will be the first cycle after calling jack_activate().
  52. * After that, it runs according to the ::JackSyncCallback rules.
  53. * Clients that don't set a @a sync_callback are assumed to be ready
  54. * immediately any time the transport wants to start.
  55. *
  56. * @param client the JACK client structure.
  57. * @param sync_callback is a realtime function that returns TRUE when
  58. * the client is ready. Setting @a sync_callback to NULL declares that
  59. * this client no longer requires slow-sync processing.
  60. * @param arg an argument for the @a sync_callback function.
  61. *
  62. * @return 0 on success, otherwise a non-zero error code.
  63. */
  64. int jack_set_sync_callback (jack_client_t *client,
  65. JackSyncCallback sync_callback,
  66. void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  67. /**
  68. * Set the timeout value for slow-sync clients.
  69. *
  70. * This timeout prevents unresponsive slow-sync clients from
  71. * completely halting the transport mechanism. The default is two
  72. * seconds. When the timeout expires, the transport starts rolling,
  73. * even if some slow-sync clients are still unready. The @a
  74. * sync_callbacks of these clients continue being invoked, giving them
  75. * a chance to catch up.
  76. *
  77. * @see jack_set_sync_callback
  78. *
  79. * @param client the JACK client structure.
  80. * @param timeout is delay (in microseconds) before the timeout expires.
  81. *
  82. * @return 0 on success, otherwise a non-zero error code.
  83. */
  84. int jack_set_sync_timeout (jack_client_t *client,
  85. jack_time_t timeout) JACK_OPTIONAL_WEAK_EXPORT;
  86. /**
  87. * Register as timebase master for the JACK subsystem.
  88. *
  89. * The timebase master registers a callback that updates extended
  90. * position information such as beats or timecode whenever necessary.
  91. * Without this extended information, there is no need for this
  92. * function.
  93. *
  94. * There is never more than one master at a time. When a new client
  95. * takes over, the former @a timebase_callback is no longer called.
  96. * Taking over the timebase may be done conditionally, so it fails if
  97. * there was a master already.
  98. *
  99. * @param client the JACK client structure.
  100. * @param conditional non-zero for a conditional request.
  101. * @param timebase_callback is a realtime function that returns
  102. * position information.
  103. * @param arg an argument for the @a timebase_callback function.
  104. *
  105. * @return
  106. * - 0 on success;
  107. * - EBUSY if a conditional request fails because there was already a
  108. * timebase master;
  109. * - other non-zero error code.
  110. */
  111. int jack_set_timebase_callback (jack_client_t *client,
  112. int conditional,
  113. JackTimebaseCallback timebase_callback,
  114. void *arg) JACK_OPTIONAL_WEAK_EXPORT;
  115. /**
  116. * Reposition the transport to a new frame number.
  117. *
  118. * May be called at any time by any client. The new position takes
  119. * effect in two process cycles. If there are slow-sync clients and
  120. * the transport is already rolling, it will enter the
  121. * ::JackTransportStarting state and begin invoking their @a
  122. * sync_callbacks until ready. This function is realtime-safe.
  123. *
  124. * @see jack_transport_reposition, jack_set_sync_callback
  125. *
  126. * @param client the JACK client structure.
  127. * @param frame frame number of new transport position.
  128. *
  129. * @return 0 if valid request, non-zero otherwise.
  130. */
  131. int jack_transport_locate (jack_client_t *client,
  132. jack_nframes_t frame) JACK_OPTIONAL_WEAK_EXPORT;
  133. /**
  134. * Query the current transport state and position.
  135. *
  136. * This function is realtime-safe, and can be called from any thread.
  137. * If called from the process thread, @a pos corresponds to the first
  138. * frame of the current cycle and the state returned is valid for the
  139. * entire cycle.
  140. *
  141. * @param client the JACK client structure.
  142. * @param pos pointer to structure for returning current transport
  143. * position; @a pos->valid will show which fields contain valid data.
  144. * If @a pos is NULL, do not return position information.
  145. *
  146. * @return Current transport state.
  147. */
  148. jack_transport_state_t jack_transport_query (const jack_client_t *client,
  149. jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT;
  150. /**
  151. * Return an estimate of the current transport frame,
  152. * including any time elapsed since the last transport
  153. * positional update.
  154. *
  155. * @param client the JACK client structure
  156. */
  157. jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  158. /**
  159. * Request a new transport position.
  160. *
  161. * May be called at any time by any client. The new position takes
  162. * effect in two process cycles. If there are slow-sync clients and
  163. * the transport is already rolling, it will enter the
  164. * ::JackTransportStarting state and begin invoking their @a
  165. * sync_callbacks until ready. This function is realtime-safe.
  166. *
  167. * @see jack_transport_locate, jack_set_sync_callback
  168. *
  169. * @param client the JACK client structure.
  170. * @param pos requested new transport position.
  171. *
  172. * @return 0 if valid request, EINVAL if position structure rejected.
  173. */
  174. int jack_transport_reposition (jack_client_t *client,
  175. const jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT;
  176. /**
  177. * Start the JACK transport rolling.
  178. *
  179. * Any client can make this request at any time. It takes effect no
  180. * sooner than the next process cycle, perhaps later if there are
  181. * slow-sync clients. This function is realtime-safe.
  182. *
  183. * @see jack_set_sync_callback
  184. *
  185. * @param client the JACK client structure.
  186. */
  187. void jack_transport_start (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  188. /**
  189. * Stop the JACK transport.
  190. *
  191. * Any client can make this request at any time. It takes effect on
  192. * the next process cycle. This function is realtime-safe.
  193. *
  194. * @param client the JACK client structure.
  195. */
  196. void jack_transport_stop (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;
  197. /**
  198. * Gets the current transport info structure (deprecated).
  199. *
  200. * @param client the JACK client structure.
  201. * @param tinfo current transport info structure. The "valid" field
  202. * describes which fields contain valid data.
  203. *
  204. * @deprecated This is for compatibility with the earlier transport
  205. * interface. Use jack_transport_query(), instead.
  206. *
  207. * @pre Must be called from the process thread.
  208. */
  209. void jack_get_transport_info (jack_client_t *client,
  210. jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_EXPORT;
  211. /**
  212. * Set the transport info structure (deprecated).
  213. *
  214. * @deprecated This function still exists for compatibility with the
  215. * earlier transport interface, but it does nothing. Instead, define
  216. * a ::JackTimebaseCallback.
  217. */
  218. void jack_set_transport_info (jack_client_t *client,
  219. jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_EXPORT;
  220. /*@}*/
  221. #ifdef __cplusplus
  222. }
  223. #endif
  224. #endif /* __jack_transport_h__ */