ReactOS 0.4.16-dev-106-g10b08aa
dsoundrender.c
Go to the documentation of this file.
1/*
2 * Unit tests for DSound Renderer functions
3 *
4 * Copyright (C) 2010 Maarten Lankhorst for CodeWeavers
5 * Copyright (C) 2007 Google (Lei Zhang)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#define COBJMACROS
23
24#include "wine/test.h"
25#include "dshow.h"
26#include "initguid.h"
27#include "dsound.h"
28#include "amaudio.h"
29
30#define QI_SUCCEED(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
31 ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); \
32 ok(ppv != NULL, "Pointer is NULL\n");
33
34#define RELEASE_EXPECT(iface, num) if (iface) { \
35 hr = IUnknown_Release((IUnknown*)iface); \
36 ok(hr == num, "IUnknown_Release should return %d, got %d\n", num, hr); \
37}
38
40
42{
43 HRESULT hr;
44
45 hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER,
47 return (hr == S_OK && pDSRender != NULL);
48}
49
50static void release_dsound_renderer(void)
51{
52 HRESULT hr;
53
54 hr = IUnknown_Release(pDSRender);
55 ok(hr == 0, "IUnknown_Release failed with %x\n", hr);
56}
57
59{
60 ok(0, "Should not be called\n");
61 *ppv = NULL;
62 return E_NOINTERFACE;
63}
64
66{
67 ok(0, "Should not be called\n");
68 return 2;
69}
70
72{
73 ok(0, "Should not be called\n");
74 return 1;
75}
76
78{
79 static const WCHAR dsguid[] = { 'D','S','G','u','i','d', 0 };
80 char temp[50];
81 WideCharToMultiByte(CP_ACP, 0, name, -1, temp, sizeof(temp)-1, NULL, NULL);
82 temp[sizeof(temp)-1] = 0;
83 trace("Trying to read %s, type %u\n", temp, var->n1.n2.vt);
84 if (!lstrcmpW(name, dsguid))
85 {
86 static const WCHAR defaultplayback[] =
87 {
88 '{','D','E','F','0','0','0','0','0','-',
89 '9','C','6','D','-','4','7','E','D','-',
90 'A','A','F','1','-','4','D','D','A','8',
91 'F','2','B','5','C','0','3','}',0
92 };
93 ok(var->n1.n2.vt == VT_BSTR, "Wrong type asked: %u\n", var->n1.n2.vt);
94 var->n1.n2.n3.bstrVal = SysAllocString(defaultplayback);
95 return S_OK;
96 }
97 ok(0, "Unknown property '%s' queried\n", temp);
98 return E_FAIL;
99}
100
101static HRESULT WINAPI PB_Write(IPropertyBag *iface, LPCOLESTR name, VARIANT *var)
102{
103 ok(0, "Should not be called\n");
104 return E_FAIL;
105}
106
107static IPropertyBagVtbl PB_Vtbl =
108{
110 PB_AddRef,
112 PB_Read,
114};
115
116static void test_query_interface(void)
117{
118 HRESULT hr;
119 IBaseFilter *pBaseFilter = NULL;
120 IBasicAudio *pBasicAudio = NULL;
121 IMediaPosition *pMediaPosition = NULL;
122 IMediaSeeking *pMediaSeeking = NULL;
123 IQualityControl *pQualityControl = NULL;
125 IDirectSound3DBuffer *ds3dbuf = NULL;
127 IAMDirectSound *pAMDirectSound = NULL;
128
129 QI_SUCCEED(pDSRender, IID_IBaseFilter, pBaseFilter);
130 RELEASE_EXPECT(pBaseFilter, 1);
131 QI_SUCCEED(pDSRender, IID_IBasicAudio, pBasicAudio);
132 RELEASE_EXPECT(pBasicAudio, 1);
133 QI_SUCCEED(pDSRender, IID_IMediaSeeking, pMediaSeeking);
134 RELEASE_EXPECT(pMediaSeeking, 1);
135 QI_SUCCEED(pDSRender, IID_IReferenceClock, clock);
137 QI_SUCCEED(pDSRender, IID_IAMDirectSound, pAMDirectSound);
138 RELEASE_EXPECT( pAMDirectSound, 1);
139 todo_wine {
140 QI_SUCCEED(pDSRender, IID_IDirectSound3DBuffer, ds3dbuf);
141 RELEASE_EXPECT(ds3dbuf, 1);
143 if (ppb)
144 {
145 IPropertyBag bag = { &PB_Vtbl };
146 hr = IPersistPropertyBag_Load(ppb, &bag, NULL);
147 ok(hr == S_OK, "Couldn't load default device: %08x\n", hr);
148 }
149 RELEASE_EXPECT(ppb, 1);
150 }
151 QI_SUCCEED(pDSRender, IID_IMediaPosition, pMediaPosition);
152 RELEASE_EXPECT(pMediaPosition, 1);
153 QI_SUCCEED(pDSRender, IID_IQualityControl, pQualityControl);
154 RELEASE_EXPECT(pQualityControl, 1);
155}
156
157static void test_pin(IPin *pin)
158{
159 IMemInputPin *mpin = NULL;
160
161 IPin_QueryInterface(pin, &IID_IMemInputPin, (void **)&mpin);
162
163 ok(mpin != NULL, "No IMemInputPin found!\n");
164 if (mpin)
165 {
166 ok(IMemInputPin_ReceiveCanBlock(mpin) == S_OK, "Receive can't block for pin!\n");
167 ok(IMemInputPin_NotifyAllocator(mpin, NULL, 0) == E_POINTER, "NotifyAllocator likes a NULL pointer argument\n");
168 IMemInputPin_Release(mpin);
169 }
170 /* TODO */
171}
172
173static void test_basefilter(void)
174{
175 IEnumPins *pin_enum = NULL;
177 IPin *pins[2];
178 ULONG ref;
179 HRESULT hr;
180
181 IUnknown_QueryInterface(pDSRender, &IID_IBaseFilter, (void **)&base);
182 if (base == NULL)
183 {
184 /* test_query_interface handles this case */
185 skip("No IBaseFilter\n");
186 return;
187 }
188
189 hr = IBaseFilter_EnumPins(base, NULL);
190 ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr);
191
192 hr= IBaseFilter_EnumPins(base, &pin_enum);
193 ok(hr == S_OK, "hr = %08x and not S_OK\n", hr);
194
195 hr = IEnumPins_Next(pin_enum, 1, NULL, NULL);
196 ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr);
197
198 hr = IEnumPins_Next(pin_enum, 2, pins, NULL);
199 ok(hr == E_INVALIDARG, "hr = %08x and not E_INVALIDARG\n", hr);
200
201 pins[0] = (void *)0xdead;
202 pins[1] = (void *)0xdeed;
203
204 hr = IEnumPins_Next(pin_enum, 2, pins, &ref);
205 ok(hr == S_FALSE, "hr = %08x instead of S_FALSE\n", hr);
206 ok(pins[0] != (void *)0xdead && pins[0] != NULL, "pins[0] = %p\n", pins[0]);
207 if (pins[0] != (void *)0xdead && pins[0] != NULL)
208 {
209 test_pin(pins[0]);
210 IPin_Release(pins[0]);
211 }
212
213 ok(pins[1] == (void *)0xdeed, "pins[1] = %p\n", pins[1]);
214
215 ref = IEnumPins_Release(pin_enum);
216 ok(ref == 0, "ref is %u and not 0!\n", ref);
217
218 IBaseFilter_Release(base);
219}
220
221START_TEST(dsoundrender)
222{
225 return;
226
229
231
233}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
const GUID IID_IUnknown
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
const GUID IID_IBaseFilter
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
@ VT_BSTR
Definition: compat.h:2303
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
unsigned int BOOL
Definition: ntddk_ex.h:94
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
Definition: axcore.idl:92
#define S_OK
Definition: intsafe.h:52
const char * var
Definition: shader.c:5666
#define todo_wine
Definition: custom.c:89
static HRESULT WINAPI PB_Write(IPropertyBag *iface, LPCOLESTR name, VARIANT *var)
Definition: dsoundrender.c:101
static IUnknown * pDSRender
Definition: dsoundrender.c:39
static BOOL create_dsound_renderer(void)
Definition: dsoundrender.c:41
#define RELEASE_EXPECT(iface, num)
Definition: dsoundrender.c:34
static IPropertyBagVtbl PB_Vtbl
Definition: dsoundrender.c:107
static void release_dsound_renderer(void)
Definition: dsoundrender.c:50
static void test_pin(IPin *pin)
Definition: dsoundrender.c:157
static ULONG WINAPI PB_AddRef(IPropertyBag *iface)
Definition: dsoundrender.c:65
static void test_query_interface(void)
Definition: dsoundrender.c:116
static HRESULT WINAPI PB_Read(IPropertyBag *iface, LPCOLESTR name, VARIANT *var, IErrorLog *log)
Definition: dsoundrender.c:77
#define QI_SUCCEED(iface, riid, ppv)
Definition: dsoundrender.c:30
static HRESULT WINAPI PB_QueryInterface(IPropertyBag *iface, REFIID riid, void **ppv)
Definition: dsoundrender.c:58
static ULONG WINAPI PB_Release(IPropertyBag *iface)
Definition: dsoundrender.c:71
static void test_basefilter(void)
Definition: dsoundrender.c:173
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
const GUID IID_IPersistPropertyBag
Definition: proxy.cpp:11
#define REFIID
Definition: guiddef.h:118
static calc_node_t temp
Definition: rpn_ieee.c:38
_Check_return_ _CRTIMP clock_t __cdecl clock(void)
Definition: clock.c:23
#define log(outFile, fmt,...)
Definition: util.h:15
HRESULT hr
Definition: shlfolder.c:183
Definition: name.c:39
Definition: regsvr.c:104
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180