Fix build under mixed mode
[jack2.git] / common / JackPort.h
blob5cd9aef23b4f85ec3b7eb575d14d2da92d4e3462
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef __JackPort__
22 #define __JackPort__
24 #include "types.h"
25 #include "JackConstants.h"
26 #include "JackCompilerDeps.h"
28 namespace Jack
31 #define ALL_PORTS 0xFFFF
32 #define NO_PORT 0xFFFE
34 /*!
35 \brief Base class for port.
38 PRE_PACKED_STRUCTURE
39 class SERVER_EXPORT JackPort
42 friend class JackGraphManager;
44 private:
46 int fTypeId;
47 enum JackPortFlags fFlags;
48 char fName[REAL_JACK_PORT_NAME_SIZE+1];
49 char fAlias1[REAL_JACK_PORT_NAME_SIZE+1];
50 char fAlias2[REAL_JACK_PORT_NAME_SIZE+1];
51 int fRefNum;
53 jack_nframes_t fLatency;
54 jack_nframes_t fTotalLatency;
55 jack_latency_range_t fPlaybackLatency;
56 jack_latency_range_t fCaptureLatency;
57 uint8_t fMonitorRequests;
59 bool fInUse;
60 jack_port_id_t fTied; // Locally tied source port
61 jack_default_audio_sample_t fBuffer[BUFFER_SIZE_MAX + 8];
63 bool IsUsed() const
65 return fInUse;
68 // RT
69 void ClearBuffer(jack_nframes_t frames);
70 void MixBuffers(void** src_buffers, int src_count, jack_nframes_t frames);
72 public:
74 JackPort();
76 bool Allocate(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
77 void Release();
78 const char* GetName() const;
79 const char* GetShortName() const;
80 void SetName(const char* name);
82 int GetAliases(char* const aliases[2]);
83 int SetAlias(const char* alias);
84 int UnsetAlias(const char* alias);
85 bool NameEquals(const char* target);
87 int GetFlags() const;
88 const char* GetType() const;
90 int Tie(jack_port_id_t port_index);
91 int UnTie();
93 jack_nframes_t GetLatency() const;
94 void SetLatency(jack_nframes_t latency);
96 void SetLatencyRange(jack_latency_callback_mode_t mode, jack_latency_range_t* range);
97 void GetLatencyRange(jack_latency_callback_mode_t mode, jack_latency_range_t* range) const;
99 jack_nframes_t GetTotalLatency() const;
101 int RequestMonitor(bool onoff);
102 int EnsureMonitor(bool onoff);
103 bool MonitoringInput()
105 return (fMonitorRequests > 0);
108 // Since we are in shared memory, the resulting pointer cannot be cached, so align it here...
109 jack_default_audio_sample_t* GetBuffer()
111 return (jack_default_audio_sample_t*)((uintptr_t)fBuffer & ~31L) + 8;
114 int GetRefNum() const;
116 } POST_PACKED_STRUCTURE;
118 } // end of namespace
121 #endif