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.

92 lines
2.9KB

  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 "Timeline.H" // for process()
  20. #define APP_NAME "Non-DAW" // FIXME: wrong place for this!
  21. /* This is the home of the JACK process callback (does this *really*
  22. need to be a class?) */
  23. Engine::Engine ( )
  24. {
  25. _client = NULL;
  26. _buffers_dropped = 0;
  27. }
  28. /* static wrapper */
  29. int
  30. Engine::process ( nframes_t nframes, void *arg )
  31. {
  32. return ((Engine*)arg)->process( nframes );
  33. }
  34. /* THREAD: RT */
  35. int
  36. Engine::process ( nframes_t nframes )
  37. {
  38. jack_position_t pos;
  39. jack_transport_state_t ts;
  40. ts = jack_transport_query( _client, &pos );
  41. if ( ts != JackTransportRolling )
  42. return 0;
  43. if ( ! trylock() )
  44. {
  45. /* the data structures we need to access here (tracks and
  46. * their ports, but not track contents) may be in an
  47. * inconsistent state at the moment. Just punt and drop this
  48. * buffer. */
  49. ++_buffers_dropped;
  50. return 0;
  51. }
  52. /* handle chicken/egg problem */
  53. if ( timeline )
  54. /* this will initiate the process() call graph for the various
  55. * number and types of tracks, which will in turn send data out
  56. * the appropriate ports. */
  57. timeline->process( nframes );
  58. unlock();
  59. return 0;
  60. }
  61. int
  62. Engine::init ( void )
  63. {
  64. if (( _client = jack_client_open ( APP_NAME, (jack_options_t)0, NULL )) == 0 )
  65. return 0;
  66. jack_set_process_callback( _client, &Engine::process, this );
  67. jack_activate( _client );
  68. /* we don't need to create any ports until tracks are created */
  69. return 1;
  70. }