3 * Copyright (c) 2007-2010 SlimDX Group
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 * of this software and associated documentation files (the "Software"), to deal
\r
7 * in the Software without restriction, including without limitation the rights
\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 * copies of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
25 #include "CaptureBufferDescription.h"
\r
27 using namespace SlimDX::Multimedia;
\r
31 namespace DirectSound
\r
33 DSCBUFFERDESC CaptureBufferDescription::ToUnmanaged()
\r
35 DSCBUFFERDESC description;
\r
36 ZeroMemory( &description, sizeof(description) );
\r
37 description.dwSize = sizeof( DSCBUFFERDESC );
\r
38 description.dwBufferBytes = BufferBytes;
\r
39 description.dwFXCount = 0;
\r
40 description.dwFlags = 0;
\r
41 description.dwReserved = 0;
\r
42 description.lpwfxFormat = NULL;
\r
43 description.lpDSCFXDesc = NULL;
\r
45 if( ControlEffects && ( EffectDescriptions != nullptr ) )
\r
47 // Manual Allocation: ugly, but necessary
\r
48 // we are only called by one other method, which performs the clean up
\r
49 description.dwFXCount = EffectDescriptions->Length;
\r
50 LPDSCEFFECTDESC lpDSCFXDesc = new DSCEFFECTDESC[ description.dwFXCount ];
\r
52 for( DWORD i = 0; i < description.dwFXCount; i++ )
\r
53 lpDSCFXDesc[i] = EffectDescriptions[i].Marshal();
\r
55 description.lpDSCFXDesc = lpDSCFXDesc;
\r
58 if( ControlEffects && WaveMapped )
\r
59 description.dwFlags = DSCBCAPS_CTRLFX | DSCBCAPS_WAVEMAPPED;
\r
60 else if( ControlEffects )
\r
61 description.dwFlags = DSCBCAPS_CTRLFX;
\r
62 else if( WaveMapped )
\r
63 description.dwFlags = DSCBCAPS_WAVEMAPPED;
\r
65 if( Format != nullptr )
\r
67 // Manual Allocation: ugly, but necessary
\r
68 // we are only called by one other method, which performs the clean up
\r
69 auto_array<WAVEFORMATEX> format = WaveFormat::ToUnmanaged( Format );
\r
70 description.lpwfxFormat = format.release();
\r
76 bool CaptureBufferDescription::operator == ( CaptureBufferDescription left, CaptureBufferDescription right )
\r
78 return CaptureBufferDescription::Equals( left, right );
\r
81 bool CaptureBufferDescription::operator != ( CaptureBufferDescription left, CaptureBufferDescription right )
\r
83 return !CaptureBufferDescription::Equals( left, right );
\r
86 int CaptureBufferDescription::GetHashCode()
\r
88 return EffectDescriptions->GetHashCode() + Format->GetHashCode() + WaveMapped.GetHashCode() + ControlEffects.GetHashCode() + BufferBytes.GetHashCode();
\r
91 bool CaptureBufferDescription::Equals( Object^ value )
\r
93 if( value == nullptr )
\r
96 if( value->GetType() != GetType() )
\r
99 return Equals( safe_cast<CaptureBufferDescription>( value ) );
\r
102 bool CaptureBufferDescription::Equals( CaptureBufferDescription value )
\r
104 return ( EffectDescriptions == value.EffectDescriptions && Format == value.Format && WaveMapped == value.WaveMapped &&
\r
105 ControlEffects == value.ControlEffects && BufferBytes == value.BufferBytes );
\r
108 bool CaptureBufferDescription::Equals( CaptureBufferDescription% value1, CaptureBufferDescription% value2 )
\r
110 return value1.Equals( value2 );
\r