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 General Public License as published by
00007   the Free Software Foundation; either version 2 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 General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 */
00020 
00021 #ifndef __JackPort__
00022 #define __JackPort__
00023 
00024 #include "types.h"
00025 #include "JackConstants.h"
00026 
00027 namespace Jack
00028 {
00029 
00030 #define ALL_PORTS       0xFFFF
00031 #define NO_PORT         0xFFFE
00032 
00037 class JackPort
00038 {
00039 
00040         friend class JackGraphManager;
00041 
00042     private:
00043 
00044         int fTypeId;
00045         enum JackPortFlags fFlags;
00046         char fName[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
00047                 char fAlias1[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
00048                 char fAlias2[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
00049         int fRefNum;
00050 
00051         jack_nframes_t fLatency;
00052                 jack_nframes_t fTotalLatency;
00053         uint8_t fMonitorRequests;
00054 
00055         bool fInUse;
00056         jack_port_id_t fTied;   // Locally tied source port
00057 
00058         #ifdef WIN32
00059         //__declspec(align(16)) float fBuffer[BUFFER_SIZE_MAX];
00060                 float fBuffer[BUFFER_SIZE_MAX];
00061         #elif __GNUC__
00062                 float fBuffer[BUFFER_SIZE_MAX] __attribute__((aligned(64)));  // 16 bytes alignment for vector code, 64 bytes better for cache loads/stores
00063         #else
00064                 #warning Buffer will not be aligned on 16 bytes boundaries : vector based code (Altivec of SSE) will fail 
00065                 float fBuffer[BUFFER_SIZE_MAX];
00066         #endif
00067 
00068         bool IsUsed() const;
00069                 
00070                 // RT
00071         void ClearBuffer(jack_nframes_t frames);
00072         void MixBuffers(void** src_buffers, int src_count, jack_nframes_t frames);
00073 
00074     public:
00075 
00076         JackPort();
00077         virtual ~JackPort();
00078 
00079         bool Allocate(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
00080         void Release();
00081         const char* GetName() const;
00082         const char* GetShortName() const;
00083         int     SetName(const char* name);
00084                 
00085                 int GetAliases(char* const aliases[2]);
00086                 int SetAlias(const char* alias);
00087                 int UnsetAlias(const char* alias);
00088                 bool NameEquals(const char* target);
00089 
00090         int     GetFlags() const;
00091         const char* GetType() const;
00092 
00093                 int Tie(jack_port_id_t port_index);
00094         int UnTie();
00095 
00096         jack_nframes_t GetLatency() const;
00097                 jack_nframes_t GetTotalLatency() const;
00098         void SetLatency(jack_nframes_t latency);
00099 
00100         int RequestMonitor(bool onoff);
00101         int EnsureMonitor(bool onoff);
00102         bool MonitoringInput();
00103 
00104         float* GetBuffer();
00105         int GetRefNum() const;
00106         
00107 };
00108 
00109 
00110 } // end of namespace
00111 
00112 
00113 #endif
00114 

Generated on Thu Feb 14 11:16:02 2008 for Jackdmp by  doxygen 1.5.1