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.

149 lines
3.7KB

  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 ( ) : _thread( "RT" )
  25. {
  26. _buffers_dropped = 0;
  27. }
  28. Engine::~Engine ( )
  29. {
  30. }
  31. /*************/
  32. /* Callbacks */
  33. /*************/
  34. /* THREAD: RT */
  35. /** This is the jack xrun callback */
  36. int
  37. Engine::xrun ( void )
  38. {
  39. return 0;
  40. }
  41. /* THREAD: RT */
  42. void
  43. Engine::freewheel ( bool starting )
  44. {
  45. if ( starting )
  46. DMESSAGE( "entering freewheeling mode" );
  47. else
  48. DMESSAGE( "leaving freewheeling mode" );
  49. }
  50. /* THREAD: RT (non-RT) */
  51. int
  52. Engine::buffer_size ( nframes_t )
  53. {
  54. // timeline->resize_buffers( nframes );
  55. return 0;
  56. }
  57. int Engine::sync ( jack_transport_state_t, jack_position_t * )
  58. {
  59. return 0;
  60. }
  61. void
  62. Engine::timebase ( jack_transport_state_t, jack_nframes_t, jack_position_t *, int )
  63. {
  64. }
  65. void
  66. Engine::timebase ( jack_transport_state_t, jack_nframes_t, jack_position_t * )
  67. {
  68. }
  69. /* THREAD: RT */
  70. int
  71. Engine::process ( nframes_t nframes )
  72. {
  73. /* FIXME: wrong place for this */
  74. _thread.set( "RT" );
  75. if ( freewheeling() )
  76. {
  77. /* /\* freewheeling mode/export. We're actually running */
  78. /* non-RT. Assume that everything is quiescent, locking is */
  79. /* unecessary and do I/O synchronously *\/ */
  80. /* if ( timeline ) */
  81. /* timeline->process( nframes ); */
  82. /* /\* because we're going faster than realtime. *\/ */
  83. /* timeline->wait_for_buffers(); */
  84. }
  85. else
  86. {
  87. if ( ! trylock() )
  88. {
  89. /* the data structures we need to access here (tracks and
  90. * their ports, but not track contents) may be in an
  91. * inconsistent state at the moment. Just punt and drop this
  92. * buffer. */
  93. ++_buffers_dropped;
  94. return 0;
  95. }
  96. /* handle chicken/egg problem */
  97. if ( mixer )
  98. /* this will initiate the process() call graph for the various
  99. * number and types of tracks, which will in turn send data out
  100. * the appropriate ports. */
  101. mixer->process( nframes );
  102. unlock();
  103. }
  104. return 0;
  105. }
  106. /* TRHEAD: RT */
  107. void
  108. Engine::thread_init ( void )
  109. {
  110. _thread.set( "RT" );
  111. }
  112. /* THREAD: RT */
  113. void
  114. Engine::shutdown ( void )
  115. {
  116. }