~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/dsound/tests/duplex.c

Version: ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Unit tests for duplex functions
  3  *
  4  * Copyright (c) 2006 Robert Reif
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include <windows.h>
 22 
 23 #include <stdio.h>
 24 
 25 #include "wine/test.h"
 26 #include "dsound.h"
 27 #include "mmreg.h"
 28 #include "dsconf.h"
 29 
 30 #include "dsound_test.h"
 31 
 32 static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID, LPCGUID,
 33     LPCDSCBUFFERDESC, LPCDSBUFFERDESC, HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *,
 34     LPDIRECTSOUNDCAPTUREBUFFER8*, LPDIRECTSOUNDBUFFER8*, LPUNKNOWN)=NULL;
 35 
 36 static void IDirectSoundFullDuplex_test(LPDIRECTSOUNDFULLDUPLEX dsfdo,
 37                                         BOOL initialized, LPCGUID lpGuidCapture,
 38                                         LPCGUID lpGuidRender)
 39 {
 40     HRESULT rc;
 41     int ref;
 42     IUnknown * unknown;
 43     IDirectSound * ds;
 44     IDirectSound8 * ds8;
 45     IDirectSoundCapture * dsc;
 46     IDirectSoundFullDuplex * dsfd;
 47 
 48     /* Try to Query for objects */
 49     rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IUnknown,(LPVOID*)&unknown);
 50     ok(rc==DS_OK,"IDirectSoundFullDuplex_QueryInterface(IID_IUnknown) failed: %08x\n", rc);
 51     if (rc==DS_OK) {
 52         ref=IDirectSoundFullDuplex_Release(unknown);
 53         ok(ref==0, "IDirectSoundFullDuplex_Release() has %d references, "
 54            "should have 0\n", ref);
 55     }
 56 
 57     rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSound,(LPVOID*)&ds);
 58     ok(rc==(initialized?DS_OK:E_NOINTERFACE),"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSound) failed: %08x\n", rc);
 59     if (rc==DS_OK) {
 60         ref=IDirectSound_Release(ds);
 61         ok(ref==0, "IDirectSound_Release() has %d references, "
 62            "should have 0\n", ref);
 63     }
 64 
 65     rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSound8,(LPVOID*)&ds8);
 66     ok(rc==(initialized?DS_OK:E_NOINTERFACE),"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSound8) "
 67        "failed: %08x\n",rc);
 68     if (rc==DS_OK) {
 69         IDirectSoundFullDuplex * dsfd1;
 70         rc=IDirectSound8_QueryInterface(ds8,&IID_IDirectSoundFullDuplex,(LPVOID*)&dsfd1);
 71         ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSoundFullDuplex) "
 72            "failed: %08x\n",rc);
 73         if (rc==DS_OK) {
 74             ref=IDirectSoundFullDuplex_Release(dsfd1);
 75             ok(ref==1, "IDirectSoundFullDuplex_Release() has %d references, "
 76                "should have 1\n", ref);
 77         }
 78         ref=IDirectSound8_Release(ds8);
 79         ok(ref==0, "IDirectSound8_Release() has %d references, "
 80            "should have 0\n", ref);
 81     }
 82 
 83     rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSoundCapture,(LPVOID*)&dsc);
 84     ok(rc==(initialized?DS_OK:E_NOINTERFACE),"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSoundCapture) "
 85        "failed: %08x\n",rc);
 86     if (rc==DS_OK) {
 87         ref=IDirectSoundCapture_Release(dsc);
 88         ok(ref==0, "IDirectSoundCapture_Release() has %d references, "
 89            "should have 0\n", ref);
 90     }
 91 
 92     rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSoundFullDuplex,(LPVOID*)&dsfd);
 93     ok(rc==DS_OK,"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSoundFullDuplex) "
 94        "failed: %08x\n",rc);
 95     if (rc==DS_OK) {
 96         ok (dsfdo==dsfd, "different interfaces\n");
 97         ref=IDirectSound8_Release(dsfd);
 98     }
 99 
100     ref=IDirectSoundFullDuplex_Release(dsfdo);
101     ok(ref==0, "IDirectSoundFullDuplex_Release() has %d references, "
102        "should have 0\n", ref);
103 }
104 
105 static void IDirectSoundFullDuplex_tests(void)
106 {
107     HRESULT rc;
108     LPDIRECTSOUNDFULLDUPLEX dsfdo = NULL;
109     DSCBUFFERDESC DSCBufferDesc;
110     DSBUFFERDESC DSBufferDesc;
111     LPDIRECTSOUNDCAPTUREBUFFER8 pDSCBuffer8;
112     LPDIRECTSOUNDBUFFER8 pDSBuffer8;
113     WAVEFORMATEX wfex;
114 
115     trace("Testing IDirectSoundFullDuplex\n");
116 
117     /* try the COM class factory method of creation with no devices specified */
118     rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
119                         CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex,
120                         (void**)&dsfdo);
121     ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG||rc==CLASS_E_CLASSNOTAVAILABLE,
122        "CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc);
123     if (rc==REGDB_E_CLASSNOTREG) {
124         trace("  Class Not Registered\n");
125         return;
126     } else if (rc==CLASS_E_CLASSNOTAVAILABLE) {
127         trace("  Class Not Available\n");
128         return;
129     }
130     if (dsfdo)
131         IDirectSoundFullDuplex_test(dsfdo, FALSE, NULL, NULL);
132 
133     /* try the COM class factory method of creation with default devices
134      * specified */
135     rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
136                         CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex,
137                         (void**)&dsfdo);
138     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc);
139     if (dsfdo)
140         IDirectSoundFullDuplex_test(dsfdo, FALSE, &DSDEVID_DefaultCapture,
141                                     &DSDEVID_DefaultPlayback);
142 
143     /* try the COM class factory method of creation with default voice
144      * devices specified */
145     rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
146                         CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex,
147                         (void**)&dsfdo);
148     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc);
149     if (dsfdo)
150         IDirectSoundFullDuplex_test(dsfdo, FALSE, &DSDEVID_DefaultVoiceCapture,
151                                     &DSDEVID_DefaultVoicePlayback);
152 
153     /* try the COM class factory method of creation with a bad
154      * IID specified */
155     rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
156                         CLSCTX_INPROC_SERVER, &CLSID_DirectSoundPrivate,
157                         (void**)&dsfdo);
158     ok(rc==E_NOINTERFACE,
159        "CoCreateInstance(CLSID_DirectSoundFullDuplex,CLSID_DirectSoundPrivate) "
160        "should have failed: 0x%08x\n", rc);
161 
162     ZeroMemory(&wfex, sizeof(wfex));
163     wfex.wFormatTag = WAVE_FORMAT_PCM;
164     wfex.nChannels = 1;
165     wfex.nSamplesPerSec = 8000;
166     wfex.wBitsPerSample = 16;
167     wfex.nBlockAlign = (wfex.wBitsPerSample * wfex.nChannels) / 8;
168     wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;
169 
170     ZeroMemory(&DSCBufferDesc, sizeof(DSCBufferDesc));
171     DSCBufferDesc.dwSize = sizeof(DSCBufferDesc);
172     DSCBufferDesc.dwFlags = DSCBCAPS_WAVEMAPPED;
173     DSCBufferDesc.dwBufferBytes = 8192;
174     DSCBufferDesc.lpwfxFormat = &wfex;
175 
176     ZeroMemory(&DSBufferDesc, sizeof(DSBufferDesc));
177     DSBufferDesc.dwSize = sizeof(DSBufferDesc);
178     DSBufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS;
179     DSBufferDesc.dwBufferBytes = 8192;
180     DSBufferDesc.lpwfxFormat = &wfex;
181 
182     /* try with no device specified */
183     rc=pDirectSoundFullDuplexCreate(NULL,NULL,&DSCBufferDesc,&DSBufferDesc,
184                                     get_hwnd(),DSSCL_EXCLUSIVE ,&dsfdo,&pDSCBuffer8,
185                                     &pDSBuffer8,NULL);
186     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL,
187        "DirectSoundFullDuplexCreate(NULL,NULL) failed: %08x\n",rc);
188     if (rc==S_OK && dsfdo)
189         IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL);
190 
191     /* try with default devices specified */
192     rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultCapture,
193                                     &DSDEVID_DefaultPlayback,&DSCBufferDesc,
194                                     &DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE,&dsfdo,
195                                     &pDSCBuffer8,&pDSBuffer8,NULL);
196     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL,
197        "DirectSoundFullDuplexCreate(DSDEVID_DefaultCapture,"
198        "DSDEVID_DefaultPlayback) failed: %08x\n", rc);
199     if (rc==DS_OK && dsfdo)
200         IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL);
201 
202     /* try with default voice devices specified */
203     rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultVoiceCapture,
204                                     &DSDEVID_DefaultVoicePlayback,
205                                     &DSCBufferDesc,&DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE,
206                                     &dsfdo,&pDSCBuffer8,&pDSBuffer8,NULL);
207     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL,
208        "DirectSoundFullDuplexCreate(DSDEVID_DefaultVoiceCapture,"
209        "DSDEVID_DefaultVoicePlayback) failed: %08x\n", rc);
210     if (rc==DS_OK && dsfdo)
211         IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL);
212 
213     /* try with bad devices specified */
214     rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultVoicePlayback,
215                                     &DSDEVID_DefaultVoiceCapture,
216                                     &DSCBufferDesc,&DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE,
217                                     &dsfdo,&pDSCBuffer8,&pDSBuffer8,NULL);
218     ok(rc==DSERR_NODRIVER||rc==DSERR_INVALIDCALL,
219        "DirectSoundFullDuplexCreate(DSDEVID_DefaultVoicePlayback,"
220        "DSDEVID_DefaultVoiceCapture) should have failed: %08x\n", rc);
221     if (rc==DS_OK && dsfdo)
222         IDirectSoundFullDuplex_Release(dsfdo);
223 }
224 
225 START_TEST(duplex)
226 {
227     HMODULE hDsound;
228 
229     CoInitialize(NULL);
230 
231     hDsound = LoadLibrary("dsound.dll");
232     if (hDsound)
233     {
234         trace("DLL Version: %s\n", get_file_version("dsound.dll"));
235 
236         pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
237             "DirectSoundFullDuplexCreate");
238         if (pDirectSoundFullDuplexCreate)
239             IDirectSoundFullDuplex_tests();
240         else
241             skip("duplex test skipped\n");
242 
243         FreeLibrary(hDsound);
244     }
245     else
246         skip("dsound.dll not found!\n");
247 
248     CoUninitialize();
249 }
250 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.