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
2.9KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2006 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 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 General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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. enum JackPortFlags fFlags;
  32. char fName[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
  33. char fAlias1[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
  34. char fAlias2[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
  35. int fRefNum;
  36. jack_nframes_t fLatency;
  37. uint8_t fMonitorRequests;
  38. bool fInUse;
  39. bool fLocked;
  40. jack_port_id_t fTied; // Locally tied source port
  41. #ifdef WIN32
  42. //__declspec(align(16)) float fBuffer[BUFFER_SIZE_MAX];
  43. float fBuffer[BUFFER_SIZE_MAX];
  44. #elif __GNUC__
  45. float fBuffer[BUFFER_SIZE_MAX] __attribute__((aligned(64))); // 16 alignment for vector code, 64 better for cache loads/stores
  46. #else
  47. #warning Buffer will not be aligned on 16 bytes boundaries : vector based code (Altivec of SSE) will fail
  48. float fBuffer[BUFFER_SIZE_MAX];
  49. #endif
  50. bool IsUsed() const;
  51. static void MixBuffer(float* mixbuffer, float* buffer, jack_nframes_t frames);
  52. public:
  53. JackPort();
  54. virtual ~JackPort();
  55. void Allocate(int refnum, const char* port_name, JackPortFlags flags);
  56. void Release();
  57. const char* GetName() const;
  58. const char* GetShortName() const;
  59. int SetName(const char* name);
  60. void Rename(const char* name, int index);
  61. int GetAliases(char* const aliases[2]);
  62. int SetAlias(const char* alias);
  63. int UnsetAlias(const char* alias);
  64. bool NameEquals(const char* target);
  65. int Flags() const;
  66. const char* Type() const;
  67. int Lock();
  68. int Unlock();
  69. int Tie(jack_port_id_t port_index);
  70. int UnTie();
  71. jack_nframes_t GetLatency() const;
  72. void SetLatency(jack_nframes_t latency);
  73. int RequestMonitor(bool onoff);
  74. int EnsureMonitor(bool onoff);
  75. bool MonitoringInput();
  76. float* GetBuffer();
  77. int GetRefNum() const;
  78. };
  79. } // end of namespace
  80. #endif