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.

240 lines
8.0KB

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