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.

129 lines
3.4KB

  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. deactivate();
  33. }
  34. /*************/
  35. /* Callbacks */
  36. /*************/
  37. /* THREAD: RT */
  38. /** This is the jack xrun callback */
  39. int
  40. Engine::xrun ( void )
  41. {
  42. return 0;
  43. }
  44. /* THREAD: RT */
  45. void
  46. Engine::freewheel ( bool starting )
  47. {
  48. if ( starting )
  49. DMESSAGE( "entering freewheeling mode" );
  50. else
  51. DMESSAGE( "leaving freewheeling mode" );
  52. }
  53. /* THREAD: RT (non-RT) */
  54. int
  55. Engine::buffer_size ( nframes_t )
  56. {
  57. // timeline->resize_buffers( nframes );
  58. return 0;
  59. }
  60. /* THREAD: RT */
  61. int
  62. Engine::process ( nframes_t nframes )
  63. {
  64. /* FIXME: wrong place for this */
  65. _thread.set( "RT" );
  66. if ( freewheeling() )
  67. {
  68. /* /\* freewheeling mode/export. We're actually running */
  69. /* non-RT. Assume that everything is quiescent, locking is */
  70. /* unecessary and do I/O synchronously *\/ */
  71. /* if ( timeline ) */
  72. /* timeline->process( nframes ); */
  73. /* /\* because we're going faster than realtime. *\/ */
  74. /* timeline->wait_for_buffers(); */
  75. }
  76. else
  77. {
  78. if ( ! trylock() )
  79. {
  80. /* the data structures we need to access here (tracks and
  81. * their ports, but not track contents) may be in an
  82. * inconsistent state at the moment. Just punt and drop this
  83. * buffer. */
  84. ++_buffers_dropped;
  85. return 0;
  86. }
  87. _process_callback(nframes, _user_data);
  88. unlock();
  89. }
  90. return 0;
  91. }
  92. /* TRHEAD: RT */
  93. void
  94. Engine::thread_init ( void )
  95. {
  96. _thread.set( "RT" );
  97. }
  98. /* THREAD: RT */
  99. void
  100. Engine::shutdown ( void )
  101. {
  102. }