OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / SlimDXc_Jun2010(VC++2008) / source / directsound / CaptureBufferDescription.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\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
11\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
14\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
21 * THE SOFTWARE.\r
22 */\r
23 #include <dsound.h>\r
24 \r
25 #include "CaptureBufferDescription.h"\r
26 \r
27 using namespace SlimDX::Multimedia;\r
28 \r
29 namespace SlimDX\r
30 {\r
31 namespace DirectSound\r
32 {\r
33         DSCBUFFERDESC CaptureBufferDescription::ToUnmanaged()\r
34         {\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
44 \r
45                 if( ControlEffects && ( EffectDescriptions != nullptr ) )\r
46                 {\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
51 \r
52                         for( DWORD i = 0; i < description.dwFXCount; i++ )\r
53                                 lpDSCFXDesc[i] = EffectDescriptions[i].Marshal();\r
54 \r
55                         description.lpDSCFXDesc = lpDSCFXDesc;\r
56                 }\r
57 \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
64 \r
65                 if( Format != nullptr )\r
66                 {\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
71                 }\r
72 \r
73                 return description;\r
74         }\r
75 \r
76         bool CaptureBufferDescription::operator == ( CaptureBufferDescription left, CaptureBufferDescription right )\r
77         {\r
78                 return CaptureBufferDescription::Equals( left, right );\r
79         }\r
80 \r
81         bool CaptureBufferDescription::operator != ( CaptureBufferDescription left, CaptureBufferDescription right )\r
82         {\r
83                 return !CaptureBufferDescription::Equals( left, right );\r
84         }\r
85 \r
86         int CaptureBufferDescription::GetHashCode()\r
87         {\r
88                 return EffectDescriptions->GetHashCode() + Format->GetHashCode() + WaveMapped.GetHashCode() + ControlEffects.GetHashCode() + BufferBytes.GetHashCode();\r
89         }\r
90 \r
91         bool CaptureBufferDescription::Equals( Object^ value )\r
92         {\r
93                 if( value == nullptr )\r
94                         return false;\r
95 \r
96                 if( value->GetType() != GetType() )\r
97                         return false;\r
98 \r
99                 return Equals( safe_cast<CaptureBufferDescription>( value ) );\r
100         }\r
101 \r
102         bool CaptureBufferDescription::Equals( CaptureBufferDescription value )\r
103         {\r
104                 return ( EffectDescriptions == value.EffectDescriptions && Format == value.Format && WaveMapped == value.WaveMapped && \r
105                         ControlEffects == value.ControlEffects && BufferBytes == value.BufferBytes );\r
106         }\r
107 \r
108         bool CaptureBufferDescription::Equals( CaptureBufferDescription% value1, CaptureBufferDescription% value2 )\r
109         {\r
110                 return value1.Equals( value2 );\r
111         }\r
112 }\r
113 }