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.

121 lines
3.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. #pragma once
  19. // #include <jack/jack.h>
  20. #include "Client.H"
  21. #include <stdlib.h>
  22. namespace JACK
  23. {
  24. class Port
  25. {
  26. jack_port_t *_port;
  27. char *_name;
  28. JACK::Client *_client;
  29. /* FIXME: reference count? */
  30. /* /\* not permitted *\/ */
  31. /* Port ( const Port &rhs ); */
  32. /* Port & operator= ( const Port &rhs ); */
  33. public:
  34. bool operator < ( const Port & rhs ) const;
  35. enum type_e { Output, Input };
  36. static int max_name ( void );
  37. Port ( JACK::Client *client, jack_port_t *port );
  38. Port ( JACK::Client *client, const char *name, type_e dir );
  39. Port ( JACK::Client *client, type_e dir, const char *base, int n, const char *type=0 );
  40. Port ( JACK::Client *client, type_e dir, int n, const char *type=0 );
  41. // Port ( );
  42. ~Port ( );
  43. Port ( const Port & rhs );
  44. bool valid ( void ) const { return _port; }
  45. bool connected ( void ) const { return jack_port_connected( _port ); }
  46. type_e type ( void ) const;
  47. const char * name ( void ) const { return _name; }
  48. bool name ( const char *name );
  49. bool name ( const char *base, int n, const char *type=0 );
  50. nframes_t total_latency ( void ) const;
  51. nframes_t latency ( void ) const;
  52. void latency ( nframes_t frames );
  53. bool activate ( void );
  54. void shutdown ( void );
  55. void write ( sample_t *buf, nframes_t nframes );
  56. void read ( sample_t *buf, nframes_t nframes );
  57. void *buffer ( nframes_t nframes );
  58. void silence ( nframes_t nframes );
  59. /* */
  60. const char ** connections ( void );
  61. bool connections ( const char **port_names );
  62. void freeze ( void );
  63. void thaw ( void );
  64. private:
  65. type_e _direction;
  66. bool activate ( const char *name, type_e dir );
  67. /* holds all we need to know about a jack port to recreate it on a
  68. new client */
  69. struct freeze_state
  70. {
  71. const char **connections;
  72. char *name;
  73. freeze_state ( )
  74. {
  75. connections = NULL;
  76. name = NULL;
  77. }
  78. ~freeze_state ( )
  79. {
  80. if ( connections )
  81. {
  82. free( connections );
  83. connections = NULL;
  84. }
  85. if ( name )
  86. {
  87. free( name );
  88. }
  89. }
  90. };
  91. freeze_state *_freezer;
  92. };
  93. }