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.

127 lines
4.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. #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 direction_e { Output, Input };
  36. enum type_e { Audio, MIDI };
  37. static int max_name ( void );
  38. Port ( JACK::Client *client, jack_port_t *port );
  39. Port ( JACK::Client *client, const char *name, direction_e dir, type_e type );
  40. Port ( JACK::Client *client, direction_e dir, type_e type, const char *base, int n, const char *subtype=0 );
  41. Port ( JACK::Client *client, direction_e dir, type_e type, int n, const char *subtype=0 );
  42. // Port ( );
  43. ~Port ( );
  44. Port ( const Port & rhs );
  45. bool valid ( void ) const { return _port; }
  46. bool connected ( void ) const { return jack_port_connected( _port ); }
  47. direction_e direction ( void ) const { return _direction; }
  48. type_e type ( void ) const { return _type; }
  49. const char * name ( void ) const { return _name; }
  50. bool name ( const char *name );
  51. bool name ( const char *base, int n, const char *type=0 );
  52. nframes_t total_latency ( void ) const;
  53. nframes_t latency ( void ) const;
  54. void latency ( nframes_t frames );
  55. bool activate ( void );
  56. void shutdown ( void );
  57. void write ( sample_t *buf, nframes_t nframes );
  58. void read ( sample_t *buf, nframes_t nframes );
  59. void *buffer ( nframes_t nframes );
  60. void silence ( nframes_t nframes );
  61. int connect ( const char *to );
  62. int disconnect ( const char *from );
  63. bool connected_to ( const char *to );
  64. /* */
  65. const char ** connections ( void );
  66. bool connections ( const char **port_names );
  67. void freeze ( void );
  68. void thaw ( void );
  69. private:
  70. direction_e _direction;
  71. type_e _type;
  72. bool activate ( const char *name, direction_e dir );
  73. /* holds all we need to know about a jack port to recreate it on a
  74. new client */
  75. struct freeze_state
  76. {
  77. const char **connections;
  78. char *name;
  79. freeze_state ( )
  80. {
  81. connections = NULL;
  82. name = NULL;
  83. }
  84. ~freeze_state ( )
  85. {
  86. if ( connections )
  87. {
  88. free( connections );
  89. connections = NULL;
  90. }
  91. if ( name )
  92. {
  93. free( name );
  94. }
  95. }
  96. };
  97. freeze_state *_freezer;
  98. };
  99. }