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.

93 lines
3.6KB

  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. #pragma once
  19. #include "util/Mutex.H"
  20. #include <jack/jack.h>
  21. typedef jack_nframes_t nframes_t;
  22. class Port;
  23. #include "Thread.H"
  24. class Engine : public Mutex
  25. {
  26. jack_client_t *_client;
  27. Thread _thread; /* only used for thread checking */
  28. int _buffers_dropped; /* buffers dropped because of locking */
  29. nframes_t _sample_rate;
  30. volatile int _xruns;
  31. volatile bool _freewheeling;
  32. volatile bool _zombified;
  33. static void shutdown ( void *arg );
  34. void shutdown ( void );
  35. static int process ( nframes_t nframes, void *arg );
  36. int process ( nframes_t nframes );
  37. static int sync ( jack_transport_state_t state, jack_position_t *pos, void *arg );
  38. int sync ( jack_transport_state_t state, jack_position_t *pos );
  39. static int xrun ( void *arg );
  40. int xrun ( void );
  41. static void timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg );
  42. void timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos );
  43. static void freewheel ( int yes, void *arg );
  44. void freewheel ( bool yes );
  45. static int buffer_size ( nframes_t nframes, void *arg );
  46. int buffer_size ( nframes_t nframes );
  47. static void thread_init ( void *arg );
  48. void thread_init ( void );
  49. Engine ( const Engine &rhs );
  50. Engine & operator = ( const Engine &rhs );
  51. void request_locate ( nframes_t frame );
  52. private:
  53. friend class Port;
  54. friend class Transport;
  55. jack_client_t * client ( void ) { return _client; }
  56. public:
  57. Engine ( );
  58. int init ( void );
  59. nframes_t nframes ( void ) const { return jack_get_buffer_size( _client ); }
  60. float frame_rate ( void ) const { return jack_get_sample_rate( _client ); }
  61. nframes_t sample_rate ( void ) const { return _sample_rate; }
  62. int xruns ( void ) const { return _xruns; };
  63. int dropped ( void ) const { return _buffers_dropped; }
  64. bool freewheeling ( void ) const { return _freewheeling; }
  65. void freewheeling ( bool yes );
  66. bool zombified ( void ) const { return _zombified; }
  67. float cpu_load ( void ) const { return jack_cpu_load( _client ); }
  68. };
  69. extern Engine * engine;