jack2 codebase
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.

115 lines
3.0KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2008 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. #ifndef __JackPort__
  17. #define __JackPort__
  18. #include "types.h"
  19. #include "JackConstants.h"
  20. namespace Jack
  21. {
  22. #define ALL_PORTS 0xFFFF
  23. #define NO_PORT 0xFFFE
  24. /*!
  25. \brief Base class for port.
  26. */
  27. class JackPort
  28. {
  29. friend class JackGraphManager;
  30. private:
  31. int fTypeId;
  32. enum JackPortFlags fFlags;
  33. char fName[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
  34. char fAlias1[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
  35. char fAlias2[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
  36. int fRefNum;
  37. jack_nframes_t fLatency;
  38. jack_nframes_t fTotalLatency;
  39. uint8_t fMonitorRequests;
  40. bool fInUse;
  41. jack_port_id_t fTied; // Locally tied source port
  42. #ifdef WIN32
  43. //__declspec(align(16)) float fBuffer[BUFFER_SIZE_MAX];
  44. float fBuffer[BUFFER_SIZE_MAX];
  45. #elif __GNUC__
  46. float fBuffer[BUFFER_SIZE_MAX] __attribute__((aligned(64))); // 16 bytes alignment for vector code, 64 bytes better for cache loads/stores
  47. #else
  48. #warning Buffer will not be aligned on 16 bytes boundaries : vector based code (Altivec of SSE) will fail
  49. float fBuffer[BUFFER_SIZE_MAX];
  50. #endif
  51. bool IsUsed() const;
  52. // RT
  53. void ClearBuffer(jack_nframes_t frames);
  54. void MixBuffers(void** src_buffers, int src_count, jack_nframes_t frames);
  55. public:
  56. JackPort();
  57. virtual ~JackPort();
  58. bool Allocate(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
  59. void Release();
  60. const char* GetName() const;
  61. const char* GetShortName() const;
  62. int SetName(const char* name);
  63. int GetAliases(char* const aliases[2]);
  64. int SetAlias(const char* alias);
  65. int UnsetAlias(const char* alias);
  66. bool NameEquals(const char* target);
  67. int GetFlags() const;
  68. const char* GetType() const;
  69. int Tie(jack_port_id_t port_index);
  70. int UnTie();
  71. jack_nframes_t GetLatency() const;
  72. jack_nframes_t GetTotalLatency() const;
  73. void SetLatency(jack_nframes_t latency);
  74. int RequestMonitor(bool onoff);
  75. int EnsureMonitor(bool onoff);
  76. bool MonitoringInput();
  77. float* GetBuffer();
  78. int GetRefNum() const;
  79. };
  80. } // end of namespace
  81. #endif