Jack2 1.9.7

JackPort.h

00001 /*
00002 Copyright (C) 2001 Paul Davis
00003 Copyright (C) 2004-2008 Grame
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU Lesser General Public License as published by
00007 the Free Software Foundation; either version 2.1 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 
00019 */
00020 
00021 #ifndef __JackPort__
00022 #define __JackPort__
00023 
00024 #include "types.h"
00025 #include "JackConstants.h"
00026 #include "JackCompilerDeps.h"
00027 
00028 namespace Jack
00029 {
00030 
00031 #define ALL_PORTS       0xFFFF
00032 #define NO_PORT         0xFFFE
00033 
00038 class SERVER_EXPORT JackPort
00039 {
00040 
00041         friend class JackGraphManager;
00042 
00043     private:
00044 
00045         int fTypeId;
00046         enum JackPortFlags fFlags;
00047         char fName[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
00048         char fAlias1[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
00049         char fAlias2[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
00050         int fRefNum;
00051 
00052         jack_nframes_t fLatency;
00053         jack_nframes_t fTotalLatency;
00054         jack_latency_range_t  fPlaybackLatency;
00055         jack_latency_range_t  fCaptureLatency;
00056         uint8_t fMonitorRequests;
00057 
00058         bool fInUse;
00059         jack_port_id_t fTied;   // Locally tied source port
00060         jack_default_audio_sample_t fBuffer[BUFFER_SIZE_MAX + 4];
00061 
00062         bool IsUsed() const
00063         {
00064             return fInUse;
00065         }
00066 
00067         // RT
00068         void ClearBuffer(jack_nframes_t frames);
00069         void MixBuffers(void** src_buffers, int src_count, jack_nframes_t frames);
00070 
00071     public:
00072 
00073         JackPort();
00074 
00075         bool Allocate(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
00076         void Release();
00077         const char* GetName() const;
00078         const char* GetShortName() const;
00079         void SetName(const char* name);
00080 
00081         int GetAliases(char* const aliases[2]);
00082         int SetAlias(const char* alias);
00083         int UnsetAlias(const char* alias);
00084         bool NameEquals(const char* target);
00085 
00086         int     GetFlags() const;
00087         const char* GetType() const;
00088 
00089         int Tie(jack_port_id_t port_index);
00090         int UnTie();
00091 
00092         jack_nframes_t GetLatency() const;
00093         void SetLatency(jack_nframes_t latency);
00094 
00095         void SetLatencyRange(jack_latency_callback_mode_t mode, jack_latency_range_t* range);
00096         void GetLatencyRange(jack_latency_callback_mode_t mode, jack_latency_range_t* range) const;
00097 
00098         jack_nframes_t GetTotalLatency() const;
00099 
00100         int RequestMonitor(bool onoff);
00101         int EnsureMonitor(bool onoff);
00102         bool MonitoringInput()
00103         {
00104             return (fMonitorRequests > 0);
00105         }
00106 
00107         // Since we are in shared memory, the resulting pointer cannot be cached, so align it here...
00108         jack_default_audio_sample_t* GetBuffer()
00109         {
00110             return (jack_default_audio_sample_t*)((long)fBuffer & ~15L) + 4;
00111         }
00112 
00113         int GetRefNum() const;
00114 
00115 } POST_PACKED_STRUCTURE;
00116 
00117 } // end of namespace
00118 
00119 
00120 #endif
00121