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.

123 lines
3.3KB

  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. #include "JackCompilerDeps.h"
  21. namespace Jack
  22. {
  23. #define ALL_PORTS 0xFFFF
  24. #define NO_PORT 0xFFFE
  25. /*!
  26. \brief Base class for port.
  27. */
  28. PRE_PACKED_STRUCTURE
  29. class SERVER_EXPORT JackPort
  30. {
  31. friend class JackGraphManager;
  32. private:
  33. int fTypeId;
  34. enum JackPortFlags fFlags;
  35. char fName[REAL_JACK_PORT_NAME_SIZE+1];
  36. char fAlias1[REAL_JACK_PORT_NAME_SIZE+1];
  37. char fAlias2[REAL_JACK_PORT_NAME_SIZE+1];
  38. int fRefNum;
  39. jack_nframes_t fLatency;
  40. jack_nframes_t fTotalLatency;
  41. jack_latency_range_t fPlaybackLatency;
  42. jack_latency_range_t fCaptureLatency;
  43. uint8_t fMonitorRequests;
  44. bool fInUse;
  45. jack_port_id_t fTied; // Locally tied source port
  46. jack_default_audio_sample_t fBuffer[BUFFER_SIZE_MAX + 8];
  47. bool IsUsed() const
  48. {
  49. return fInUse;
  50. }
  51. // RT
  52. void ClearBuffer(jack_nframes_t frames);
  53. void MixBuffers(void** src_buffers, int src_count, jack_nframes_t frames);
  54. public:
  55. JackPort();
  56. bool Allocate(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
  57. void Release();
  58. const char* GetName() const;
  59. const char* GetShortName() const;
  60. void SetName(const char* name);
  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 GetFlags() const;
  66. const char* GetType() const;
  67. int Tie(jack_port_id_t port_index);
  68. int UnTie();
  69. jack_nframes_t GetLatency() const;
  70. void SetLatency(jack_nframes_t latency);
  71. void SetLatencyRange(jack_latency_callback_mode_t mode, jack_latency_range_t* range);
  72. void GetLatencyRange(jack_latency_callback_mode_t mode, jack_latency_range_t* range) const;
  73. jack_nframes_t GetTotalLatency() const;
  74. int RequestMonitor(bool onoff);
  75. int EnsureMonitor(bool onoff);
  76. bool MonitoringInput()
  77. {
  78. return (fMonitorRequests > 0);
  79. }
  80. // Since we are in shared memory, the resulting pointer cannot be cached, so align it here...
  81. jack_default_audio_sample_t* GetBuffer()
  82. {
  83. return (jack_default_audio_sample_t*)((uintptr_t)fBuffer & ~31L) + 8;
  84. }
  85. int GetRefNum() const;
  86. } POST_PACKED_STRUCTURE;
  87. } // end of namespace
  88. #endif