sync with trunk r46493
[reactos.git] / dll / directx / bdaplgin / frequencyfilter.cpp
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS BDA Proxy
4 * FILE: dll/directx/bdaplgin/frequencyfilter.cpp
5 * PURPOSE: IBDA_FrequencyFilter interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
8 */
9
10 #include "precomp.h"
11
12 #ifndef _MSC_VER
13 const GUID IID_IBDA_FrequencyFilter = {0x71985f47, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x00, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
14 const GUID KSPROPSETID_BdaFrequencyFilter = {0x71985f47, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
15 #endif
16
17 class CBDAFrequencyFilter : public IBDA_FrequencyFilter
18 {
19 public:
20 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
21
22 STDMETHODIMP_(ULONG) AddRef()
23 {
24 InterlockedIncrement(&m_Ref);
25 return m_Ref;
26 }
27 STDMETHODIMP_(ULONG) Release()
28 {
29 InterlockedDecrement(&m_Ref);
30 if (!m_Ref)
31 {
32 delete this;
33 return 0;
34 }
35 return m_Ref;
36 }
37
38 HRESULT STDMETHODCALLTYPE put_Autotune(ULONG ulTransponder);
39 HRESULT STDMETHODCALLTYPE get_Autotune(ULONG *pulTransponder);
40 HRESULT STDMETHODCALLTYPE put_Frequency(ULONG ulFrequency);
41 HRESULT STDMETHODCALLTYPE get_Frequency(ULONG *pulFrequency);
42 HRESULT STDMETHODCALLTYPE put_Polarity(Polarisation Polarity);
43 HRESULT STDMETHODCALLTYPE get_Polarity(Polarisation *pPolarity);
44 HRESULT STDMETHODCALLTYPE put_Range(ULONG ulRange);
45 HRESULT STDMETHODCALLTYPE get_Range(ULONG *pulRange);
46 HRESULT STDMETHODCALLTYPE put_Bandwidth(ULONG ulBandwidth);
47 HRESULT STDMETHODCALLTYPE get_Bandwidth(ULONG *pulBandwidth);
48 HRESULT STDMETHODCALLTYPE put_FrequencyMultiplier(ULONG ulMultiplier);
49 HRESULT STDMETHODCALLTYPE get_FrequencyMultiplier(ULONG *pulMultiplier);
50
51 CBDAFrequencyFilter(IKsPropertySet * pProperty, ULONG NodeId) : m_Ref(0), m_pProperty(pProperty), m_NodeId(NodeId){};
52 virtual ~CBDAFrequencyFilter(){};
53
54 protected:
55 LONG m_Ref;
56 IKsPropertySet * m_pProperty;
57 ULONG m_NodeId;
58 };
59
60 HRESULT
61 STDMETHODCALLTYPE
62 CBDAFrequencyFilter::QueryInterface(
63 IN REFIID refiid,
64 OUT PVOID* Output)
65 {
66 *Output = NULL;
67
68 if (IsEqualGUID(refiid, IID_IUnknown))
69 {
70 *Output = PVOID(this);
71 reinterpret_cast<IUnknown*>(*Output)->AddRef();
72 return NOERROR;
73 }
74
75 if (IsEqualGUID(refiid, IID_IBDA_FrequencyFilter))
76 {
77 *Output = (IBDA_FrequencyFilter*)(this);
78 reinterpret_cast<IBDA_FrequencyFilter*>(*Output)->AddRef();
79 return NOERROR;
80 }
81
82 #ifdef BDAPLGIN_TRACE
83 WCHAR Buffer[MAX_PATH];
84 LPOLESTR lpstr;
85 StringFromCLSID(refiid, &lpstr);
86 swprintf(Buffer, L"CControlNode::QueryInterface: NoInterface for %s", lpstr);
87 OutputDebugStringW(Buffer);
88 CoTaskMemFree(lpstr);
89 DebugBreak();
90 #endif
91
92 return E_NOINTERFACE;
93 }
94
95 HRESULT
96 STDMETHODCALLTYPE
97 CBDAFrequencyFilter::put_Autotune(ULONG ulTransponder)
98 {
99 return E_NOINTERFACE;
100 }
101
102 HRESULT
103 STDMETHODCALLTYPE
104 CBDAFrequencyFilter::get_Autotune(ULONG *pulTransponder)
105 {
106 return E_NOINTERFACE;
107 }
108
109 HRESULT
110 STDMETHODCALLTYPE
111 CBDAFrequencyFilter::put_Frequency(ULONG ulFrequency)
112 {
113 KSP_NODE Node;
114 HRESULT hr;
115
116 // setup request
117 Node.NodeId = m_NodeId;
118 Node.Reserved = 0;
119
120 // perform request
121 hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_FREQUENCY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulFrequency, sizeof(ULONG));
122
123 #ifdef BDAPLGIN_TRACE
124 WCHAR Buffer[100];
125 swprintf(Buffer, L"CBDAFrequencyFilter::put_Frequency: m_NodeId %lu ulFrequency %lu hr %lx\n", m_NodeId, ulFrequency, hr);
126 OutputDebugStringW(Buffer);
127 #endif
128
129 return hr;
130 }
131
132 HRESULT
133 STDMETHODCALLTYPE
134 CBDAFrequencyFilter::get_Frequency(ULONG *pulFrequency)
135 {
136 return E_NOINTERFACE;
137 }
138
139 HRESULT
140 STDMETHODCALLTYPE
141 CBDAFrequencyFilter::put_Polarity(Polarisation Polarity)
142 {
143 KSP_NODE Node;
144 HRESULT hr;
145
146 // setup request
147 Node.NodeId = m_NodeId;
148 Node.Reserved = 0;
149
150 // perform request
151 hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_POLARITY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &Polarity, sizeof(Polarisation));
152
153 #ifdef BDAPLGIN_TRACE
154 WCHAR Buffer[100];
155 swprintf(Buffer, L"CBDAFrequencyFilter::put_Polarity: m_NodeId %lu Polarity %lu hr %lx\n", m_NodeId, Polarity, hr);
156 OutputDebugStringW(Buffer);
157 #endif
158
159 return hr;
160 }
161
162 HRESULT
163 STDMETHODCALLTYPE
164 CBDAFrequencyFilter::get_Polarity(Polarisation *pPolarity)
165 {
166 return E_NOINTERFACE;
167 }
168
169 HRESULT
170 STDMETHODCALLTYPE
171 CBDAFrequencyFilter::put_Range(ULONG ulRange)
172 {
173 KSP_NODE Node;
174 HRESULT hr;
175
176 // setup request
177 Node.NodeId = m_NodeId;
178 Node.Reserved = 0;
179
180 // perform request
181 hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_RANGE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulRange, sizeof(ULONG));
182
183 #ifdef BDAPLGIN_TRACE
184 WCHAR Buffer[100];
185 swprintf(Buffer, L"CBDAFrequencyFilter::put_Range: m_NodeId %lu ulRange %lu hr %lx\n", m_NodeId, ulRange, hr);
186 OutputDebugStringW(Buffer);
187 #endif
188
189 return hr;
190 }
191
192 HRESULT
193 STDMETHODCALLTYPE
194 CBDAFrequencyFilter::get_Range(ULONG *pulRange)
195 {
196 return E_NOINTERFACE;
197 }
198
199 HRESULT
200 STDMETHODCALLTYPE
201 CBDAFrequencyFilter::put_Bandwidth(ULONG ulBandwidth)
202 {
203 KSP_NODE Node;
204 HRESULT hr;
205
206 // setup request
207 Node.NodeId = m_NodeId;
208 Node.Reserved = 0;
209
210 // perform request
211 hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_BANDWIDTH, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulBandwidth, sizeof(ULONG));
212
213 #ifdef BDAPLGIN_TRACE
214 WCHAR Buffer[100];
215 swprintf(Buffer, L"CBDAFrequencyFilter::put_Bandwidth: m_NodeId %lu ulBandwidth %lu hr %lx\n", m_NodeId, ulBandwidth, hr);
216 OutputDebugStringW(Buffer);
217 #endif
218
219 return hr;
220 }
221
222 HRESULT
223 STDMETHODCALLTYPE
224 CBDAFrequencyFilter::get_Bandwidth(ULONG *pulBandwidth)
225 {
226 return E_NOINTERFACE;
227 }
228 HRESULT
229 STDMETHODCALLTYPE
230 CBDAFrequencyFilter::put_FrequencyMultiplier(ULONG ulMultiplier)
231 {
232 KSP_NODE Node;
233 HRESULT hr;
234
235 // setup request
236 Node.NodeId = m_NodeId;
237 Node.Reserved = 0;
238
239 // perform request
240 hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulMultiplier, sizeof(ULONG));
241
242 #ifdef BDAPLGIN_TRACE
243 WCHAR Buffer[100];
244 swprintf(Buffer, L"CBDAFrequencyFilter::put_FrequencyMultiplier: m_NodeId %lu ulMultiplier %lu hr %lx\n", m_NodeId, ulMultiplier, hr);
245 OutputDebugStringW(Buffer);
246 #endif
247
248 return hr;
249 }
250
251 HRESULT
252 STDMETHODCALLTYPE
253 CBDAFrequencyFilter::get_FrequencyMultiplier(ULONG *pulMultiplier)
254 {
255 return E_NOINTERFACE;
256 }
257
258 HRESULT
259 WINAPI
260 CBDAFrequencyFilter_fnConstructor(
261 IKsPropertySet* pProperty,
262 ULONG NodeId,
263 REFIID riid,
264 LPVOID * ppv)
265 {
266 // construct device control
267 CBDAFrequencyFilter * handler = new CBDAFrequencyFilter(pProperty, NodeId);
268
269 #ifdef BDAPLGIN_TRACE
270 OutputDebugStringW(L"CBDAFrequencyFilter_fnConstructor\n");
271 #endif
272
273 if (!handler)
274 return E_OUTOFMEMORY;
275
276 if (FAILED(handler->QueryInterface(riid, ppv)))
277 {
278 /* not supported */
279 delete handler;
280 return E_NOINTERFACE;
281 }
282
283 return NOERROR;
284 }