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.

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