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.

128 lines
3.3KB

  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. /* THREAD: RT */
  60. int
  61. Engine::process ( nframes_t nframes )
  62. {
  63. /* FIXME: wrong place for this */
  64. _thread.set( "RT" );
  65. if ( freewheeling() )
  66. {
  67. /* /\* freewheeling mode/export. We're actually running */
  68. /* non-RT. Assume that everything is quiescent, locking is */
  69. /* unecessary and do I/O synchronously *\/ */
  70. /* if ( timeline ) */
  71. /* timeline->process( nframes ); */
  72. /* /\* because we're going faster than realtime. *\/ */
  73. /* timeline->wait_for_buffers(); */
  74. }
  75. else
  76. {
  77. if ( ! trylock() )
  78. {
  79. /* the data structures we need to access here (tracks and
  80. * their ports, but not track contents) may be in an
  81. * inconsistent state at the moment. Just punt and drop this
  82. * buffer. */
  83. ++_buffers_dropped;
  84. return 0;
  85. }
  86. _process_callback(nframes, _user_data);
  87. unlock();
  88. }
  89. return 0;
  90. }
  91. /* TRHEAD: RT */
  92. void
  93. Engine::thread_init ( void )
  94. {
  95. _thread.set( "RT" );
  96. }
  97. /* THREAD: RT */
  98. void
  99. Engine::shutdown ( void )
  100. {
  101. }