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.

119 lines
4.0KB

  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. enum type_e { Output, Input };
  35. static int max_name ( void );
  36. Port ( JACK::Client *client, jack_port_t *port );
  37. Port ( JACK::Client *client, const char *name, type_e dir );
  38. Port ( JACK::Client *client, type_e dir, const char *base, int n, const char *type=0 );
  39. Port ( JACK::Client *client, type_e dir, int n, const char *type=0 );
  40. // Port ( );
  41. ~Port ( );
  42. Port ( const Port & rhs );
  43. bool valid ( void ) const { return _port; }
  44. bool connected ( void ) const { return jack_port_connected( _port ); }
  45. type_e type ( void ) const
  46. {
  47. return jack_port_flags( _port ) == JackPortIsOutput ? Output : Input;
  48. }
  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. void activate ( const char *name, type_e dir );
  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. /* */
  62. const char ** connections ( void );
  63. bool connections ( const char **port_names );
  64. void freeze ( void );
  65. void thaw ( void );
  66. private:
  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. type_e direction;
  73. char *name;
  74. freeze_state ( )
  75. {
  76. connections = NULL;
  77. name = NULL;
  78. }
  79. ~freeze_state ( )
  80. {
  81. if ( connections )
  82. {
  83. free( connections );
  84. connections = NULL;
  85. }
  86. if ( name )
  87. {
  88. free( name );
  89. }
  90. }
  91. };
  92. freeze_state *_freezer;
  93. };
  94. }