1626bc4beSJérôme Duval// ****************************************************************************
2626bc4beSJérôme Duval//
3626bc4beSJérôme Duval//		CChannelMask.cpp
4626bc4beSJérôme Duval//
5626bc4beSJérôme Duval//		Implementation file for the CChannelMask class.
6626bc4beSJérôme Duval//
7626bc4beSJérôme Duval// 	CChannelMask is a handy way to specify a group of pipes simultaneously.
8626bc4beSJérôme Duval//		It should really be called "CPipeMask", but the class name predates
9626bc4beSJérôme Duval//		the term "pipe".
10626bc4beSJérôme Duval//
11626bc4beSJérôme Duval// 	Since these masks are sometimes passed to the DSP, they must be kept in
12626bc4beSJérôme Duval//	 	little-endian format; the class does this for you.
13626bc4beSJérôme Duval//
14626bc4beSJérôme Duval// ----------------------------------------------------------------------------
15626bc4beSJérôme Duval//
16626bc4beSJérôme Duval// This file is part of Echo Digital Audio's generic driver library.
17626bc4beSJérôme Duval// Copyright Echo Digital Audio Corporation (c) 1998 - 2005
18626bc4beSJérôme Duval// All rights reserved
19626bc4beSJérôme Duval// www.echoaudio.com
20626bc4beSJérôme Duval//
21626bc4beSJérôme Duval// This library is free software; you can redistribute it and/or
22626bc4beSJérôme Duval// modify it under the terms of the GNU Lesser General Public
23626bc4beSJérôme Duval// License as published by the Free Software Foundation; either
24626bc4beSJérôme Duval// version 2.1 of the License, or (at your option) any later version.
25626bc4beSJérôme Duval//
26626bc4beSJérôme Duval// This library is distributed in the hope that it will be useful,
27626bc4beSJérôme Duval// but WITHOUT ANY WARRANTY; without even the implied warranty of
28626bc4beSJérôme Duval// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29626bc4beSJérôme Duval// Lesser General Public License for more details.
30626bc4beSJérôme Duval//
31626bc4beSJérôme Duval// You should have received a copy of the GNU Lesser General Public
32626bc4beSJérôme Duval// License along with this library; if not, write to the Free Software
33626bc4beSJérôme Duval// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34626bc4beSJérôme Duval//
35626bc4beSJérôme Duval// ****************************************************************************
36626bc4beSJérôme Duval
37626bc4beSJérôme Duval#include "CEchoGals.h"
38626bc4beSJérôme Duval
39626bc4beSJérôme Duval
40626bc4beSJérôme Duval/****************************************************************************
41626bc4beSJérôme Duval
42626bc4beSJérôme Duval	CChannelMask
43626bc4beSJérôme Duval
44626bc4beSJérôme Duval ****************************************************************************/
45626bc4beSJérôme Duval
46626bc4beSJérôme Duval//===========================================================================
47626bc4beSJérôme Duval//
48626bc4beSJérôme Duval// Constructor
49626bc4beSJérôme Duval//
50626bc4beSJérôme Duval//===========================================================================
51626bc4beSJérôme Duval
52626bc4beSJérôme DuvalCChannelMask::CChannelMask()
53626bc4beSJérôme Duval{
54626bc4beSJérôme Duval
55626bc4beSJérôme Duval	Clear();
56626bc4beSJérôme Duval
57626bc4beSJérôme Duval}	// CChannelMask::CChannelMask()
58626bc4beSJérôme Duval
59626bc4beSJérôme Duval
60626bc4beSJérôme Duval//===========================================================================
61626bc4beSJérôme Duval//
62626bc4beSJérôme Duval//	SetMask, SetOutMask, and SetInMask all allow you to just set
63626bc4beSJérôme Duval// the masks directly.
64626bc4beSJérôme Duval//
65626bc4beSJérôme Duval//===========================================================================
66626bc4beSJérôme Duval
67626bc4beSJérôme Duvalvoid CChannelMask::SetMask( CH_MASK OutMask, CH_MASK InMask, int nOutputs )
68626bc4beSJérôme Duval{
69626bc4beSJérôme Duval
70be188ae1SJérôme Duval	m_Mask = OutMask;
71be188ae1SJérôme Duval	m_Mask |= InMask << nOutputs;
72626bc4beSJérôme Duval
73626bc4beSJérôme Duval}	// void CChannelMask::SetMask( ... )
74626bc4beSJérôme Duval
75626bc4beSJérôme Duval
76626bc4beSJérôme Duvalvoid CChannelMask::SetOutMask( CH_MASK OutMask, int nOutputs )
77626bc4beSJérôme Duval{
78626bc4beSJérôme Duval
79be188ae1SJérôme Duval	m_Mask &= ((CH_MASK) -1) << nOutputs;
80be188ae1SJérôme Duval	m_Mask |= OutMask;
81626bc4beSJérôme Duval
82626bc4beSJérôme Duval}	// void CChannelMask::SetOutMask( CH_MASK OutMask, int nOutputs )
83626bc4beSJérôme Duval
84626bc4beSJérôme Duval
85626bc4beSJérôme Duvalvoid CChannelMask::SetInMask( CH_MASK InMask, int nOutputs )
86626bc4beSJérôme Duval{
87be188ae1SJérôme Duval	m_Mask &= ~( (CH_MASK) -1 << nOutputs );
88be188ae1SJérôme Duval	m_Mask |= InMask << nOutputs;
89626bc4beSJérôme Duval}	// void CChannelMask::SetInMask( CH_MASK InMask, int nOutputs )
90626bc4beSJérôme Duval
91626bc4beSJérôme Duval
92626bc4beSJérôme Duval//===========================================================================
93626bc4beSJérôme Duval//
94626bc4beSJérôme Duval//	Retrieve an output bit mask and an input bitmask.
95626bc4beSJérôme Duval//
96626bc4beSJérôme Duval//===========================================================================
97626bc4beSJérôme Duval
98626bc4beSJérôme Duvalvoid CChannelMask::GetMask( CH_MASK & OutMask, CH_MASK & InMask, int nOutputs )
99626bc4beSJérôme Duval{
100626bc4beSJérôme Duval	OutMask = GetOutMask( nOutputs );
101626bc4beSJérôme Duval	InMask = GetInMask( nOutputs );
102626bc4beSJérôme Duval}	// void CChannelMask::GetMask( ... )
103626bc4beSJérôme Duval
104626bc4beSJérôme DuvalCH_MASK CChannelMask::GetOutMask( int nOutputs )
105626bc4beSJérôme Duval{
106be188ae1SJérôme Duval	return  m_Mask & ~( (CH_MASK) -1 << nOutputs );
107626bc4beSJérôme Duval}	// CH_MASK CChannelMask::GetOutMask( int nOutputs )
108626bc4beSJérôme Duval
109626bc4beSJérôme DuvalCH_MASK CChannelMask::GetInMask( int nOutputs )
110626bc4beSJérôme Duval{
111be188ae1SJérôme Duval	return  m_Mask >> nOutputs;
112626bc4beSJérôme Duval}	// CH_MASK CChannelMask::GetIntMask( int nOutputs )
113626bc4beSJérôme Duval
114626bc4beSJérôme Duval
115626bc4beSJérôme Duval//===========================================================================
116626bc4beSJérôme Duval//
117626bc4beSJérôme Duval// IsEmpty returns TRUE if mask has no bits set
118626bc4beSJérôme Duval//
119626bc4beSJérôme Duval//===========================================================================
120626bc4beSJérôme Duval
121626bc4beSJérôme DuvalBOOL CChannelMask::IsEmpty()
122626bc4beSJérôme Duval{
123be188ae1SJérôme Duval	if (0 != m_Mask)
124be188ae1SJérôme Duval		return FALSE;
125626bc4beSJérôme Duval
126626bc4beSJérôme Duval	return TRUE;
127626bc4beSJérôme Duval
128626bc4beSJérôme Duval}	// void CChannelMask::IsEmpty()
129626bc4beSJérôme Duval
130626bc4beSJérôme Duval
131626bc4beSJérôme Duval//===========================================================================
132626bc4beSJérôme Duval//
133626bc4beSJérôme Duval// Call SetIndexInMask and ClearIndexInMask to set or clear a single bit.
134626bc4beSJérôme Duval//
135626bc4beSJérôme Duval//===========================================================================
136626bc4beSJérôme Duval
137626bc4beSJérôme Duval// Set driver channel index into DSP mask format
138626bc4beSJérôme Duvalvoid CChannelMask::SetIndexInMask( WORD wPipeIndex )
139626bc4beSJérôme Duval{
140be188ae1SJérôme Duval	m_Mask |= 1 << wPipeIndex;
141626bc4beSJérôme Duval
142626bc4beSJérôme Duval}	// void CChannelMask::SetIndexInMask( WORD wPipeIndex )
143626bc4beSJérôme Duval
144626bc4beSJérôme Duval
145626bc4beSJérôme Duval// Clear driver channel index into DSP mask format
146626bc4beSJérôme Duvalvoid CChannelMask::ClearIndexInMask( WORD wPipeIndex )
147626bc4beSJérôme Duval{
148626bc4beSJérôme Duval
149be188ae1SJérôme Duval	m_Mask &= ~((CH_MASK) 1 << wPipeIndex);
150be188ae1SJérôme Duval
151626bc4beSJérôme Duval}	// void CChannelMask::ClearIndexInMask( WORD wPipeIndex )
152626bc4beSJérôme Duval
153626bc4beSJérôme Duval
154626bc4beSJérôme Duval//===========================================================================
155626bc4beSJérôme Duval//
156626bc4beSJérôme Duval// Use GetIndexFromMask	to search the mask for bits that are set.
157626bc4beSJérôme Duval//
158626bc4beSJérôme Duval// The search starts at the bit specified by wStartPipeIndex and returns
159626bc4beSJérôme Duval// the pipe index for the first non-zero bit found.
160626bc4beSJérôme Duval//
161626bc4beSJérôme Duval//	Returns ECHO_INVALID_CHANNEL if none are found.
162626bc4beSJérôme Duval//
163626bc4beSJérôme Duval//===========================================================================
164626bc4beSJérôme Duval
165626bc4beSJérôme DuvalWORD CChannelMask::GetIndexFromMask( WORD wStartPipeIndex )
166626bc4beSJérôme Duval{
167be188ae1SJérôme Duval	CH_MASK bit;
168be188ae1SJérôme Duval	WORD index;
169be188ae1SJérôme Duval
170be188ae1SJérôme Duval	bit = 1 << wStartPipeIndex;
171be188ae1SJérôme Duval	index = wStartPipeIndex;
172be188ae1SJérôme Duval	while (bit != 0)
173626bc4beSJérôme Duval	{
174be188ae1SJérôme Duval		if (0 != (m_Mask & bit))
175be188ae1SJérôme Duval			return index;
176be188ae1SJérôme Duval
177be188ae1SJérôme Duval		bit <<= 1;
178be188ae1SJérôme Duval		index++;
179626bc4beSJérôme Duval	}
180be188ae1SJérôme Duval
181626bc4beSJérôme Duval	return( (WORD) ECHO_INVALID_CHANNEL );
182626bc4beSJérôme Duval
183626bc4beSJérôme Duval}		// WORD CChannelMask::GetIndexFromMask( WORD wStartIndex )
184626bc4beSJérôme Duval
185626bc4beSJérôme Duval
186626bc4beSJérôme Duval//===========================================================================
187626bc4beSJérôme Duval//
188626bc4beSJérôme Duval// Returns TRUE if the bit specified by the pipe index is set.
189626bc4beSJérôme Duval//
190626bc4beSJérôme Duval//===========================================================================
191626bc4beSJérôme Duval
192626bc4beSJérôme DuvalBOOL CChannelMask::TestIndexInMask( WORD wPipeIndex )
193626bc4beSJérôme Duval{
194be188ae1SJérôme Duval	if (0 != (m_Mask & ((CH_MASK) 1 << wPipeIndex)))
195626bc4beSJérôme Duval		return TRUE;
196626bc4beSJérôme Duval
197626bc4beSJérôme Duval	return FALSE;
198626bc4beSJérôme Duval}	// BOOL CChannelMask::TestIndexInMask( WORD wPipeIndex )
199626bc4beSJérôme Duval
200626bc4beSJérôme Duval
201626bc4beSJérôme Duval//===========================================================================
202626bc4beSJérôme Duval//
203626bc4beSJérôme Duval// Clear bits in this mask that are in SrcMask - this is just like
204626bc4beSJérôme Duval// operator -=, below.
205626bc4beSJérôme Duval//
206626bc4beSJérôme Duval//===========================================================================
207626bc4beSJérôme Duval
208626bc4beSJérôme Duvalvoid CChannelMask::ClearMask( CChannelMask SrcMask )
209626bc4beSJérôme Duval{
210be188ae1SJérôme Duval	m_Mask &= ~SrcMask.m_Mask;
211626bc4beSJérôme Duval
212626bc4beSJérôme Duval}	// void CChannelMask::ClearMask( CChannelMask SrcMask )
213626bc4beSJérôme Duval
214626bc4beSJérôme Duval
215626bc4beSJérôme Duval//===========================================================================
216626bc4beSJérôme Duval//
217626bc4beSJérôme Duval//	Clear all channels in this mask
218626bc4beSJérôme Duval//
219626bc4beSJérôme Duval//===========================================================================
220626bc4beSJérôme Duval
221626bc4beSJérôme Duvalvoid CChannelMask::Clear()
222626bc4beSJérôme Duval{
223be188ae1SJérôme Duval	m_Mask = 0;
224626bc4beSJérôme Duval}	// void CChannelMask::Clear()
225626bc4beSJérôme Duval
226626bc4beSJérôme Duval
227626bc4beSJérôme Duval//===========================================================================
228626bc4beSJérôme Duval//
229626bc4beSJérôme Duval//	operator +=    Add channels in source mask to this mask
230626bc4beSJérôme Duval//
231626bc4beSJérôme Duval//===========================================================================
232626bc4beSJérôme Duval
233626bc4beSJérôme DuvalVOID CChannelMask::operator += (CONST CChannelMask & RVal)
234626bc4beSJérôme Duval{
235be188ae1SJérôme Duval	m_Mask |= RVal.m_Mask;
236626bc4beSJérôme Duval
237626bc4beSJérôme Duval}	// VOID operator += (CONST CChannelMask & RVal)
238626bc4beSJérôme Duval
239626bc4beSJérôme Duval
240626bc4beSJérôme Duval//===========================================================================
241626bc4beSJérôme Duval//
242626bc4beSJérôme Duval//	operator -=    Remove channels in source mask from this mask
243626bc4beSJérôme Duval//
244626bc4beSJérôme Duval//===========================================================================
245626bc4beSJérôme Duval
246626bc4beSJérôme DuvalVOID CChannelMask::operator -= (CONST CChannelMask & RVal)
247626bc4beSJérôme Duval{
248be188ae1SJérôme Duval	ClearMask(RVal);
249626bc4beSJérôme Duval}	// VOID operator -= (CONST CChannelMask & RVal)
250626bc4beSJérôme Duval
251626bc4beSJérôme Duval
252626bc4beSJérôme Duval//===========================================================================
253626bc4beSJérôme Duval//
254626bc4beSJérôme Duval// Test returns TRUE if any bits in source mask are set in this mask
255626bc4beSJérôme Duval//
256626bc4beSJérôme Duval//===========================================================================
257626bc4beSJérôme Duval
258626bc4beSJérôme DuvalBOOL CChannelMask::Test( PCChannelMask pSrcMask )
259626bc4beSJérôme Duval{
260be188ae1SJérôme Duval	if (0 != (m_Mask & pSrcMask->m_Mask))
261be188ae1SJérôme Duval		return TRUE;
262be188ae1SJérôme Duval
263626bc4beSJérôme Duval	return FALSE;
264626bc4beSJérôme Duval
265626bc4beSJérôme Duval}	// BOOL CChannelMask::Test( PChannelMask pSrcMask )
266626bc4beSJérôme Duval
267626bc4beSJérôme Duval
268626bc4beSJérôme Duval//===========================================================================
269626bc4beSJérôme Duval//
270626bc4beSJérôme Duval//	IsSubsetOf returns TRUE if all of the channels in TstMask are set in
271be188ae1SJérôme Duval// m_Mask.
272626bc4beSJérôme Duval//
273626bc4beSJérôme Duval//	Use to be sure all channels in this instance exist in
274626bc4beSJérôme Duval//	another instance.
275626bc4beSJérôme Duval//
276626bc4beSJérôme Duval//===========================================================================
277626bc4beSJérôme Duval
278626bc4beSJérôme DuvalBOOL CChannelMask::IsSubsetOf
279626bc4beSJérôme Duval(
280626bc4beSJérôme Duval	CChannelMask& TstMask
281626bc4beSJérôme Duval)
282626bc4beSJérôme Duval{
283be188ae1SJérôme Duval	if ((m_Mask & TstMask.m_Mask) != TstMask.m_Mask)
284be188ae1SJérôme Duval		return FALSE;
285626bc4beSJérôme Duval
286626bc4beSJérôme Duval	return TRUE;
287626bc4beSJérôme Duval
288626bc4beSJérôme Duval}	// BOOL CChannelMask::IsSubsetOf
289626bc4beSJérôme Duval
290626bc4beSJérôme Duval
291626bc4beSJérôme Duval//===========================================================================
292626bc4beSJérôme Duval//
293626bc4beSJérôme Duval//	IsIntersectionOf returns TRUE if TstMask contains at least one of the
294626bc4beSJérôme Duval// channels enabled in this instance.
295626bc4beSJérôme Duval//
296626bc4beSJérôme Duval//	Use this to find out if any channels in this instance exist in
297626bc4beSJérôme Duval//	another instance.
298626bc4beSJérôme Duval//
299626bc4beSJérôme Duval//===========================================================================
300626bc4beSJérôme Duval
301626bc4beSJérôme DuvalBOOL CChannelMask::IsIntersectionOf
302626bc4beSJérôme Duval(
303626bc4beSJérôme Duval	CChannelMask& TstMask
304626bc4beSJérôme Duval)
305626bc4beSJérôme Duval{
306be188ae1SJérôme Duval	if (0 != (m_Mask & TstMask.m_Mask))
307be188ae1SJérôme Duval		return TRUE;
308626bc4beSJérôme Duval
309626bc4beSJérôme Duval	return FALSE;
310626bc4beSJérôme Duval
311626bc4beSJérôme Duval}	// BOOL CChannelMask::IsIntersectionOf
312626bc4beSJérôme Duval
313626bc4beSJérôme Duval
314626bc4beSJérôme Duval//===========================================================================
315626bc4beSJérôme Duval//
316626bc4beSJérôme Duval// Operator == is just what you'd expect - it tells you if one mask is
317626bc4beSJérôme Duval// the same as another
318626bc4beSJérôme Duval//
319626bc4beSJérôme Duval//===========================================================================
320626bc4beSJérôme Duval
321626bc4beSJérôme DuvalBOOLEAN operator == ( CONST CChannelMask &LVal, CONST CChannelMask &RVal )
322626bc4beSJérôme Duval{
323be188ae1SJérôme Duval	if (LVal.m_Mask != RVal.m_Mask)
324be188ae1SJérôme Duval		return FALSE;
325626bc4beSJérôme Duval
326626bc4beSJérôme Duval	return TRUE;
327626bc4beSJérôme Duval
328626bc4beSJérôme Duval}	// BOOLEAN operator == ( CONST CChannelMask &LVal, CONST CChannelMask &RVal )
329626bc4beSJérôme Duval
330626bc4beSJérôme Duval
331626bc4beSJérôme Duval//===========================================================================
332626bc4beSJérôme Duval//
333626bc4beSJérôme Duval// Operator = just copies from one mask to another.
334626bc4beSJérôme Duval//
335626bc4beSJérôme Duval//===========================================================================
336626bc4beSJérôme Duval
337626bc4beSJérôme DuvalCChannelMask& CChannelMask::operator =(CONST CChannelMask & RVal)
338626bc4beSJérôme Duval{
339626bc4beSJérôme Duval	if ( &RVal == this )
340626bc4beSJérôme Duval		return *this;
341626bc4beSJérôme Duval
342be188ae1SJérôme Duval	m_Mask = RVal.m_Mask;
343626bc4beSJérôme Duval
344626bc4beSJérôme Duval	return *this;
345626bc4beSJérôme Duval
346626bc4beSJérôme Duval}	// CChannelMask& CChannelMask::operator = (CONTS CChannelMask & RVal)
347626bc4beSJérôme Duval
348626bc4beSJérôme Duval
349626bc4beSJérôme Duval//===========================================================================
350626bc4beSJérôme Duval//
351626bc4beSJérôme Duval// Operator & performs a bitwise logical AND
352626bc4beSJérôme Duval//
353626bc4beSJérôme Duval//===========================================================================
354626bc4beSJérôme Duval
355626bc4beSJérôme DuvalVOID CChannelMask::operator &= (CONST CChannelMask & RVal)
356626bc4beSJérôme Duval{
357626bc4beSJérôme Duval	if ( &RVal == this )
358626bc4beSJérôme Duval		return;
359626bc4beSJérôme Duval
360be188ae1SJérôme Duval	m_Mask &= RVal.m_Mask;
361626bc4beSJérôme Duval
362626bc4beSJérôme Duval}	// VOID CChannelMask::operator &= (CONST CChannelMask & RVal)
363626bc4beSJérôme Duval
364626bc4beSJérôme Duval
365626bc4beSJérôme Duval//===========================================================================
366626bc4beSJérôme Duval//
367626bc4beSJérôme Duval// Operator & performs a bitwise logical OR
368626bc4beSJérôme Duval//
369626bc4beSJérôme Duval//===========================================================================
370626bc4beSJérôme Duval
371626bc4beSJérôme DuvalVOID CChannelMask::operator |= (CONST CChannelMask & RVal)
372626bc4beSJérôme Duval{
373626bc4beSJérôme Duval	if ( &RVal == this )
374626bc4beSJérôme Duval		return;
375626bc4beSJérôme Duval
376be188ae1SJérôme Duval	m_Mask |= RVal.m_Mask;
377626bc4beSJérôme Duval
378626bc4beSJérôme Duval}	// VOID CChannelMask::operator |= (CONST CChannelMask & RVal)
379626bc4beSJérôme Duval
380626bc4beSJérôme Duval
381626bc4beSJérôme Duval//===========================================================================
382626bc4beSJérôme Duval//
383626bc4beSJérôme Duval// Overload new & delete so memory for this object is allocated
384626bc4beSJérôme Duval//	from non-paged memory.
385626bc4beSJérôme Duval//
386626bc4beSJérôme Duval//===========================================================================
387626bc4beSJérôme Duval
388626bc4beSJérôme DuvalPVOID CChannelMask::operator new( size_t Size )
389626bc4beSJérôme Duval{
390626bc4beSJérôme Duval	PVOID 		pMemory;
391626bc4beSJérôme Duval	ECHOSTATUS 	Status;
392626bc4beSJérôme Duval
393626bc4beSJérôme Duval	Status = OsAllocateNonPaged(Size,&pMemory);
394626bc4beSJérôme Duval
395626bc4beSJérôme Duval	if ( (ECHOSTATUS_OK != Status) || (NULL == pMemory ))
396626bc4beSJérôme Duval	{
397626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("CChannelMask::operator new - memory allocation failed\n"));
398626bc4beSJérôme Duval
399626bc4beSJérôme Duval		pMemory = NULL;
400626bc4beSJérôme Duval	}
401626bc4beSJérôme Duval	else
402626bc4beSJérôme Duval	{
403626bc4beSJérôme Duval		memset( pMemory, 0, Size );
404626bc4beSJérôme Duval	}
405626bc4beSJérôme Duval
406626bc4beSJérôme Duval	return pMemory;
407626bc4beSJérôme Duval
408626bc4beSJérôme Duval}	// PVOID CChannelMask::operator new( size_t Size )
409626bc4beSJérôme Duval
410626bc4beSJérôme Duval
411626bc4beSJérôme DuvalVOID  CChannelMask::operator delete( PVOID pVoid )
412626bc4beSJérôme Duval{
413626bc4beSJérôme Duval	if ( ECHOSTATUS_OK != OsFreeNonPaged( pVoid ) )
414626bc4beSJérôme Duval	{
415626bc4beSJérôme Duval		ECHO_DEBUGPRINTF(("CChannelMask::operator delete memory free failed\n"));
416626bc4beSJérôme Duval	}
417626bc4beSJérôme Duval}	// VOID  CChannelMask::operator delete( PVOID pVoid )
418626bc4beSJérôme Duval
419626bc4beSJérôme Duval
420626bc4beSJérôme Duval
421626bc4beSJérôme Duval
422626bc4beSJérôme Duval/****************************************************************************
423626bc4beSJérôme Duval
424626bc4beSJérôme Duval	CChMaskDsp
425626bc4beSJérôme Duval
426626bc4beSJérôme Duval ****************************************************************************/
427626bc4beSJérôme Duval
428626bc4beSJérôme Duval//===========================================================================
429626bc4beSJérôme Duval//
430626bc4beSJérôme Duval// Constructor
431626bc4beSJérôme Duval//
432626bc4beSJérôme Duval//===========================================================================
433626bc4beSJérôme Duval
434626bc4beSJérôme DuvalCChMaskDsp::CChMaskDsp()
435626bc4beSJérôme Duval{
436626bc4beSJérôme Duval
437626bc4beSJérôme Duval	Clear();
438626bc4beSJérôme Duval
439626bc4beSJérôme Duval}	// CChMaskDsp::CChMaskDsp()
440626bc4beSJérôme Duval
441626bc4beSJérôme Duval
442626bc4beSJérôme Duval//===========================================================================
443626bc4beSJérôme Duval//
444626bc4beSJérôme Duval// IsEmpty returns TRUE if mask has no bits set
445626bc4beSJérôme Duval//
446626bc4beSJérôme Duval//===========================================================================
447626bc4beSJérôme Duval
448626bc4beSJérôme DuvalBOOL CChMaskDsp::IsEmpty()
449626bc4beSJérôme Duval{
4504dd9e436SJérôme Duval	if (0 != m_Mask)
451626bc4beSJérôme Duval			return FALSE;
452626bc4beSJérôme Duval
453626bc4beSJérôme Duval	return TRUE;
454626bc4beSJérôme Duval
455626bc4beSJérôme Duval}	// void CChMaskDsp::IsEmpty()
456626bc4beSJérôme Duval
457626bc4beSJérôme Duval
458626bc4beSJérôme Duval//===========================================================================
459626bc4beSJérôme Duval//
460626bc4beSJérôme Duval// Call SetIndexInMask and ClearIndexInMask to set or clear a single bit.
461626bc4beSJérôme Duval//
462626bc4beSJérôme Duval//===========================================================================
463626bc4beSJérôme Duval
464626bc4beSJérôme Duval// Set driver channel index into DSP mask format
465626bc4beSJérôme Duvalvoid CChMaskDsp::SetIndexInMask( WORD wPipeIndex )
466626bc4beSJérôme Duval{
4674dd9e436SJérôme Duval	CH_MASK_DSP bit,temp;
4684dd9e436SJérôme Duval
4694dd9e436SJérôme Duval	temp = SWAP( m_Mask );
4704dd9e436SJérôme Duval	bit = 1 << wPipeIndex;
4714dd9e436SJérôme Duval	temp |= bit;
4724dd9e436SJérôme Duval	m_Mask = SWAP( temp );
473626bc4beSJérôme Duval
474626bc4beSJérôme Duval}	// void CChMaskDsp::SetIndexInMask( WORD wPipeIndex )
475626bc4beSJérôme Duval
476626bc4beSJérôme Duval
477626bc4beSJérôme Duval// Clear driver channel index into DSP mask format
478626bc4beSJérôme Duvalvoid CChMaskDsp::ClearIndexInMask( WORD wPipeIndex )
479626bc4beSJérôme Duval{
4804dd9e436SJérôme Duval	CH_MASK_DSP bit,temp;
4814dd9e436SJérôme Duval
4824dd9e436SJérôme Duval	temp = SWAP( m_Mask );
4834dd9e436SJérôme Duval	bit = 1 << wPipeIndex;
4844dd9e436SJérôme Duval	temp &= ~bit;
4854dd9e436SJérôme Duval	m_Mask = SWAP( temp );
486626bc4beSJérôme Duval
487626bc4beSJérôme Duval}	// void CChMaskDsp::SetIndexInMask( WORD wPipeIndex )
488626bc4beSJérôme Duval
489626bc4beSJérôme Duval
490626bc4beSJérôme Duval//===========================================================================
491626bc4beSJérôme Duval//
492626bc4beSJérôme Duval// Returns TRUE if the bit specified by the pipe index is set.
493626bc4beSJérôme Duval//
494626bc4beSJérôme Duval//===========================================================================
495626bc4beSJérôme Duval
496626bc4beSJérôme DuvalBOOL CChMaskDsp::TestIndexInMask( WORD wPipeIndex )
497626bc4beSJérôme Duval{
4984dd9e436SJérôme Duval	CH_MASK_DSP temp,bit;
4994dd9e436SJérôme Duval
5004dd9e436SJérôme Duval	temp = SWAP(m_Mask);
5014dd9e436SJérôme Duval	bit = 1 << wPipeIndex;
5024dd9e436SJérôme Duval	if (0 != (temp & bit))
503626bc4beSJérôme Duval		return TRUE;
504626bc4beSJérôme Duval
505626bc4beSJérôme Duval	return FALSE;
506626bc4beSJérôme Duval
507626bc4beSJérôme Duval}	// BOOL CChMaskDsp::TestIndexInMask( WORD wPipeIndex )
508626bc4beSJérôme Duval
509626bc4beSJérôme Duval
510626bc4beSJérôme Duval//===========================================================================
511626bc4beSJérôme Duval//
512626bc4beSJérôme Duval//	Clear all channels in this mask
513626bc4beSJérôme Duval//
514626bc4beSJérôme Duval//===========================================================================
515626bc4beSJérôme Duval
516626bc4beSJérôme Duvalvoid CChMaskDsp::Clear()
517626bc4beSJérôme Duval{
5184dd9e436SJérôme Duval	m_Mask = 0;
519626bc4beSJérôme Duval}	// void CChMaskDsp::Clear()
520