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.

124 lines
4.1KB

  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. int connect ( const char *to );
  60. int disconnect ( const char *from );
  61. bool connected_to ( const char *to );
  62. /* */
  63. const char ** connections ( void );
  64. bool connections ( const char **port_names );
  65. void freeze ( void );
  66. void thaw ( void );
  67. private:
  68. type_e _direction;
  69. bool activate ( const char *name, type_e dir );
  70. /* holds all we need to know about a jack port to recreate it on a
  71. new client */
  72. struct freeze_state
  73. {
  74. const char **connections;
  75. char *name;
  76. freeze_state ( )
  77. {
  78. connections = NULL;
  79. name = NULL;
  80. }
  81. ~freeze_state ( )
  82. {
  83. if ( connections )
  84. {
  85. free( connections );
  86. connections = NULL;
  87. }
  88. if ( name )
  89. {
  90. free( name );
  91. }
  92. }
  93. };
  94. freeze_state *_freezer;
  95. };
  96. }