SiP and "solo overrides mutes" tweak:
[ardour.git] / libs / backends / wavesaudio / wavesapi / BasicTypes / WUComPtr.h
1 /*
2     Copyright (C) 2014 Waves Audio Ltd.
3
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
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __WUComPtr_h__
21 #define __WUComPtr_h__
22         
23 /* Copy to include
24 #include "BasicTypes/WUComPtr.h"
25 */
26
27 #include "WavesPublicAPI/wstdint.h"
28
29 typedef int32_t wvComPtr[2];
30
31 // ConvertDPtr has the exact format of a vfp callback function, but it is a local function, native only.
32 // It converts a pointer in either 32 bits or 64 bits to a place-holder of 64 bits in coefs/states/external memory.
33 // pData is expected to point to a pre-allocate space enough for storing a pointer (posibly two single-precision coefs).
34 // Since pointers are not transferable between hardwares, at preset time no need for a shell callback.
35 // We keep this as a cALGORITHM for compatibility with the rest of the convert functions
36 //================================================================================
37 inline uint32_t vfpConvertDPtr(const void* InPointer, void* pData)
38 //================================================================================
39 {       
40     uint64_t *pL = (uint64_t *)pData;
41     *pL = (uint64_t)InPointer;
42     return (uint32_t)sizeof(uint64_t);
43 }
44
45
46 /*
47 {
48         // data in that struct must be the same type of the Coefs/States type!
49         int32_t LSW; // Least significant word
50         int32_t MSW; // Most  significant word
51 };
52
53 inline wvComPtr PackToComPtr(const intptr_t in_PtrToPack)
54 // take ptr that hosted in intptr_t type
55 // and pack it to wvComPtr container type (MSW and LSW of 32bit each)
56 {
57         wvComPtr retVal;
58         int64_t t_PtrToPack = static_cast<int64_t>(in_PtrToPack);
59         // This packing is xPlatform coding for x32 and x64
60         // #ifdef for x64 - intptr_t is 64 bit
61         retVal.LSW = static_cast<int32_t>(t_PtrToPack & intptr_t(0xFFFFFFFF));
62         retVal.MSW = (static_cast<int32_t>(t_PtrToPack>>32));
63
64         // #ifdef for x32 - intptr_t is 32 bit
65 //      retVal.LSW = int32_t(in_PtrToPack);
66 //      retVal.MSW = 0;
67         
68         return retVal;
69 }
70
71 inline intptr_t UnpackComPtr( const wvComPtr in_ComPtrToUnpack)
72 // take wvComPtr with MSW and LSW of 32bit each
73 // and unpack it to intptr_t type
74 {
75         intptr_t retVal;
76         
77         // This unpacking is xPlatform coding for x32 and x64
78         // #ifdef for x64 - intptr_t is 64 bit so use intptr_t instead of int64_t
79         int64_t PtrAt64 = static_cast<int64_t>(in_ComPtrToUnpack.MSW);
80         PtrAt64 <<= 32;
81         PtrAt64 |= static_cast<int64_t>(in_ComPtrToUnpack.LSW);
82         retVal = static_cast<intptr_t>(PtrAt64);
83
84
85         // #ifdef for x32 - intptr_t is 32 bit
86 //      retVal = static_cast<intptr_t>(retVal.LSW);
87
88         return retVal;
89 }
90
91
92 //////////////////////////////////////////////////////////////////////////
93 inline uint32_t  ComPtr_to_DSP( const intptr_t PtrToConvert, char* pDataStruct )
94 {
95
96         *(reinterpret_cast<wvComPtr *>(pDataStruct)) = PackToComPtr(PtrToConvert);
97
98         return uint32_t(sizeof(wvComPtr));
99 }
100 //////////////////////////////////////////////////////////////////////////
101
102 //////////////////////////////////////////////////////////////////////////
103 inline uint32_t  DSP_to_ComPtr( const char* pDataStruct, intptr_t *ThePtr)
104 // pDataStruct is pointing to wvComPtr in the Coefs/States
105 // the function reconstruct the pointer into ThePtr
106 {
107
108         *ThePtr = UnpackComPtr(*(reinterpret_cast<const wvComPtr *>(pDataStruct)));
109
110         return uint32_t(sizeof(wvComPtr));
111 }
112 //////////////////////////////////////////////////////////////////////////
113 */
114
115 #endif //#if !defined(__WUComPtr_h__)
116
117
118