Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
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.

146 lines
3.6KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "Engine.H"
  19. #include "../Mixer.H" // for process()
  20. /* This is the home of the JACK process callback */
  21. // #include "const.h"
  22. #include "util/debug.h"
  23. #include "util/Thread.H"
  24. Engine::Engine ( void (*process_callback)(nframes_t nframes, void *), void *user_data ) : _thread( "RT" )
  25. {
  26. _process_callback = process_callback;
  27. _user_data = user_data;
  28. _buffers_dropped = 0;
  29. }
  30. Engine::~Engine ( )
  31. {
  32. }
  33. /*************/
  34. /* Callbacks */
  35. /*************/
  36. /* THREAD: RT */
  37. /** This is the jack xrun callback */
  38. int
  39. Engine::xrun ( void )
  40. {
  41. return 0;
  42. }
  43. /* THREAD: RT */
  44. void
  45. Engine::freewheel ( bool starting )
  46. {
  47. if ( starting )
  48. DMESSAGE( "entering freewheeling mode" );
  49. else
  50. DMESSAGE( "leaving freewheeling mode" );
  51. }
  52. /* THREAD: RT (non-RT) */
  53. int
  54. Engine::buffer_size ( nframes_t )
  55. {
  56. // timeline->resize_buffers( nframes );
  57. return 0;
  58. }
  59. int Engine::sync ( jack_transport_state_t, jack_position_t * )
  60. {
  61. return 0;
  62. }
  63. void
  64. Engine::timebase ( jack_transport_state_t, jack_nframes_t, jack_position_t *, int )
  65. {
  66. }
  67. void
  68. Engine::timebase ( jack_transport_state_t, jack_nframes_t, jack_position_t * )
  69. {
  70. }
  71. /* THREAD: RT */
  72. int
  73. Engine::process ( nframes_t nframes )
  74. {
  75. /* FIXME: wrong place for this */
  76. _thread.set( "RT" );
  77. if ( freewheeling() )
  78. {
  79. /* /\* freewheeling mode/export. We're actually running */
  80. /* non-RT. Assume that everything is quiescent, locking is */
  81. /* unecessary and do I/O synchronously *\/ */
  82. /* if ( timeline ) */
  83. /* timeline->process( nframes ); */
  84. /* /\* because we're going faster than realtime. *\/ */
  85. /* timeline->wait_for_buffers(); */
  86. }
  87. else
  88. {
  89. if ( ! trylock() )
  90. {
  91. /* the data structures we need to access here (tracks and
  92. * their ports, but not track contents) may be in an
  93. * inconsistent state at the moment. Just punt and drop this
  94. * buffer. */
  95. ++_buffers_dropped;
  96. return 0;
  97. }
  98. _process_callback(nframes, _user_data);
  99. unlock();
  100. }
  101. return 0;
  102. }
  103. /* TRHEAD: RT */
  104. void
  105. Engine::thread_init ( void )
  106. {
  107. _thread.set( "RT" );
  108. }
  109. /* THREAD: RT */
  110. void
  111. Engine::shutdown ( void )
  112. {
  113. }