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.

247 lines
8.1KB

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