1// **************************************************************************** 2// 3// CChannelMask.h 4// 5// Include file for interfacing with the CChannelMask and CChMaskDsp 6// classes. 7// Set editor tabs to 3 for your viewing pleasure. 8// 9// CChannelMask is a handy way to specify a group of pipes simultaneously. 10// It should really be called "CPipeMask", but the class name predates 11// the term "pipe". 12// 13// CChMaskDsp is used in the comm page to specify a group of channels 14// at once; these are read by the DSP and must therefore be kept 15// in little-endian format. 16// 17//--------------------------------------------------------------------------- 18// 19// ---------------------------------------------------------------------------- 20// 21// This file is part of Echo Digital Audio's generic driver library. 22// Copyright Echo Digital Audio Corporation (c) 1998 - 2005 23// All rights reserved 24// www.echoaudio.com 25// 26// This library is free software; you can redistribute it and/or 27// modify it under the terms of the GNU Lesser General Public 28// License as published by the Free Software Foundation; either 29// version 2.1 of the License, or (at your option) any later version. 30// 31// This library is distributed in the hope that it will be useful, 32// but WITHOUT ANY WARRANTY; without even the implied warranty of 33// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 34// Lesser General Public License for more details. 35// 36// You should have received a copy of the GNU Lesser General Public 37// License along with this library; if not, write to the Free Software 38// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 39// 40// **************************************************************************** 41 42// Prevent problems with multiple includes 43#ifndef _CHMASKOBJECT_ 44#define _CHMASKOBJECT_ 45 46// 47// Defines 48// 49typedef unsigned long CH_MASK; 50 51#define CH_MASK_BITS (sizeof( CH_MASK ) * 8) 52 // Max bits per mask entry 53 54#define ECHO_INVALID_CHANNEL ((WORD)(-1)) 55 // Marks unused channel # 56 57typedef unsigned long CH_MASK_DSP; 58#define CH_MASK_DSP_BITS (sizeof( CH_MASK_DSP ) * 8) 59 // Max bits per mask entry 60 61/**************************************************************************** 62 63 CChannelMask 64 65 ****************************************************************************/ 66 67class CChannelMask 68{ 69protected: 70 71#ifdef ECHO_OS9 72 friend class CInOutChannelMask; 73#endif 74 75 CH_MASK m_Mask; // One bit per output or input channel 76 77public: 78 79 CChannelMask(); 80 ~CChannelMask() {} 81 82 CH_MASK GetMask() 83 { 84 return m_Mask; 85 } 86 87 // Returns TRUE if no bits set 88 BOOL IsEmpty(); 89 90 // Set the wPipeIndex bit in the mask 91 void SetIndexInMask( WORD wPipeIndex ); 92 93 // Clear the wPipeIndex bit in the mask 94 void ClearIndexInMask( WORD wPipeIndex ); 95 96 // Return the next bit set starting with wStartPipeIndex as an index. 97 // If nothing set, returns ECHO_INVALID_CHANNEL. 98 // Use this interface for enumerating thru a channel mask. 99 WORD GetIndexFromMask( WORD wStartPipeIndex ); 100 101 // Test driver channel index in mask. 102 // Return TRUE if set 103 BOOL TestIndexInMask( WORD wPipeIndex ); 104 105 // Clear all bits in the mask 106 void Clear(); 107 108 // Clear bits in this mask that are in SrcMask 109 void ClearMask( CChannelMask SrcMask ); 110 111 // Return TRUE if any bits in source mask are set in this mask 112 BOOL Test( CChannelMask * pSrcMask ); 113 114 // 115 // Return TRUE if the Test Mask contains all of the channels 116 // enabled in this instance. 117 // Use to be sure all channels in this instance exist in 118 // another instance. 119 // 120 BOOL IsSubsetOf( CChannelMask& TstMask ); 121 122 // 123 // Return TRUE if the Test Mask contains at least one of the channels 124 // enabled in this instance. 125 // Use to find out if any channels in this instance exist in 126 // another instance. 127 // 128 BOOL IsIntersectionOf( CChannelMask& TstMask ); 129 130 // 131 // Overload new & delete so memory for this object is allocated 132 // from non-paged memory. 133 // 134 PVOID operator new( size_t Size ); 135 VOID operator delete( PVOID pVoid ); 136 137 // 138 // Macintosh compiler likes "class" after friend, PC doesn't care 139 // 140 friend class CChMaskDsp; 141 142 // Return TRUE if source mask equals this mask 143 friend BOOLEAN operator == ( CONST CChannelMask &LVal, 144 CONST CChannelMask &RVal ); 145 146 // Copy mask bits in source to this mask 147 CChannelMask& operator = (CONST CChannelMask & RVal); 148 149 // Add mask bits in source to this mask 150 VOID operator += (CONST CChannelMask & RVal); 151 152 // Subtract mask bits in source to this mask 153 VOID operator -= (CONST CChannelMask & RVal); 154 155 // AND mask bits in source to this mask 156 VOID operator &= (CONST CChannelMask & RVal); 157 158 // OR mask bits in source to this mask 159 VOID operator |= (CONST CChannelMask & RVal); 160 161protected : 162 163 // 164 // Store an output bit mask and an input bitmask. 165 // We assume here that the # of outputs fits in one mask reg 166 // 167 void SetMask( CH_MASK OutMask, CH_MASK InMask, int nOutputs ); 168 void SetOutMask( CH_MASK OutMask, int nOutputs ); 169 void SetInMask( CH_MASK InMask, int nOutputs ); 170 171 // 172 // Retrieve an output bit mask and an input bitmask. 173 // We assume here that the # of outputs fits in one mask reg 174 // 175 void GetMask( CH_MASK & OutMask, CH_MASK & InMask, int nOutputs ); 176 CH_MASK GetOutMask( int nOutputs ); 177 CH_MASK GetInMask( int nOutputs ); 178 179}; // class CChannelMask 180 181typedef CChannelMask * PCChannelMask; 182 183 184/**************************************************************************** 185 186 CChMaskDsp 187 188 ****************************************************************************/ 189 190class CChMaskDsp 191{ 192public: 193 CH_MASK_DSP m_Mask; // One bit per output or input channel 194 // 32 bits total 195 CChMaskDsp(); 196 ~CChMaskDsp() {} 197 198 // Returns TRUE if no bits set 199 BOOL IsEmpty(); 200 201 // Set the wPipeIndex bit in the mask 202 void SetIndexInMask( WORD wPipeIndex ); 203 204 // Clear the wPipeIndex bit in the mask 205 void ClearIndexInMask( WORD wPipeIndex ); 206 207 // Test pipe index in mask. 208 // Return TRUE if set 209 BOOL TestIndexInMask( WORD wPipeIndex ); 210 211 // Clear all bits in the mask 212 void Clear(); 213 214 // 215 // Overload new & delete so memory for this object is allocated 216 // from non-paged memory. 217 // 218 PVOID operator new( size_t Size ); 219 VOID operator delete( PVOID pVoid ); 220 221 // 222 // Macintosh compiler likes "class" after friend, PC doesn't care 223 // 224 friend class CChannelMask; 225 226 // Copy mask bits in source to this mask 227 CChMaskDsp& operator = (CONST CChannelMask & RVal); 228 229protected : 230 231}; // class CChMaskDsp 232 233typedef CChMaskDsp * PCChMaskDsp; 234 235#endif // _CHMASKOBJECT_ 236 237// CChannelMask.h 238