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.

131 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. _process_callback_user_data = user_data;
  28. _buffer_size_callback = 0;
  29. _buffers_dropped = 0;
  30. }
  31. Engine::~Engine ( )
  32. {
  33. deactivate();
  34. }
  35. void
  36. Engine::buffer_size_callback ( void ( *buffer_size_callback ) ( nframes_t, void * ), void *user_data )
  37. {
  38. _buffer_size_callback = buffer_size_callback;
  39. _buffer_size_callback_user_data = user_data;
  40. }
  41. /*************/
  42. /* Callbacks */
  43. /*************/
  44. /* THREAD: RT */
  45. /** This is the jack xrun callback */
  46. int
  47. Engine::xrun ( void )
  48. {
  49. return 0;
  50. }
  51. /* THREAD: RT */
  52. void
  53. Engine::freewheel ( bool starting )
  54. {
  55. if ( starting )
  56. DMESSAGE( "entering freewheeling mode" );
  57. else
  58. DMESSAGE( "leaving freewheeling mode" );
  59. }
  60. /* THREAD: RT (non-RT) */
  61. int
  62. Engine::buffer_size ( nframes_t nframes )
  63. {
  64. /* JACK calls this in the RT thread, even though it's a
  65. * non-realtime operation. This mucks up our ability to do
  66. * THREAD_ASSERT, so just lie and say this is the UI thread... */
  67. _thread.set( "UI" );
  68. _buffer_size_callback( nframes, _buffer_size_callback_user_data );
  69. _thread.set( "RT" );
  70. return 0;
  71. }
  72. /* THREAD: RT */
  73. int
  74. Engine::process ( nframes_t nframes )
  75. {
  76. /* FIXME: wrong place for this */
  77. _thread.set( "RT" );
  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, _process_callback_user_data);
  88. unlock();
  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. }