ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2013
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
16 participants
554 discussions
Start a n
N
ew thread
[akhaldi] 60476: [MMDEVAPI] * Import from Wine 1.7.1. Dedicated to Johannes Anderwald. CORE-7469
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 30 13:32:32 2013 New Revision: 60476 URL:
http://svn.reactos.org/svn/reactos?rev=60476&view=rev
Log: [MMDEVAPI] * Import from Wine 1.7.1. Dedicated to Johannes Anderwald. CORE-7469 Added: trunk/reactos/dll/win32/mmdevapi/ trunk/reactos/dll/win32/mmdevapi/CMakeLists.txt (with props) trunk/reactos/dll/win32/mmdevapi/audiovolume.c (with props) trunk/reactos/dll/win32/mmdevapi/devenum.c (with props) trunk/reactos/dll/win32/mmdevapi/main.c (with props) trunk/reactos/dll/win32/mmdevapi/mmdevapi.h (with props) trunk/reactos/dll/win32/mmdevapi/mmdevapi.rc (with props) trunk/reactos/dll/win32/mmdevapi/mmdevapi.spec (with props) trunk/reactos/dll/win32/mmdevapi/mmdevapi_classes.idl (with props) trunk/reactos/dll/win32/mmdevapi/mmdevapi_classes.rgs (with props) trunk/reactos/include/psdk/audiopolicy.idl (with props) trunk/reactos/include/psdk/devicetopology.idl (with props) trunk/reactos/include/psdk/endpointvolume.idl (with props) Modified: trunk/reactos/dll/win32/CMakeLists.txt trunk/reactos/include/psdk/CMakeLists.txt trunk/reactos/include/psdk/devpropdef.h trunk/reactos/include/psdk/ksmedia.h trunk/reactos/lib/sdk/uuid/otherguids.c trunk/reactos/media/doc/README.WINE trunk/reactos/media/inf/syssetup.inf [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/dll/win32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/CMakeLists.txt?r…
Added: trunk/reactos/dll/win32/mmdevapi/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/CMakeLi…
Added: trunk/reactos/dll/win32/mmdevapi/audiovolume.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/audiovo…
Added: trunk/reactos/dll/win32/mmdevapi/devenum.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/devenum…
Added: trunk/reactos/dll/win32/mmdevapi/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/main.c?…
Added: trunk/reactos/dll/win32/mmdevapi/mmdevapi.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/mmdevap…
Added: trunk/reactos/dll/win32/mmdevapi/mmdevapi.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/mmdevap…
Added: trunk/reactos/dll/win32/mmdevapi/mmdevapi.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/mmdevap…
Added: trunk/reactos/dll/win32/mmdevapi/mmdevapi_classes.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/mmdevap…
Added: trunk/reactos/dll/win32/mmdevapi/mmdevapi_classes.rgs URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mmdevapi/mmdevap…
Modified: trunk/reactos/include/psdk/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/CMakeLists.tx…
Added: trunk/reactos/include/psdk/audiopolicy.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/audiopolicy.i…
Added: trunk/reactos/include/psdk/devicetopology.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/devicetopolog…
Modified: trunk/reactos/include/psdk/devpropdef.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/devpropdef.h?…
Added: trunk/reactos/include/psdk/endpointvolume.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/endpointvolum…
Modified: trunk/reactos/include/psdk/ksmedia.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ksmedia.h?rev…
Modified: trunk/reactos/lib/sdk/uuid/otherguids.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/uuid/otherguids.c?…
Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
Modified: trunk/reactos/media/inf/syssetup.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/inf/syssetup.inf?rev…
11 years, 2 months
1
0
0
0
[akhaldi] 60475: [DSOUND_WINETEST] * Sync with Wine 1.7.1. CORE-7469
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 30 11:39:02 2013 New Revision: 60475 URL:
http://svn.reactos.org/svn/reactos?rev=60475&view=rev
Log: [DSOUND_WINETEST] * Sync with Wine 1.7.1. CORE-7469 Modified: trunk/rostests/winetests/dsound/CMakeLists.txt trunk/rostests/winetests/dsound/capture.c trunk/rostests/winetests/dsound/ds3d.c trunk/rostests/winetests/dsound/ds3d8.c trunk/rostests/winetests/dsound/dsound.c trunk/rostests/winetests/dsound/dsound8.c trunk/rostests/winetests/dsound/dsound_test.h trunk/rostests/winetests/dsound/duplex.c trunk/rostests/winetests/dsound/propset.c trunk/rostests/winetests/dsound/testlist.c Modified: trunk/rostests/winetests/dsound/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/CMakeLis…
============================================================================== --- trunk/rostests/winetests/dsound/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/CMakeLists.txt [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -1,7 +1,3 @@ - -add_definitions( - -D__ROS_LONG64__ - -D_DLL -D__USE_CRTIMP) list(APPEND SOURCE capture.c @@ -14,7 +10,7 @@ testlist.c) add_executable(dsound_winetest ${SOURCE}) -target_link_libraries(dsound_winetest wine uuid dxguid) +target_link_libraries(dsound_winetest uuid dxguid) set_module_type(dsound_winetest win32cui) -add_importlibs(dsound_winetest dsound ole32 user32 msvcrt kernel32 ntdll) +add_importlibs(dsound_winetest ole32 user32 msvcrt kernel32) add_cd_file(TARGET dsound_winetest DESTINATION reactos/bin FOR all) Modified: trunk/rostests/winetests/dsound/capture.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/capture.…
============================================================================== --- trunk/rostests/winetests/dsound/capture.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/capture.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -19,13 +19,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H +#define COBJMACROS + +#include <wine/test.h> + #include <stdio.h> -#include "initguid.h" -#include "windows.h" -#include "wine/test.h" -#include "dsound.h" -#include "mmreg.h" -#include "dsconf.h" +//#include "initguid.h" +//#include "windows.h" +#include <wingdi.h> +#include <mmsystem.h> +#include <dsound.h> +#include <mmreg.h> +#include <dsconf.h> #include "dsound_test.h" @@ -177,7 +185,7 @@ "should have 0\n", ref); } -static void IDirectSoundCapture_tests(void) +static void test_capture(void) { HRESULT rc; LPDIRECTSOUNDCAPTURE dsco=NULL; @@ -379,8 +387,6 @@ (void **)&(state.notify)); ok((rc==DS_OK)&&(state.notify!=NULL), "IDirectSoundCaptureBuffer_QueryInterface() failed: %08x\n", rc); - if (rc!=DS_OK) - return; for (i = 0; i < NOTIFICATIONS; i++) { state.posnotify[i].dwOffset = (i * state.size) + state.size - 1; @@ -390,28 +396,23 @@ rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS, state.posnotify); ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed: %08x\n", rc); - if (rc!=DS_OK) - return; ref=IDirectSoundNotify_Release(state.notify); ok(ref==0,"IDirectSoundNotify_Release(): has %d references, should have " "0\n",ref); - if (ref!=0) - return; + + rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc); + + rc=IDirectSoundCaptureBuffer_Start(dscbo,0); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc); + + rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc); + ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING) || broken(status==DSCBSTATUS_CAPTURING), + "GetStatus: bad status: %x\n",status); if (record) { - rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING); - ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc); - if (rc!=DS_OK) - return; - - rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status); - ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc); - ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING), - "GetStatus: bad status: %x\n",status); - if (rc!=DS_OK) - return; - /* wait for the notifications */ for (i = 0; i < (NOTIFICATIONS * 2); i++) { rc=WaitForMultipleObjects(NOTIFICATIONS,state.event,FALSE,3000); @@ -426,11 +427,12 @@ break; } - rc=IDirectSoundCaptureBuffer_Stop(dscbo); - ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc); - if (rc!=DS_OK) - return; - } + } + rc=IDirectSoundCaptureBuffer_Stop(dscbo); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc); + + rc=IDirectSoundCaptureBuffer_Stop(dscbo); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc); } static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, @@ -671,13 +673,93 @@ return TRUE; } -static void capture_tests(void) +static void test_enumerate(void) { HRESULT rc; rc=pDirectSoundCaptureEnumerateA(&dscenum_callback,NULL); ok(rc==DS_OK,"DirectSoundCaptureEnumerateA() failed: %08x\n", rc); } +static void test_COM(void) +{ + IDirectSoundCapture *dsc = (IDirectSoundCapture*)0xdeadbeef; + IDirectSoundCaptureBuffer *buffer = (IDirectSoundCaptureBuffer*)0xdeadbeef; + IDirectSoundNotify *notify; + IUnknown *unk; + DSCBUFFERDESC bufdesc; + WAVEFORMATEX wfx; + HRESULT hr; + ULONG refcount; + + hr = pDirectSoundCaptureCreate(NULL, &dsc, (IUnknown*)0xdeadbeef); + ok(hr == DSERR_NOAGGREGATION, + "DirectSoundCaptureCreate failed: %08x, expected DSERR_NOAGGREGATION\n", hr); + ok(dsc == (IDirectSoundCapture*)0xdeadbeef, "dsc = %p\n", dsc); + + hr = pDirectSoundCaptureCreate(NULL, &dsc, NULL); + if (hr == DSERR_NODRIVER) { + skip("No driver\n"); + return; + } + ok(hr == DS_OK, "DirectSoundCaptureCreate failed: %08x, expected DS_OK\n", hr); + + /* Different refcount for IDirectSoundCapture and for IUnknown */ + refcount = IDirectSoundCapture_AddRef(dsc); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + hr = IDirectSoundCapture_QueryInterface(dsc, &IID_IUnknown, (void**)&unk); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + refcount = IUnknown_AddRef(unk); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + IUnknown_Release(unk); + IUnknown_Release(unk); + IDirectSoundCapture_Release(dsc); + + init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1); + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize = sizeof(bufdesc); + bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; + bufdesc.lpwfxFormat = &wfx; + + hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, (IUnknown*)0xdeadbeef); + if (hr == E_INVALIDARG) { + /* Old DirectX has only the 1st version of the DSCBUFFERDESC struct */ + bufdesc.dwSize = sizeof(DSCBUFFERDESC1); + hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, (IUnknown*)0xdeadbeef); + } + ok(hr == DSERR_NOAGGREGATION, + "IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected DSERR_NOAGGREGATION\n", hr); + ok(buffer == (IDirectSoundCaptureBuffer*)0xdeadbeef || !buffer /* Win2k without DirectX9 */, + "buffer = %p\n", buffer); + + hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, NULL); + ok(hr == DS_OK, "IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected DS_OK\n", hr); + + /* IDirectSoundCaptureBuffer and IDirectSoundNotify have separate refcounts */ + IDirectSoundCaptureBuffer_AddRef(buffer); + refcount = IDirectSoundCaptureBuffer_AddRef(buffer); + ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n", refcount); + hr = IDirectSoundCaptureBuffer_QueryInterface(buffer, &IID_IDirectSoundNotify, (void**)¬ify); + ok(hr == DS_OK, "IDirectSoundCapture_QueryInterface failed: %08x, expected DS_OK\n", hr); + refcount = IDirectSoundNotify_AddRef(notify); + ok(refcount == 2, "IDirectSoundNotify refcount is %u, expected 2\n", refcount); + IDirectSoundCaptureBuffer_AddRef(buffer); + refcount = IDirectSoundCaptureBuffer_Release(buffer); + ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n", refcount); + + /* Release IDirectSoundCaptureBuffer while keeping IDirectSoundNotify alive */ + while (IDirectSoundCaptureBuffer_Release(buffer) > 0); + refcount = IDirectSoundNotify_AddRef(notify); + ok(refcount == 3, "IDirectSoundNotify refcount is %u, expected 3\n", refcount); + refcount = IDirectSoundCaptureBuffer_AddRef(buffer); + ok(refcount == 1, "IDirectSoundCaptureBuffer refcount is %u, expected 1\n", refcount); + + while (IDirectSoundNotify_Release(notify) > 0); + refcount = IDirectSoundCaptureBuffer_Release(buffer); + ok(refcount == 0, "IDirectSoundCaptureBuffer refcount is %u, expected 0\n", refcount); + refcount = IDirectSoundCapture_Release(dsc); + ok(refcount == 0, "IDirectSoundCapture refcount is %u, expected 0\n", refcount); +} + START_TEST(capture) { HMODULE hDsound; @@ -685,25 +767,22 @@ CoInitialize(NULL); hDsound = LoadLibrary("dsound.dll"); - if (hDsound) - { - - pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound, - "DirectSoundCaptureCreate"); - pDirectSoundCaptureEnumerateA=(void*)GetProcAddress(hDsound, - "DirectSoundCaptureEnumerateA"); - if (pDirectSoundCaptureCreate && pDirectSoundCaptureEnumerateA) - { - IDirectSoundCapture_tests(); - capture_tests(); - } - else - skip("capture test skipped\n"); - - FreeLibrary(hDsound); - } - else - skip("dsound.dll not found!\n"); - + if (!hDsound) { + skip("dsound.dll not found - skipping all tests\n"); + return; + } + + pDirectSoundCaptureCreate = (void*)GetProcAddress(hDsound, "DirectSoundCaptureCreate"); + pDirectSoundCaptureEnumerateA = (void*)GetProcAddress(hDsound, "DirectSoundCaptureEnumerateA"); + if (!pDirectSoundCaptureCreate || !pDirectSoundCaptureEnumerateA) { + skip("DirectSoundCapture{Create,Enumerate} missing - skipping all tests\n"); + return; + } + + test_COM(); + test_capture(); + test_enumerate(); + + FreeLibrary(hDsound); CoUninitialize(); } Modified: trunk/rostests/winetests/dsound/ds3d.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/ds3d.c?r…
============================================================================== --- trunk/rostests/winetests/dsound/ds3d.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/ds3d.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -23,13 +23,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#include <wine/test.h> + +//#include <windows.h> #include <math.h> - -#include "wine/test.h" -#include "dsound.h" -#include "mmreg.h" +#include <wingdi.h> +#include <mmsystem.h> +#include <dsound.h> +#include <mmreg.h> +#include "ks.h" +#include "ksmedia.h" #include "dsound_test.h" #define PI 3.14159265358979323846 @@ -39,7 +47,7 @@ static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*, LPUNKNOWN)=NULL; -char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size) +char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size, BOOL ieee) { int i; int nb_samples; @@ -52,12 +60,12 @@ for (i=0;i<nb_samples;i++) { double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec); if (wfx->wBitsPerSample==8) { - unsigned char sample=(unsigned char)((double)127.5*(y+1.0)); + unsigned char sample=127.5*(y+1.0); *b++=sample; if (wfx->nChannels==2) *b++=sample; } else if (wfx->wBitsPerSample == 16) { - signed short sample=(signed short)((double)32767.5*y-0.5); + signed short sample=32767.5*y-0.5; b[0]=sample & 0xff; b[1]=sample >> 8; b+=2; @@ -67,7 +75,7 @@ b+=2; } } else if (wfx->wBitsPerSample == 24) { - signed int sample=(signed int)((double)8388607.5*y-0.5); + signed int sample=8388607.5*y-0.5; b[0]=sample & 0xff; b[1]=(sample >> 8)&0xff; b[2]=sample >> 16; @@ -79,18 +87,31 @@ b+=3; } } else if (wfx->wBitsPerSample == 32) { - signed int sample=(signed int)((double)2147483647.5*y-0.5); - b[0]=sample & 0xff; - b[1]=(sample >> 8)&0xff; - b[2]=(sample >> 16)&0xff; - b[3]=sample >> 24; - b+=4; - if (wfx->nChannels==2) { + if (ieee) { + float *ptr = (float *) b; + *ptr = y; + + ptr++; + b+=4; + + if (wfx->nChannels==2) { + *ptr = y; + b+=4; + } + } else { + signed int sample=2147483647.5*y-0.5; b[0]=sample & 0xff; b[1]=(sample >> 8)&0xff; b[2]=(sample >> 16)&0xff; b[3]=sample >> 24; b+=4; + if (wfx->nChannels==2) { + b[0]=sample & 0xff; + b[1]=(sample >> 8)&0xff; + b[2]=(sample >> 16)&0xff; + b[3]=sample >> 24; + b+=4; + } } } } @@ -317,6 +338,7 @@ DSBCAPS dsbcaps; WAVEFORMATEX wfx,wfx2; DWORD size,status,freq; + BOOL ieee = FALSE; int ref; if (set_frequency) { @@ -358,12 +380,16 @@ if (size == sizeof(WAVEFORMATEX)) { rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,size,NULL); + ieee = (wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT); } else if (size == sizeof(WAVEFORMATEXTENSIBLE)) { WAVEFORMATEXTENSIBLE wfxe; rc=IDirectSoundBuffer_GetFormat(*dsbo,(WAVEFORMATEX*)&wfxe,size,NULL); wfx = wfxe.Format; - } + ieee = IsEqualGUID(&wfxe.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); + } else + return; + ok(rc==DS_OK, "IDirectSoundBuffer_GetFormat() failed: %08x\n", rc); if (rc==DS_OK && winetest_debug > 1) { @@ -600,9 +626,9 @@ "returned DSERR_INVALIDPARAM, returned %08x\n", rc); if (set_frequency) - state.wave=wave_generate_la(&wfx,(duration*frequency)/wfx.nSamplesPerSec,&state.wave_len); + state.wave=wave_generate_la(&wfx,(duration*frequency)/wfx.nSamplesPerSec,&state.wave_len,ieee); else - state.wave=wave_generate_la(&wfx,duration,&state.wave_len); + state.wave=wave_generate_la(&wfx,duration,&state.wave_len,ieee); state.dsbo=*dsbo; state.wfx=&wfx; @@ -783,7 +809,7 @@ ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; - if (has_3d) + if (has_3dbuffer) bufdesc.dwFlags|=DSBCAPS_CTRL3D; else bufdesc.dwFlags|= @@ -805,8 +831,8 @@ wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); - ok(rc==DS_OK && secondary!=NULL,"IDirectSound_CreateSoundBuffer() " - "failed to create a %s%ssecondary buffer %s%s%s%sat %dx%dx%d (%s): %08x\n", + ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ + "IDirectSound_CreateSoundBuffer() failed to create a %s%ssecondary buffer %s%s%s%sat %dx%dx%d (%s): %08x\n", has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"", listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"", listener!=NULL?"listener ":"", @@ -815,6 +841,14 @@ wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, getDSBCAPS(bufdesc.dwFlags),rc); if (rc==DS_OK && secondary!=NULL) { + IDirectSound3DBuffer *ds3d; + + rc=IDirectSoundBuffer_QueryInterface(secondary, &IID_IDirectSound3DBuffer, (void**)&ds3d); + ok((has_3dbuffer && rc==DS_OK) || (!has_3dbuffer && rc==E_NOINTERFACE), + "Wrong return trying to get 3D buffer on %s3D secondary interface: %08x\n", has_3dbuffer ? "" : "non-", rc); + if(rc==DS_OK) + IDirectSound3DBuffer_Release(ds3d); + if (!has_3d) { LONG refvol,vol,refpan,pan; @@ -1195,15 +1229,13 @@ !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0, listener,0,0,FALSE,0); - todo_wine { - temp_buffer = NULL; - rc=IDirectSound3DListener_QueryInterface(listener, - &IID_IKsPropertySet,(LPVOID *)&temp_buffer); - ok(rc==DS_OK && temp_buffer!=NULL, - "IDirectSound3DListener_QueryInterface didn't handle IKsPropertySet: ret = %08x\n", rc); - if(temp_buffer) - IKsPropertySet_Release(temp_buffer); - } + temp_buffer = NULL; + rc = IDirectSound3DListener_QueryInterface(listener, &IID_IKsPropertySet, + (void **)&temp_buffer); + ok(rc==DS_OK && temp_buffer!=NULL, + "IDirectSound3DListener_QueryInterface didn't handle IKsPropertySet: ret = %08x\n", rc); + if(temp_buffer) + IKsPropertySet_Release(temp_buffer); } /* Testing the reference counting */ @@ -1212,15 +1244,12 @@ "references, should have 0\n",ref); } - todo_wine { - temp_buffer = NULL; - rc=IDirectSoundBuffer_QueryInterface(primary, - &IID_IKsPropertySet,(LPVOID *)&temp_buffer); - ok(rc==DS_OK && temp_buffer!=NULL, - "IDirectSoundBuffer_QueryInterface didn't handle IKsPropertySet on primary buffer: ret = %08x\n", rc); - if(temp_buffer) - IKsPropertySet_Release(temp_buffer); - } + temp_buffer = NULL; + rc = IDirectSoundBuffer_QueryInterface(primary, &IID_IKsPropertySet, (void **)&temp_buffer); + ok(rc==DS_OK && temp_buffer!=NULL, + "IDirectSoundBuffer_QueryInterface didn't handle IKsPropertySet on primary buffer: ret = %08x\n", rc); + if(temp_buffer) + IKsPropertySet_Release(temp_buffer); /* Testing the reference counting */ ref=IDirectSoundBuffer_Release(primary); @@ -1237,11 +1266,14 @@ return rc; } +static unsigned driver_count = 0; + static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) { HRESULT rc; trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule); + driver_count++; rc = test_for_driver(lpGuid); if (rc == DSERR_NODRIVER) { @@ -1288,6 +1320,7 @@ HRESULT rc; rc=pDirectSoundEnumerateA(&dsenum_callback,NULL); ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc); + trace("tested %u DirectSound drivers\n", driver_count); } START_TEST(ds3d) @@ -1310,7 +1343,7 @@ FreeLibrary(hDsound); } else - skip("dsound.dll not found!\n"); + skip("dsound.dll not found - skipping all tests\n"); CoUninitialize(); } Modified: trunk/rostests/winetests/dsound/ds3d8.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/ds3d8.c?…
============================================================================== --- trunk/rostests/winetests/dsound/ds3d8.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/ds3d8.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -23,13 +23,20 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +//#include <windows.h> #include <math.h> -#include "wine/test.h" -#include "dsound.h" -#include "mmreg.h" +#include <wine/test.h> +#include <wingdi.h> +#include <mmreg.h> +#include <dsound.h> +//#include "ks.h" +#include <ksmedia.h> #include "dsound_test.h" static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL; @@ -181,6 +188,7 @@ DSBCAPS dsbcaps; WAVEFORMATEX wfx,wfx2; DWORD size,status,freq; + BOOL ieee = FALSE; int ref; /* DSOUND: Error: Invalid caps pointer */ @@ -214,11 +222,15 @@ if (size == sizeof(WAVEFORMATEX)) { rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,size,NULL); + ieee = (wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT); } else if (size == sizeof(WAVEFORMATEXTENSIBLE)) { WAVEFORMATEXTENSIBLE wfxe; rc=IDirectSoundBuffer_GetFormat(*dsbo,(WAVEFORMATEX*)&wfxe,size,NULL); wfx = wfxe.Format; - } + ieee = IsEqualGUID(&wfxe.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); + } else + return; + ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc); if (rc==DS_OK && winetest_debug > 1) { trace(" Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n", @@ -447,7 +459,7 @@ ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have " "returned DSERR_INVALIDPARAM, returned %08x\n", rc); - state.wave=wave_generate_la(&wfx,duration,&state.wave_len); + state.wave=wave_generate_la(&wfx,duration,&state.wave_len,ieee); state.dsbo=*dsbo; state.wfx=&wfx; @@ -643,7 +655,10 @@ "IDirectSound8_CreateSoundBuffer(secondary) should have " "returned DSERR_INVALIDPARAM, returned %08x\n", rc); if (secondary) + { ref=IDirectSoundBuffer_Release(secondary); + ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, should have 0\n",ref); + } init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1); } @@ -699,7 +714,7 @@ rc=IDirectSoundBuffer_SetPan(secondary,-1000); ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: %08x\n",rc); rc=IDirectSoundBuffer_GetPan(secondary,&pan); - ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: %08x\n",rc); + ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed: %08x\n",rc); ok(pan==-1000,"secondary: wrong pan %d instead of -1000\n", pan); @@ -1073,11 +1088,14 @@ return rc; } +static unsigned driver_count = 0; + static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) { HRESULT rc; trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule); + driver_count++; rc = test_for_driver8(lpGuid); if (rc == DSERR_NODRIVER) { @@ -1124,6 +1142,7 @@ HRESULT rc; rc=pDirectSoundEnumerateA(&dsenum_callback,NULL); ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc); + trace("tested %u DirectSound drivers\n", driver_count); } START_TEST(ds3d8) @@ -1143,12 +1162,12 @@ if (pDirectSoundCreate8) ds3d8_tests(); else - skip("ds3d8 test skipped\n"); + skip("DirectSoundCreate8 missing - skipping all tests\n"); FreeLibrary(hDsound); } else - skip("dsound.dll not found!\n"); + skip("dsound.dll not found - skipping all tests\n"); CoUninitialize(); } Modified: trunk/rostests/winetests/dsound/dsound.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/dsound.c…
============================================================================== --- trunk/rostests/winetests/dsound/dsound.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/dsound.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -26,15 +26,20 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> - -#include "wine/test.h" -#include "dsound.h" -#include "dsconf.h" -#include "mmreg.h" -#include "initguid.h" -#include "ks.h" -#include "ksmedia.h" +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +//#include <windows.h> + +#include <wine/test.h> +#include <wingdi.h> +#include <mmreg.h> +#include <dsound.h> +#include <dsconf.h> +//#include "initguid.h" +//#include "ks.h" +#include <ksmedia.h> #include "dsound_test.h" @@ -173,7 +178,7 @@ static void IDirectSound_tests(void) { HRESULT rc; - LPDIRECTSOUND dso=NULL; + IDirectSound *dso=(IDirectSound*)0xdeadbeef; LPCLASSFACTORY cf=NULL; trace("Testing IDirectSound\n"); @@ -187,6 +192,12 @@ &IID_IUnknown, (void**)&cf); ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound, IID_IUnknown) " "failed: %08x\n", rc); + + /* COM aggregation */ + rc=CoCreateInstance(&CLSID_DirectSound, (IUnknown*)&dso, CLSCTX_INPROC_SERVER, + &IID_IDirectSound, (void**)&dso); + ok(rc==CLASS_E_NOAGGREGATION || broken(rc==DSERR_INVALIDPARAM), + "DirectMusicPerformance create failed: %08x, expected CLASS_E_NOAGGREGATION\n", rc); /* try the COM class factory method of creation with no device specified */ rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER, @@ -326,7 +337,7 @@ wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); - ok(rc==DS_OK && secondary!=NULL, + ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ "IDirectSound_CreateSoundBuffer() failed to create a secondary " "buffer %08x\n",rc); if (rc==DS_OK && secondary!=NULL) { @@ -493,6 +504,15 @@ !(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0,FALSE,0); ref=IDirectSoundBuffer_Release(primary); + ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references\n",ref); + + ref=IDirectSoundBuffer_AddRef(primary); + ok(ref==1,"IDirectSoundBuffer_AddRef() primary has %d references\n",ref); + + ref=IDirectSoundBuffer_Release(primary); + ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references\n",ref); + + ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } @@ -523,7 +543,7 @@ DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx2; - int f,ref; + int f,ref,tag; /* Create the DirectSound object */ rc=pDirectSoundCreate(lpGuid,&dso,NULL); @@ -556,6 +576,11 @@ if (rc==DS_OK && primary!=NULL) { for (f=0;f<NB_FORMATS;f++) { + for (tag=0;tag<NB_TAGS;tag++) { + /* if float, we only want to test 32-bit */ + if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] != 32)) + continue; + /* We must call SetCooperativeLevel to be allowed to call * SetFormat */ /* DSOUND: Setting DirectSound cooperative level to @@ -565,7 +590,7 @@ if (rc!=DS_OK) goto EXIT; - init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], + init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1], formats[f][2]); wfx2=wfx; rc=IDirectSoundBuffer_SetFormat(primary,&wfx); @@ -612,13 +637,13 @@ wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx2; if (winetest_interactive) { - trace(" Testing a primary buffer at %dx%dx%d with a " + trace(" Testing a primary buffer at %dx%dx%d (fmt=%d) with a " "secondary buffer at %dx%dx%d\n", - wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, + wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag], wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); - ok(rc==DS_OK && secondary!=NULL, + ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); if (rc==DS_OK && secondary!=NULL) { @@ -629,6 +654,7 @@ ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } + } } ref=IDirectSoundBuffer_Release(primary); @@ -658,7 +684,7 @@ DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; - DWORD f; + DWORD f, tag; int ref; /* Create the DirectSound object */ @@ -697,8 +723,14 @@ goto EXIT1; for (f=0;f<NB_FORMATS;f++) { + for (tag=0;tag<NB_TAGS;tag++) { WAVEFORMATEXTENSIBLE wfxe; - init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], + + /* if float, we only want to test 32-bit */ + if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] != 32)) + continue; + + init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1], formats[f][2]); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); @@ -720,16 +752,16 @@ wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); - if (gotdx8 || wfx.wBitsPerSample <= 16) + if (gotdx8 || wfx.wBitsPerSample <= 16 || wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT) { if (wfx.wBitsPerSample > 16) - ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary) + ok(broken((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary) || rc == DS_OK, /* driver dependent? */ "IDirectSound_CreateSoundBuffer() " "should have returned (DSERR_CONTROLUNAVAIL or DSERR_INVALIDCALL) " "and NULL, returned: %08x %p\n", rc, secondary); else - ok(rc==DS_OK && secondary!=NULL, + ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); } else @@ -738,7 +770,7 @@ if (!gotdx8) { - skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n"); + win_skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n"); /* Apparently they succeed with bogus values, * which means that older dsound doesn't look at them */ @@ -752,7 +784,7 @@ bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe; wfxe.Format = wfx; wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); wfxe.Format.cbSize = 1; wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample; wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO); @@ -792,7 +824,7 @@ IDirectSoundBuffer_Release(secondary); secondary=NULL; } - wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); ++wfxe.Samples.wValidBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); @@ -825,9 +857,9 @@ no_wfe: if (rc==DS_OK && secondary!=NULL) { if (winetest_interactive) { - trace(" Testing a secondary buffer at %dx%dx%d " + trace(" Testing a secondary buffer at %dx%dx%d (fmt=%d) " "with a primary buffer at %dx%dx%d\n", - wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, + wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag], wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } test_buffer(dso,&secondary,0,FALSE,0,FALSE,0, @@ -837,6 +869,7 @@ ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } + } } EXIT1: ref=IDirectSoundBuffer_Release(primary); @@ -883,8 +916,8 @@ bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec + 1; bufdesc.lpwfxFormat=&wfx; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); - ok(rc==DS_OK,"IDirectSound_CreateSoundBuffer() " - "should have returned DS_OK, returned: %08x\n", rc); + ok(rc == DS_OK || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ + "IDirectSound_CreateSoundBuffer() should have returned DS_OK, returned: %08x\n", rc); if (rc==DS_OK && secondary!=NULL) { ZeroMemory(&dsbcaps, sizeof(dsbcaps)); @@ -993,7 +1026,7 @@ wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); - ok(rc==DS_OK && secondary!=NULL, + ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); if (rc==DS_OK && secondary!=NULL) { @@ -1024,6 +1057,438 @@ return DSERR_GENERIC; return rc; +} + +static HRESULT test_notify(LPDIRECTSOUNDBUFFER dsb, + DWORD count, LPHANDLE event, + DWORD expected) +{ + HRESULT rc; + DWORD ret; + + rc=IDirectSoundBuffer_SetCurrentPosition(dsb,0); + ok(rc==DS_OK, + "IDirectSoundBuffer_SetCurrentPosition failed %08x\n",rc); + if(rc!=DS_OK) + return rc; + + rc=IDirectSoundBuffer_Play(dsb,0,0,0); + ok(rc==DS_OK,"IDirectSoundBuffer_Play failed %08x\n",rc); + if(rc!=DS_OK) + return rc; + + rc=IDirectSoundBuffer_Stop(dsb); + ok(rc==DS_OK,"IDirectSoundBuffer_Stop failed %08x\n",rc); + if(rc!=DS_OK) + return rc; + + ret=WaitForMultipleObjects(count,event,FALSE,0); + ok(ret==expected,"expected %d. got %d\n",expected,ret); + return rc; +} + +static HRESULT test_duplicate(LPGUID lpGuid) +{ + HRESULT rc; + LPDIRECTSOUND dso=NULL; + LPDIRECTSOUNDBUFFER primary=NULL; + DSBUFFERDESC bufdesc; + int ref; + + /* Create the DirectSound object */ + rc=pDirectSoundCreate(lpGuid,&dso,NULL); + ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, + "DirectSoundCreate() failed: %08x\n",rc); + if (rc!=DS_OK) + return rc; + + /* We must call SetCooperativeLevel before creating primary buffer */ + /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ + rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); + ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); + if (rc!=DS_OK) + goto EXIT; + + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize=sizeof(bufdesc); + bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); + ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed " + "to create a primary buffer %08x\n",rc); + + if (rc==DS_OK && primary!=NULL) { + LPDIRECTSOUNDBUFFER original=NULL; + WAVEFORMATEX wfx; + + init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1); + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize=sizeof(bufdesc); + bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLPOSITIONNOTIFY; + bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec/100; /* very short buffer */ + bufdesc.lpwfxFormat=&wfx; + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&original,NULL); + ok(rc==DS_OK && original!=NULL, + "IDirectSound_CreateSoundBuffer() failed to create a original " + "buffer %08x\n",rc); + if (rc==DS_OK && original!=NULL) { + LPDIRECTSOUNDBUFFER duplicated=NULL; + LPDIRECTSOUNDNOTIFY notify=NULL; + HANDLE event[2]; + LPVOID buf=NULL; + DWORD bufsize; + int i; + + /* Prepare notify events */ + for (i=0;i<sizeof(event)/sizeof(event[0]);i++) { + event[i] = CreateEvent(NULL,FALSE,FALSE,NULL); + } + + /* Make silent buffer */ + rc=IDirectSoundBuffer_Lock(original,0,0,&buf,&bufsize, + NULL,NULL,DSBLOCK_ENTIREBUFFER); + ok(rc==DS_OK && buf!=NULL, + "IDirectSoundBuffer_Lock failed to lock the buffer %08x\n",rc); + if (rc==DS_OK && buf!=NULL) { + ZeroMemory(buf,bufsize); + rc=IDirectSoundBuffer_Unlock(original,buf,bufsize, + NULL,0); + ok(rc==DS_OK,"IDirectSoundBuffer_Unlock failed to unlock " + "%08x\n",rc); + } + + rc=IDirectSoundBuffer_QueryInterface(original, + &IID_IDirectSoundNotify, + (void**)¬ify); + ok(rc==DS_OK && notify!=NULL, + "IDirectSoundBuffer_QueryInterface() failed to create a " + "notification %08x\n",rc); + if (rc==DS_OK && notify!=NULL) { + DSBPOSITIONNOTIFY dsbpn; + LPDIRECTSOUNDNOTIFY dup_notify=NULL; + + dsbpn.dwOffset=DSBPN_OFFSETSTOP; + dsbpn.hEventNotify=event[0]; + rc=IDirectSoundNotify_SetNotificationPositions(notify, + 1,&dsbpn); + ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions " + "failed %08x\n",rc); + + rc=IDirectSound_DuplicateSoundBuffer(dso,original,&duplicated); + ok(rc==DS_OK && duplicated!=NULL, + "IDirectSound_DuplicateSoundBuffer failed %08x\n",rc); + + trace("testing duplicated buffer without notifications.\n"); + test_notify(duplicated,sizeof(event)/sizeof(event[0]), + event,WAIT_TIMEOUT); + + rc=IDirectSoundBuffer_QueryInterface(duplicated, + &IID_IDirectSoundNotify, + (void**)&dup_notify); + ok(rc==DS_OK&&dup_notify!=NULL, + "IDirectSoundBuffer_QueryInterface() failed to create a " + "notification %08x\n",rc); + if(rc==DS_OK&&dup_notify!=NULL) { + dsbpn.dwOffset=DSBPN_OFFSETSTOP; + dsbpn.hEventNotify=event[1]; + rc=IDirectSoundNotify_SetNotificationPositions(dup_notify, + 1,&dsbpn); + ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions " + "failed %08x\n",rc); + + trace("testing duplicated buffer with a notification.\n"); + test_notify(duplicated,sizeof(event)/sizeof(event[0]), + event,WAIT_OBJECT_0+1); + + ref=IDirectSoundNotify_Release(dup_notify); + ok(ref==0,"IDirectSoundNotify_Release() has %d references, " + "should have 0\n",ref); + } + ref=IDirectSoundNotify_Release(notify); + ok(ref==0,"IDirectSoundNotify_Release() has %d references, " + "should have 0\n",ref); + + trace("testing original buffer with a notification.\n"); + test_notify(original,sizeof(event)/sizeof(event[0]), + event,WAIT_OBJECT_0); + + ref=IDirectSoundBuffer_Release(duplicated); + ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " + "should have 0\n",ref); + } + ref=IDirectSoundBuffer_Release(original); + ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " + "should have 0\n",ref); + } + ref=IDirectSoundBuffer_Release(primary); + ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " + "should have 0\n",ref); + } + + /* Set the CooperativeLevel back to normal */ + /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ + rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); + ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); + +EXIT: + ref=IDirectSound_Release(dso); + ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); + if (ref!=0) + return DSERR_GENERIC; + + return rc; +} + +static HRESULT test_invalid_fmts(LPGUID lpGuid) +{ + HRESULT rc; + LPDIRECTSOUND dso=NULL; + LPDIRECTSOUNDBUFFER primary=NULL; + DSBUFFERDESC bufdesc; + + /* Create the DirectSound object */ + rc=pDirectSoundCreate(lpGuid,&dso,NULL); + ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, + "DirectSoundCreate() failed: %08x\n",rc); + if (rc!=DS_OK) + return rc; + + /* We must call SetCooperativeLevel before creating primary buffer */ + /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ + rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); + ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); + if (rc!=DS_OK){ + IDirectSound_Release(dso); + return rc; + } + + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize=sizeof(bufdesc); + bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); + ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed " + "to create a primary buffer %08x\n",rc); + + if (rc==DS_OK && primary!=NULL) { + WAVEFORMATEX wfx; + WAVEFORMATEXTENSIBLE fmtex; + + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = 0; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 0; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 2; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 12; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 0; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = 0; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = 0; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample / 8) - 1; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample / 8) + 1; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign + 1; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == S_OK, "SetFormat: %08x\n", rc); + + rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL); + ok(rc == S_OK, "GetFormat: %08x\n", rc); + ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "format: 0x%x\n", wfx.wFormatTag); + ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels); + ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec); + ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample); + ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign); + ok(wfx.nAvgBytesPerSec == 44100 * 4 + 1, "avgbytes: %u\n", wfx.nAvgBytesPerSec); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign - 1; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == S_OK, "SetFormat: %08x\n", rc); + + rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL); + ok(rc == S_OK, "GetFormat: %08x\n", rc); + ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "format: 0x%x\n", wfx.wFormatTag); + ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels); + ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec); + ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample); + ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign); + ok(wfx.nAvgBytesPerSec == 44100 * 4 - 1, "avgbytes: %u\n", wfx.nAvgBytesPerSec); + + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign + 1; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == S_OK, "SetFormat: %08x\n", rc); + + rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL); + ok(rc == S_OK, "GetFormat: %08x\n", rc); + ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "format: 0x%x\n", wfx.wFormatTag); + ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels); + ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec); + ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample); + ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign); + ok(wfx.nAvgBytesPerSec == 44100 * 4 + 1, "avgbytes: %u\n", wfx.nAvgBytesPerSec); + + wfx.wFormatTag = WAVE_FORMAT_ALAW; + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + rc = IDirectSoundBuffer_SetFormat(primary, &wfx); + ok(rc == S_OK, "SetFormat: %08x\n", rc); + + rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL); + ok(rc == S_OK, "GetFormat: %08x\n", rc); + ok(wfx.wFormatTag == WAVE_FORMAT_ALAW, "format: 0x%x\n", wfx.wFormatTag); + ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels); + ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec); + ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample); + ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign); + ok(wfx.nAvgBytesPerSec == 44100 * 4, "avgbytes: %u\n", wfx.nAvgBytesPerSec); + + if(!gotdx8){ + win_skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n"); + goto done; + } + + fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); + fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + fmtex.Format.nChannels = 2; + fmtex.Format.nSamplesPerSec = 44100; + fmtex.Format.wBitsPerSample = 16; + fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample / 8; + fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec * fmtex.Format.nBlockAlign; + fmtex.Samples.wValidBitsPerSample = 0; + fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + rc = IDirectSoundBuffer_SetFormat(primary, (WAVEFORMATEX*)&fmtex); + ok(rc == S_OK, "SetFormat: %08x\n", rc); + + rc = IDirectSoundBuffer_GetFormat(primary, (WAVEFORMATEX*)&fmtex, sizeof(fmtex), NULL); + ok(rc == S_OK, "GetFormat: %08x\n", rc); + ok(fmtex.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "format: 0x%x\n", fmtex.Format.wFormatTag); + ok(fmtex.Format.nChannels == 2, "channels: %u\n", fmtex.Format.nChannels); + ok(fmtex.Format.nSamplesPerSec == 44100, "rate: %u\n", fmtex.Format.nSamplesPerSec); + ok(fmtex.Format.wBitsPerSample == 16, "bps: %u\n", fmtex.Format.wBitsPerSample); + ok(fmtex.Format.nBlockAlign == 4, "blockalign: %u\n", fmtex.Format.nBlockAlign); + ok(fmtex.Format.nAvgBytesPerSec == 44100 * 4, "avgbytes: %u\n", fmtex.Format.nAvgBytesPerSec); + ok(fmtex.Samples.wValidBitsPerSample == 0 || /* <= XP */ + fmtex.Samples.wValidBitsPerSample == 16, /* >= Vista */ + "validbits: %u\n", fmtex.Samples.wValidBitsPerSample); + ok(IsEqualGUID(&fmtex.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM), "subtype incorrect\n"); + + fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); + fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + fmtex.Format.nChannels = 2; + fmtex.Format.nSamplesPerSec = 44100; + fmtex.Format.wBitsPerSample = 24; + fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample / 8; + fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec * fmtex.Format.nBlockAlign; + fmtex.Samples.wValidBitsPerSample = 20; + fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + rc = IDirectSoundBuffer_SetFormat(primary, (WAVEFORMATEX*)&fmtex); + ok(rc == S_OK, "SetFormat: %08x\n", rc); + + rc = IDirectSoundBuffer_GetFormat(primary, (WAVEFORMATEX*)&fmtex, sizeof(fmtex), NULL); + ok(rc == S_OK, "GetFormat: %08x\n", rc); + ok(fmtex.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "format: 0x%x\n", fmtex.Format.wFormatTag); + ok(fmtex.Format.nChannels == 2, "channels: %u\n", fmtex.Format.nChannels); + ok(fmtex.Format.nSamplesPerSec == 44100, "rate: %u\n", fmtex.Format.nSamplesPerSec); + ok(fmtex.Format.wBitsPerSample == 24, "bps: %u\n", fmtex.Format.wBitsPerSample); + ok(fmtex.Format.nBlockAlign == 6, "blockalign: %u\n", fmtex.Format.nBlockAlign); + ok(fmtex.Format.nAvgBytesPerSec == 44100 * 6, "avgbytes: %u\n", fmtex.Format.nAvgBytesPerSec); + ok(fmtex.Samples.wValidBitsPerSample == 20, "validbits: %u\n", fmtex.Samples.wValidBitsPerSample); + ok(IsEqualGUID(&fmtex.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM), "subtype incorrect\n"); + + fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); + fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + fmtex.Format.nChannels = 2; + fmtex.Format.nSamplesPerSec = 44100; + fmtex.Format.wBitsPerSample = 24; + fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample / 8; + fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec * fmtex.Format.nBlockAlign; + fmtex.Samples.wValidBitsPerSample = 32; + fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + rc = IDirectSoundBuffer_SetFormat(primary, (WAVEFORMATEX*)&fmtex); + ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc); + + IDirectSoundBuffer_Release(primary); + } + +done: + IDirectSound_Release(dso); + + return S_OK; } static unsigned int number; @@ -1054,6 +1519,8 @@ test_primary_secondary(lpGuid); test_secondary(lpGuid); test_frequency(lpGuid); + test_duplicate(lpGuid); + test_invalid_fmts(lpGuid); } return 1; @@ -1066,6 +1533,118 @@ ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc); } +static void test_hw_buffers(void) +{ + IDirectSound *ds; + IDirectSoundBuffer *primary, *primary2, **secondaries, *secondary; + IDirectSoundBuffer8 *buf8; + DSCAPS caps; + DSBCAPS bufcaps; + DSBUFFERDESC bufdesc; + WAVEFORMATEX fmt; + UINT i; + HRESULT hr; + + hr = pDirectSoundCreate(NULL, &ds, NULL); + ok(hr == S_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL, + "DirectSoundCreate failed: %08x\n", hr); + if(hr != S_OK) + return; + + caps.dwSize = sizeof(caps); + + hr = IDirectSound_GetCaps(ds, &caps); + ok(hr == S_OK, "GetCaps failed: %08x\n", hr); + + ok(caps.dwPrimaryBuffers == 1, "Got wrong number of primary buffers: %u\n", + caps.dwPrimaryBuffers); + + /* DSBCAPS_LOC* is ignored for primary buffers */ + bufdesc.dwSize = sizeof(bufdesc); + bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE | + DSBCAPS_PRIMARYBUFFER; + bufdesc.dwBufferBytes = 0; + bufdesc.dwReserved = 0; + bufdesc.lpwfxFormat = NULL; + bufdesc.guid3DAlgorithm = GUID_NULL; + + hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &primary, NULL); + ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr); + if(hr != S_OK){ + IDirectSound_Release(ds); + return; + } + + bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE | + DSBCAPS_PRIMARYBUFFER; + + hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &primary2, NULL); + ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr); + ok(primary == primary2, "Got different primary buffers: %p, %p\n", primary, primary2); + if(hr == S_OK) + IDirectSoundBuffer_Release(primary2); + + buf8 = (IDirectSoundBuffer8 *)0xDEADBEEF; + hr = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8, + (void**)&buf8); + ok(hr == E_NOINTERFACE, "QueryInterface gave wrong failure: %08x\n", hr); + ok(buf8 == NULL, "Pointer didn't get set to NULL\n"); + + fmt.wFormatTag = WAVE_FORMAT_PCM; + fmt.nChannels = 2; + fmt.nSamplesPerSec = 48000; + fmt.wBitsPerSample = 16; + fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; + fmt.nAvgBytesPerSec = fmt.nBlockAlign * fmt.nSamplesPerSec; + fmt.cbSize = 0; + + bufdesc.lpwfxFormat = &fmt; + bufdesc.dwBufferBytes = fmt.nSamplesPerSec * fmt.nBlockAlign / 10; + bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE | + DSBCAPS_CTRLVOLUME; + + secondaries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(IDirectSoundBuffer *) * caps.dwMaxHwMixingAllBuffers); + + /* try to fill all of the hw buffers */ + trace("dwMaxHwMixingAllBuffers: %u\n", caps.dwMaxHwMixingAllBuffers); + trace("dwMaxHwMixingStaticBuffers: %u\n", caps.dwMaxHwMixingStaticBuffers); + trace("dwMaxHwMixingStreamingBuffers: %u\n", caps.dwMaxHwMixingStreamingBuffers); + for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i){ + hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &secondaries[i], NULL); + ok(hr == S_OK || hr == E_NOTIMPL || broken(hr == DSERR_CONTROLUNAVAIL) || broken(hr == E_FAIL), + "CreateSoundBuffer(%u) failed: %08x\n", i, hr); + if(hr != S_OK) + break; + + bufcaps.dwSize = sizeof(bufcaps); + hr = IDirectSoundBuffer_GetCaps(secondaries[i], &bufcaps); + ok(hr == S_OK, "GetCaps failed: %08x\n", hr); + ok((bufcaps.dwFlags & DSBCAPS_LOCHARDWARE) != 0, + "Buffer wasn't allocated in hardware, dwFlags: %x\n", bufcaps.dwFlags); + } + + /* see if we can create one more */ + hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &secondary, NULL); + ok((i == caps.dwMaxHwMixingAllBuffers && hr == DSERR_ALLOCATED) || /* out of hw buffers */ + (caps.dwMaxHwMixingAllBuffers == 0 && hr == DSERR_INVALIDCALL) || /* no hw buffers at all */ + hr == E_NOTIMPL || /* don't support hw buffers */ + broken(hr == DSERR_CONTROLUNAVAIL) || /* vmware winxp, others? */ + broken(hr == E_FAIL) || /* broken AC97 driver */ + broken(hr == S_OK) /* broken driver allows more hw bufs than dscaps claims */, + "CreateSoundBuffer(%u) gave wrong error: %08x\n", i, hr); + if(hr == S_OK) + IDirectSoundBuffer_Release(secondary); + + for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i) + if(secondaries[i]) + IDirectSoundBuffer_Release(secondaries[i]); + HeapFree(GetProcessHeap(), 0, secondaries); + + IDirectSoundBuffer_Release(primary); + IDirectSound_Release(ds); +} + START_TEST(dsound) { HMODULE hDsound; @@ -1077,14 +1656,8 @@ { BOOL ret; - ok( FreeLibrary(hDsound), "FreeLibrary(1) returned %d\n", GetLastError()); - SetLastError(0xdeadbeef); ret = FreeLibrary(hDsound); - ok( ret || - broken(!ret && GetLastError() == ERROR_MOD_NOT_FOUND) || /* NT4 */ - broken(!ret && GetLastError() == ERROR_INVALID_HANDLE), /* Win9x */ - "FreeLibrary(2) returned %d\n", GetLastError()); - ok(!FreeLibrary(hDsound), "DirectSound DLL still loaded\n"); + ok( ret, "FreeLibrary(1) returned %d\n", GetLastError()); } hDsound = LoadLibrary("dsound.dll"); @@ -1100,11 +1673,12 @@ IDirectSound_tests(); dsound_tests(); + test_hw_buffers(); FreeLibrary(hDsound); } else - skip("dsound.dll not found!\n"); + win_skip("dsound.dll not found - skipping all tests\n"); CoUninitialize(); } Modified: trunk/rostests/winetests/dsound/dsound8.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/dsound8.…
============================================================================== --- trunk/rostests/winetests/dsound/dsound8.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/dsound8.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -25,15 +25,27 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> -#include <stdio.h> - -#include "wine/test.h" -#include "dsound.h" -#include "dsconf.h" -#include "mmreg.h" -#include "ks.h" -#include "ksmedia.h" +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define COBJMACROS +#define NONAMELESSUNION +//#include <windows.h> +//#include <stdio.h> + +#include <wine/test.h> +#include <wingdi.h> +#include <mmreg.h> +#include <dsound.h> +#include <dsconf.h> +//#include "ks.h" +#include <ksmedia.h> +#include <initguid.h> +#include <mmdeviceapi.h> +//#include "audioclient.h" +//#include "propkey.h" +//#include "devpkey.h" #include "dsound_test.h" @@ -356,6 +368,8 @@ &IID_IDirectSoundBuffer8, (void **)&buffer8); if (rc==DS_OK && buffer8!=NULL) { + ok(buffer8==(IDirectSoundBuffer8*)secondary, + "IDirectSoundBuffer8 iface different from IDirectSoundBuffer.\n"); ref=IDirectSoundBuffer8_AddRef(buffer8); ok(ref==3,"IDirectSoundBuffer8_AddRef() has %d references, " "should have 3\n",ref); @@ -534,7 +548,7 @@ DSCAPS dscaps; WAVEFORMATEX wfx, wfx2; int ref; - unsigned int f; + unsigned int f, tag; /* Create the DirectSound object */ rc=pDirectSoundCreate8(lpGuid,&dso,NULL); @@ -568,6 +582,11 @@ if (rc==DS_OK && primary!=NULL) { for (f=0;f<NB_FORMATS;f++) { + for (tag=0;tag<NB_TAGS;tag++) { + /* if float, we only want to test 32-bit */ + if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] != 32)) + continue; + /* We must call SetCooperativeLevel to be allowed to call * SetFormat */ /* DSOUND: Setting DirectSound cooperative level to @@ -577,7 +596,7 @@ if (rc!=DS_OK) goto EXIT; - init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], + init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1], formats[f][2]); wfx2=wfx; rc=IDirectSoundBuffer_SetFormat(primary,&wfx); @@ -621,9 +640,9 @@ wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx2; if (winetest_interactive) { - trace(" Testing a primary buffer at %dx%dx%d with a " + trace(" Testing a primary buffer at %dx%dx%d (fmt=%d) with a " "secondary buffer at %dx%dx%d\n", - wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, + wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag], wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); @@ -639,6 +658,7 @@ ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } + } } ref=IDirectSoundBuffer_Release(primary); @@ -668,7 +688,7 @@ DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; - DWORD f; + DWORD f, tag; int ref; /* Create the DirectSound object */ @@ -708,8 +728,14 @@ goto EXIT1; for (f=0;f<NB_FORMATS;f++) { + for (tag=0;tag<NB_TAGS;tag++) { WAVEFORMATEXTENSIBLE wfxe; - init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], + + /* if float, we only want to test 32-bit */ + if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] != 32)) + continue; + + init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1], formats[f][2]); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); @@ -748,7 +774,7 @@ bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe; wfxe.Format = wfx; wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); wfxe.Format.cbSize = 1; wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample; wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO); @@ -799,7 +825,7 @@ secondary=NULL; } - wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", @@ -854,9 +880,9 @@ if (rc==DS_OK && secondary!=NULL) { if (winetest_interactive) { - trace(" Testing a secondary buffer at %dx%dx%d " + trace(" Testing a secondary buffer at %dx%dx%d (fmt=%d) " "with a primary buffer at %dx%dx%d\n", - wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, + wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag], wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0, @@ -866,6 +892,7 @@ ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } + } } EXIT1: ref=IDirectSoundBuffer_Release(primary); @@ -915,6 +942,236 @@ ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc); } +static void test_hw_buffers(void) +{ + IDirectSound8 *ds; + IDirectSoundBuffer *primary, *primary2, **secondaries, *secondary; + IDirectSoundBuffer8 *buf8; + DSCAPS caps; + DSBCAPS bufcaps; + DSBUFFERDESC bufdesc; + WAVEFORMATEX fmt; + UINT i; + HRESULT hr; + + hr = pDirectSoundCreate8(NULL, &ds, NULL); + ok(hr == S_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL, + "DirectSoundCreate8 failed: %08x\n", hr); + if(hr != S_OK) + return; + + caps.dwSize = sizeof(caps); + + hr = IDirectSound8_GetCaps(ds, &caps); + ok(hr == S_OK, "GetCaps failed: %08x\n", hr); + + ok(caps.dwPrimaryBuffers == 1, "Got wrong number of primary buffers: %u\n", + caps.dwPrimaryBuffers); + + /* DSBCAPS_LOC* is ignored for primary buffers */ + bufdesc.dwSize = sizeof(bufdesc); + bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE | + DSBCAPS_PRIMARYBUFFER; + bufdesc.dwBufferBytes = 0; + bufdesc.dwReserved = 0; + bufdesc.lpwfxFormat = NULL; + bufdesc.guid3DAlgorithm = GUID_NULL; + + hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &primary, NULL); + ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr); + if(hr != S_OK){ + IDirectSound8_Release(ds); + return; + } + + bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE | + DSBCAPS_PRIMARYBUFFER; + + hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &primary2, NULL); + ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr); + ok(primary == primary2, "Got different primary buffers: %p, %p\n", primary, primary2); + if(hr == S_OK) + IDirectSoundBuffer_Release(primary2); + + buf8 = (IDirectSoundBuffer8 *)0xDEADBEEF; + hr = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8, + (void**)&buf8); + ok(hr == E_NOINTERFACE, "QueryInterface gave wrong failure: %08x\n", hr); + ok(buf8 == NULL, "Pointer didn't get set to NULL\n"); + + fmt.wFormatTag = WAVE_FORMAT_PCM; + fmt.nChannels = 2; + fmt.nSamplesPerSec = 48000; + fmt.wBitsPerSample = 16; + fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; + fmt.nAvgBytesPerSec = fmt.nBlockAlign * fmt.nSamplesPerSec; + fmt.cbSize = 0; + + bufdesc.lpwfxFormat = &fmt; + bufdesc.dwBufferBytes = fmt.nSamplesPerSec * fmt.nBlockAlign / 10; + bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE | + DSBCAPS_CTRLVOLUME; + + secondaries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(IDirectSoundBuffer *) * caps.dwMaxHwMixingAllBuffers); + + /* try to fill all of the hw buffers */ + trace("dwMaxHwMixingAllBuffers: %u\n", caps.dwMaxHwMixingAllBuffers); + trace("dwMaxHwMixingStaticBuffers: %u\n", caps.dwMaxHwMixingStaticBuffers); + trace("dwMaxHwMixingStreamingBuffers: %u\n", caps.dwMaxHwMixingStreamingBuffers); + for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i){ + hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &secondaries[i], NULL); + ok(hr == S_OK || hr == E_NOTIMPL || broken(hr == DSERR_CONTROLUNAVAIL) || broken(hr == E_FAIL), + "CreateSoundBuffer(%u) failed: %08x\n", i, hr); + if(hr != S_OK) + break; + + bufcaps.dwSize = sizeof(bufcaps); + hr = IDirectSoundBuffer_GetCaps(secondaries[i], &bufcaps); + ok(hr == S_OK, "GetCaps failed: %08x\n", hr); + ok((bufcaps.dwFlags & DSBCAPS_LOCHARDWARE) != 0, + "Buffer wasn't allocated in hardware, dwFlags: %x\n", bufcaps.dwFlags); + } + + /* see if we can create one more */ + hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &secondary, NULL); + ok((i == caps.dwMaxHwMixingAllBuffers && hr == DSERR_ALLOCATED) || /* out of hw buffers */ + (caps.dwMaxHwMixingAllBuffers == 0 && hr == DSERR_INVALIDCALL) || /* no hw buffers at all */ + hr == E_NOTIMPL || /* don't support hw buffers */ + broken(hr == DSERR_CONTROLUNAVAIL) || /* vmware winxp, others? */ + broken(hr == E_FAIL) || /* broken AC97 driver */ + broken(hr == S_OK) /* broken driver allows more hw bufs than dscaps claims */, + "CreateSoundBuffer(%u) gave wrong error: %08x\n", i, hr); + if(hr == S_OK) + IDirectSoundBuffer_Release(secondary); + + for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i) + if(secondaries[i]) + IDirectSoundBuffer_Release(secondaries[i]); + + HeapFree(GetProcessHeap(), 0, secondaries); + + IDirectSoundBuffer_Release(primary); + IDirectSound8_Release(ds); +} + +static struct { + UINT dev_count; + GUID guid; +} default_info = { 0 }; + +static BOOL WINAPI default_device_cb(GUID *guid, const char *desc, + const char *module, void *user) +{ + trace("guid: %p, desc: %s\n", guid, desc); + if(!guid) + ok(default_info.dev_count == 0, "Got NULL GUID not in first position\n"); + else{ + if(default_info.dev_count == 0){ + ok(IsEqualGUID(guid, &default_info.guid), "Expected default device GUID\n"); + }else{ + ok(!IsEqualGUID(guid, &default_info.guid), "Got default GUID at unexpected location: %u\n", + default_info.dev_count); + } + + /* only count real devices */ + ++default_info.dev_count; + } + + return TRUE; +} + +static void test_first_device(void) +{ + IMMDeviceEnumerator *devenum; + IMMDevice *defdev; + IPropertyStore *ps; + PROPVARIANT pv; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, + CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum); + if(FAILED(hr)){ + win_skip("MMDevAPI is not available, skipping default device test\n"); + return; + } + + hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum, eRender, + eMultimedia, &defdev); + if (hr == E_NOTFOUND) { + win_skip("No default device found\n"); + return; + } + ok(hr == S_OK, "GetDefaultAudioEndpoint failed: %08x\n", hr); + + hr = IMMDevice_OpenPropertyStore(defdev, STGM_READ, &ps); + ok(hr == S_OK, "OpenPropertyStore failed: %08x\n", hr); + + PropVariantInit(&pv); + + hr = IPropertyStore_GetValue(ps, &PKEY_AudioEndpoint_GUID, &pv); + ok(hr == S_OK, "GetValue failed: %08x\n", hr); + + CLSIDFromString(pv.u.pwszVal, &default_info.guid); + + PropVariantClear(&pv); + IPropertyStore_Release(ps); + IMMDevice_Release(defdev); + IMMDeviceEnumerator_Release(devenum); + + hr = pDirectSoundEnumerateA(&default_device_cb, NULL); + ok(hr == S_OK, "DirectSoundEnumerateA failed: %08x\n", hr); +} + +static void test_COM(void) +{ + IDirectSound *ds; + IDirectSound8 *ds8 = (IDirectSound8*)0xdeadbeef; + IUnknown *unk, *unk8; + ULONG refcount; + HRESULT hr; + + /* COM aggregation */ + hr = CoCreateInstance(&CLSID_DirectSound8, (IUnknown*)&ds, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void**)&ds8); + ok(hr == CLASS_E_NOAGGREGATION, + "DirectSound create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); + ok(!ds8, "ds8 = %p\n", ds8); + + /* Invalid RIID */ + hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectSound3DBuffer, (void**)&ds8); + ok(hr == E_NOINTERFACE, + "DirectSound create failed: %08x, expected E_NOINTERFACE\n", hr); + + /* Same refcount for IDirectSound and IDirectSound8 */ + hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound8, + (void**)&ds8); + ok(hr == S_OK, "DirectSound create failed: %08x, expected S_OK\n", hr); + refcount = IDirectSound8_AddRef(ds8); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + hr = IDirectSound8_QueryInterface(ds8, &IID_IDirectSound, (void**)&ds); + ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr); + refcount = IDirectSound8_AddRef(ds8); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + refcount = IDirectSound_AddRef(ds); + ok(refcount == 5, "refcount == %u, expected 5\n", refcount); + + /* Separate refcount for IUnknown */ + hr = IDirectSound_QueryInterface(ds, &IID_IUnknown, (void**)&unk); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + refcount = IUnknown_AddRef(unk); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + hr = IDirectSound_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + refcount = IUnknown_AddRef(unk8); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + refcount = IDirectSound_AddRef(ds); + ok(refcount == 6, "refcount == %u, expected 6\n", refcount); + + while (IDirectSound_Release(ds)); + while (IUnknown_Release(unk)); +} START_TEST(dsound8) { @@ -932,16 +1189,19 @@ "DirectSoundCreate8"); if (pDirectSoundCreate8) { + test_COM(); IDirectSound8_tests(); dsound8_tests(); + test_hw_buffers(); + test_first_device(); } else - skip("dsound8 test skipped\n"); + skip("DirectSoundCreate8 missing - skipping all tests\n"); FreeLibrary(hDsound); } else - skip("dsound.dll not found!\n"); + skip("dsound.dll not found - skipping all tests\n"); CoUninitialize(); } Modified: trunk/rostests/winetests/dsound/dsound_test.h URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/dsound_t…
============================================================================== --- trunk/rostests/winetests/dsound/dsound_test.h [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/dsound_test.h [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -17,6 +17,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ + +#include <wingdi.h> +#include <mmreg.h> +#include <mmsystem.h> static const unsigned int formats[][4]={ { 8000, 8, 1, 0 }, @@ -70,11 +74,14 @@ }; #define NB_FORMATS (sizeof(formats)/sizeof(*formats)) +static const unsigned int format_tags[] = {WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT}; +#define NB_TAGS (sizeof(format_tags)/sizeof(*format_tags)) + /* The time slice determines how often we will service the buffer */ #define TIME_SLICE 31 #define BUFFER_LEN 400 -extern char* wave_generate_la(WAVEFORMATEX*,double,DWORD*); +extern char* wave_generate_la(WAVEFORMATEX*,double,DWORD*,BOOL); extern HWND get_hwnd(void); extern void init_format(WAVEFORMATEX*,int,int,int,int); extern void test_buffer(LPDIRECTSOUND,LPDIRECTSOUNDBUFFER*, Modified: trunk/rostests/winetests/dsound/duplex.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/duplex.c…
============================================================================== --- trunk/rostests/winetests/dsound/duplex.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/duplex.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -18,14 +18,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> - -#include <stdio.h> - -#include "wine/test.h" -#include "dsound.h" -#include "mmreg.h" -#include "dsconf.h" +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define COBJMACROS +//#include <windows.h> +//#include <stdio.h> + +#include <wine/test.h> +#include <wingdi.h> +#include <mmreg.h> +#include <dsound.h> +#include <dsconf.h> #include "dsound_test.h" @@ -93,8 +98,9 @@ ok(rc==DS_OK,"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSoundFullDuplex) " "failed: %08x\n",rc); if (rc==DS_OK) { - ok (dsfdo==dsfd, "different interfaces\n"); + ok(dsfdo==dsfd, "different interfaces\n"); ref=IDirectSound8_Release(dsfd); + ok(ref==1, "IDirectSoundFullDuplex_Release() has %d references, should have 1\n", ref); } ref=IDirectSoundFullDuplex_Release(dsfdo); @@ -222,6 +228,117 @@ IDirectSoundFullDuplex_Release(dsfdo); } +static void test_COM(void) +{ + IDirectSoundFullDuplex *dsfd = (IDirectSoundFullDuplex*)0xdeadbeef; + IDirectSound *ds; + IDirectSound8 *ds8; + IDirectSoundCapture *dsc; + IUnknown *unk, *unk8; + IDirectSoundBuffer8 *dsb8; + IDirectSoundCaptureBuffer8 *dscb8; + DSBUFFERDESC bufdesc; + DSCBUFFERDESC cbufdesc; + WAVEFORMATEX wfx; + ULONG refcount; + HRESULT hr; + + /* COM aggregation */ + hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, (IUnknown*)&dsfd, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void**)&dsfd); + ok(hr == CLASS_E_NOAGGREGATION, + "DirectSoundFullDuplex create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); + ok(!dsfd, "dsfd = %p\n", dsfd); + + /* Invalid RIID */ + hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectSound3DBuffer, (void**)&dsfd); + ok(hr == E_NOINTERFACE, + "DirectSoundFullDuplex create failed: %08x, expected E_NOINTERFACE\n", hr); + + /* Different refcount for IDirectSoundFullDuplex and for IUnknown */ + hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectSoundFullDuplex, (void**)&dsfd); + ok(hr == S_OK, "DirectSoundFullDuplex create failed: %08x, expected S_OK\n", hr); + refcount = IDirectSoundFullDuplex_AddRef(dsfd); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IUnknown, (void**)&unk); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + refcount = IUnknown_AddRef(unk); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + + /* Not initialized */ + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8, (void**)&ds8); + ok(hr == E_NOINTERFACE, + "QueryInterface for IID_IDirectSound8 failed: %08x, expected E_NOINTERFACE\n", hr); + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture, (void**)&dsc); + ok(hr == E_NOINTERFACE, + "QueryInterface for IID_IDirectSoundCapture failed: %08x, expected E_NOINTERFACE\n", hr); + + init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1); + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize = sizeof(bufdesc); + bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; + bufdesc.lpwfxFormat = &wfx; + ZeroMemory(&cbufdesc, sizeof(cbufdesc)); + cbufdesc.dwSize = sizeof(cbufdesc); + cbufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; + cbufdesc.lpwfxFormat = &wfx; + hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc, get_hwnd(), + DSSCL_EXCLUSIVE, NULL, NULL); + ok(hr == E_INVALIDARG, + "IDirectSoundFullDuplex_Initialize failed: %08x, expected E_INVALIDARG\n", hr); + hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc, get_hwnd(), + DSSCL_EXCLUSIVE, &dscb8, &dsb8); + if (hr == DSERR_NODRIVER || hr == DSERR_INVALIDCALL) { + skip("No driver\n"); + return; + } + ok(hr == S_OK, "IDirectSoundFullDuplex_Initialize failed: %08x\n", hr); + + /* IDirectSound and IDirectSound8 */ + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8, (void**)&ds8); + ok(hr == S_OK, "QueryInterface for IID_IDirectSound8 failed: %08x\n", hr); + refcount = IDirectSound8_AddRef(ds8); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound, (void**)&ds); + ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr); + refcount = IDirectSound8_AddRef(ds8); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + refcount = IDirectSound_AddRef(ds); + ok(refcount == 5, "refcount == %u, expected 5\n", refcount); + hr = IDirectSound8_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + ok(unk == unk8, "Got different IUnknown when QI'ing IDirectSoundFullDuplex and IDirectSound\n"); + refcount = IUnknown_AddRef(unk8); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + refcount = IDirectSound_AddRef(ds); + ok(refcount == 6, "refcount == %u, expected 6\n", refcount); + refcount = IDirectSoundFullDuplex_AddRef(dsfd); + ok(refcount == 3, "refcount == %u, expected 3\n", refcount); + + /* IDirectSoundCapture */ + hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture, (void**)&dsc); + ok(hr == S_OK, "QueryInterface for IID_IDirectSoundCapture failed: %08x\n", hr); + refcount = IDirectSoundCapture_AddRef(dsc); + ok(refcount == 2, "refcount == %u, expected 2\n", refcount); + refcount = IDirectSoundFullDuplex_AddRef(dsfd); + ok(refcount == 4, "refcount == %u, expected 4\n", refcount); + hr = IDirectSoundCapture_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + ok(unk == unk8, + "Got different IUnknown when QI'ing IDirectSoundFullDuplex and IDirectSoundCapture\n"); + refcount = IUnknown_AddRef(unk8); + ok(refcount == 6, "refcount == %u, expected 6\n", refcount); + + IDirectSoundBuffer8_Release(dsb8); + IDirectSoundCaptureBuffer8_Release(dscb8); + while (IDirectSound8_Release(ds8)); + while (IDirectSoundCapture_Release(dsc)); + while (IDirectSoundFullDuplex_Release(dsfd)); + while (IUnknown_Release(unk)); +} + START_TEST(duplex) { HMODULE hDsound; @@ -234,15 +351,16 @@ pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound, "DirectSoundFullDuplexCreate"); - if (pDirectSoundFullDuplexCreate) + if (pDirectSoundFullDuplexCreate) { + test_COM(); IDirectSoundFullDuplex_tests(); - else - skip("duplex test skipped\n"); + } else + skip("DirectSoundFullDuplexCreate missing - skipping all tests\n"); FreeLibrary(hDsound); } else - skip("dsound.dll not found!\n"); + skip("dsound.dll not found - skipping all tests\n"); CoUninitialize(); } Modified: trunk/rostests/winetests/dsound/propset.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/propset.…
============================================================================== --- trunk/rostests/winetests/dsound/propset.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/propset.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -19,12 +19,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + #define COBJMACROS -#include <windows.h> - -#include "wine/test.h" -#include "dsound.h" -#include "dsconf.h" +//#include <windows.h> + +#include <wine/test.h> +#include <wingdi.h> +#include <winnls.h> +#include <mmreg.h> +#include <dsound.h> +#include <dsconf.h> #include "dsound_test.h" @@ -553,6 +560,8 @@ IKsPropertySet_Release(pps); } +static unsigned driver_count = 0; + static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) { @@ -564,6 +573,7 @@ int ref; trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule); + driver_count++; rc=pDirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL, @@ -616,8 +626,8 @@ trace(" Testing a secondary buffer at %dx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); - ok(rc==DS_OK&&secondary!=NULL,"IDirectSound_CreateSoundBuffer() " - "failed to create a secondary buffer: %08x\n",rc); + ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ + "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer: %08x\n",rc); if (rc==DS_OK&&secondary!=NULL) { IKsPropertySet * pPropertySet=NULL; rc=IDirectSoundBuffer_QueryInterface(secondary, @@ -710,6 +720,7 @@ HRESULT rc; rc=pDirectSoundEnumerateA(&dsenum_callback,NULL); ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc); + trace("tested %u DirectSound drivers\n", driver_count); } START_TEST(propset) @@ -743,7 +754,7 @@ FreeLibrary(hDsound); } else - skip("dsound.dll not found!\n"); + skip("dsound.dll not found - skipping all tests\n"); CoUninitialize(); } Modified: trunk/rostests/winetests/dsound/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/testlist…
============================================================================== --- trunk/rostests/winetests/dsound/testlist.c [iso-8859-1] (original) +++ trunk/rostests/winetests/dsound/testlist.c [iso-8859-1] Mon Sep 30 11:39:02 2013 @@ -1,10 +1,7 @@ /* Automatically generated file; DO NOT EDIT!! */ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - #define STANDALONE -#include "wine/test.h" +#include <wine/test.h> extern void func_capture(void); extern void func_ds3d8(void);
11 years, 2 months
1
0
0
0
[akhaldi] 60474: [DSOUND] * Sync with Wine 1.7.1. CORE-7469
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 30 11:38:41 2013 New Revision: 60474 URL:
http://svn.reactos.org/svn/reactos?rev=60474&view=rev
Log: [DSOUND] * Sync with Wine 1.7.1. CORE-7469 Modified: trunk/reactos/dll/directx/wine/dsound/CMakeLists.txt trunk/reactos/dll/directx/wine/dsound/capture.c trunk/reactos/dll/directx/wine/dsound/dsound.c trunk/reactos/dll/directx/wine/dsound/dsound_main.c trunk/reactos/dll/directx/wine/dsound/dsound_private.h trunk/reactos/dll/directx/wine/dsound/primary.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/directx/wine/dsound/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dsound/CM…
============================================================================== --- trunk/reactos/dll/directx/wine/dsound/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/directx/wine/dsound/CMakeLists.txt [iso-8859-1] Mon Sep 30 11:38:41 2013 @@ -5,7 +5,6 @@ -D__WINESRC__) include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) - spec2def(dsound.dll dsound.spec ADD_IMPORTLIB) add_library(dsound SHARED @@ -19,10 +18,9 @@ primary.c propset.c sound3d.c - version.rc ${CMAKE_CURRENT_BINARY_DIR}/dsound.def) -set_module_type(dsound win32dll) +set_module_type(dsound win32dll version.rc) target_link_libraries(dsound dxguid uuid wine) -add_importlibs(dsound winmm ole32 advapi32 user32 msvcrt kernel32 ntdll) +add_importlibs(dsound ole32 advapi32 user32 msvcrt kernel32 ntdll) add_cd_file(TARGET dsound DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/dll/directx/wine/dsound/capture.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dsound/ca…
============================================================================== --- trunk/reactos/dll/directx/wine/dsound/capture.c [iso-8859-1] (original) +++ trunk/reactos/dll/directx/wine/dsound/capture.c [iso-8859-1] Mon Sep 30 11:38:41 2013 @@ -62,6 +62,8 @@ /* IDirectSoundNotify fields */ DSBPOSITIONNOTIFY *notifies; int nrofnotifies; + HANDLE thread; + HANDLE sleepev; } IDirectSoundCaptureBufferImpl; /* DirectSoundCaptureDevice implementation structure */ @@ -75,7 +77,6 @@ WAVEFORMATEX *pwfx; IDirectSoundCaptureBufferImpl *capture_buffer; DWORD state; - UINT timerID; CRITICAL_SECTION lock; IMMDevice *mmdevice; IAudioClient *client; @@ -83,11 +84,19 @@ struct list entry; }; +static DWORD WINAPI DSOUND_capture_thread(void *user); static void capturebuffer_destroy(IDirectSoundCaptureBufferImpl *This) { if (This->device->state == STATE_CAPTURING) This->device->state = STATE_STOPPING; + + if(This->thread){ + SetEvent(This->sleepev); + WaitForSingleObject(This->thread, INFINITE); + CloseHandle(This->thread); + } + CloseHandle(This->sleepev); HeapFree(GetProcessHeap(),0, This->pdscbd); @@ -742,8 +751,8 @@ } err = IAudioClient_Initialize(device->client, - AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_NOPERSIST, - 200 * 100000, 50000, device->pwfx, NULL); + AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_NOPERSIST | AUDCLNT_STREAMFLAGS_EVENTCALLBACK, + 200 * 100000, 0, device->pwfx, NULL); if(FAILED(err)){ WARN("Initialize failed: %08x\n", err); IAudioClient_Release(device->client); @@ -756,12 +765,27 @@ return err; } + This->sleepev = CreateEventW(NULL, 0, 0, NULL); + + err = IAudioClient_SetEventHandle(device->client, This->sleepev); + if(FAILED(err)){ + WARN("SetEventHandle failed: %08x\n", err); + IAudioClient_Release(device->client); + device->client = NULL; + CloseHandle(This->sleepev); + HeapFree(GetProcessHeap(), 0, This->pdscbd); + This->device->capture_buffer = 0; + HeapFree( GetProcessHeap(), 0, This ); + return err; + } + err = IAudioClient_GetService(device->client, &IID_IAudioCaptureClient, (void**)&device->capture); if(FAILED(err)){ WARN("GetService failed: %08x\n", err); IAudioClient_Release(device->client); device->client = NULL; + CloseHandle(This->sleepev); HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); @@ -779,6 +803,7 @@ device->client = NULL; IAudioCaptureClient_Release(device->capture); device->capture = NULL; + CloseHandle(This->sleepev); HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); @@ -786,6 +811,7 @@ } device->buffer = newbuf; device->buflen = buflen; + This->thread = CreateThread(NULL, 0, DSOUND_capture_thread, This, 0, NULL); } IDirectSoundCaptureBuffer_AddRef(&This->IDirectSoundCaptureBuffer8_iface); @@ -832,9 +858,6 @@ if (!ref) { TRACE("deleting object\n"); - - timeKillEvent(device->timerID); - timeEndPeriod(DS_TIME_RES); EnterCriticalSection(&DSOUND_capturers_lock); list_remove(&device->entry); @@ -854,29 +877,19 @@ return ref; } -static void CALLBACK DSOUND_capture_timer(UINT timerID, UINT msg, DWORD_PTR user, - DWORD_PTR dw1, DWORD_PTR dw2) -{ - DirectSoundCaptureDevice *device = (DirectSoundCaptureDevice*)user; - UINT32 packet_frames, packet_bytes, avail_bytes; +static HRESULT DSOUND_capture_data(DirectSoundCaptureDevice *device) +{ + HRESULT hr; + UINT32 packet_frames, packet_bytes, avail_bytes, skip_bytes = 0; DWORD flags; BYTE *buf; - HRESULT hr; - - if(!device->ref) - return; - - EnterCriticalSection(&device->lock); - - if(!device->capture_buffer || device->state == STATE_STOPPED){ - LeaveCriticalSection(&device->lock); - return; - } + + if(!device->capture_buffer || device->state == STATE_STOPPED) + return S_FALSE; if(device->state == STATE_STOPPING){ device->state = STATE_STOPPED; - LeaveCriticalSection(&device->lock); - return; + return S_FALSE; } if(device->state == STATE_STARTING) @@ -885,24 +898,28 @@ hr = IAudioCaptureClient_GetBuffer(device->capture, &buf, &packet_frames, &flags, NULL, NULL); if(FAILED(hr)){ - LeaveCriticalSection(&device->lock); WARN("GetBuffer failed: %08x\n", hr); - return; + return hr; } packet_bytes = packet_frames * device->pwfx->nBlockAlign; + if(packet_bytes > device->buflen){ + TRACE("audio glitch: dsound buffer too small for data\n"); + skip_bytes = packet_bytes - device->buflen; + packet_bytes = device->buflen; + } avail_bytes = device->buflen - device->write_pos_bytes; if(avail_bytes > packet_bytes) avail_bytes = packet_bytes; - memcpy(device->buffer + device->write_pos_bytes, buf, avail_bytes); + memcpy(device->buffer + device->write_pos_bytes, buf + skip_bytes, avail_bytes); capture_CheckNotify(device->capture_buffer, device->write_pos_bytes, avail_bytes); packet_bytes -= avail_bytes; if(packet_bytes > 0){ if(device->capture_buffer->flags & DSCBSTART_LOOPING){ - memcpy(device->buffer, buf + avail_bytes, packet_bytes); + memcpy(device->buffer, buf + skip_bytes + avail_bytes, packet_bytes); capture_CheckNotify(device->capture_buffer, 0, packet_bytes); }else{ device->state = STATE_STOPPED; @@ -915,12 +932,44 @@ hr = IAudioCaptureClient_ReleaseBuffer(device->capture, packet_frames); if(FAILED(hr)){ - LeaveCriticalSection(&device->lock); WARN("ReleaseBuffer failed: %08x\n", hr); - return; - } - - LeaveCriticalSection(&device->lock); + return hr; + } + + return S_OK; +} + +static DWORD WINAPI DSOUND_capture_thread(void *user) +{ + IDirectSoundCaptureBufferImpl *buffer = user; + HRESULT hr; + DWORD ret, wait_ms; + REFERENCE_TIME period; + + hr = IAudioClient_GetDevicePeriod(buffer->device->client, &period, NULL); + if(FAILED(hr)){ + WARN("GetDevicePeriod failed: %08x\n", hr); + wait_ms = 5; + }else + wait_ms = MulDiv(5, period, 10000); + + while(buffer->ref){ + ret = WaitForSingleObject(buffer->sleepev, wait_ms); + + if(!buffer->device->ref) + break; + + if(ret == WAIT_OBJECT_0){ + EnterCriticalSection(&buffer->device->lock); + + DSOUND_capture_data(buffer->device); + + LeaveCriticalSection(&buffer->device->lock); + }else if(ret != WAIT_TIMEOUT) + WARN("WaitForSingleObject failed: %u\n", GetLastError()); + } + + return 0; } static struct _TestFormat { @@ -984,14 +1033,6 @@ EnterCriticalSection(&DSOUND_capturers_lock); - LIST_FOR_EACH_ENTRY(device, &DSOUND_capturers, DirectSoundCaptureDevice, entry){ - if(IsEqualGUID(&device->guid, &devGUID)){ - IMMDevice_Release(mmdevice); - LeaveCriticalSection(&DSOUND_capturers_lock); - return DSERR_ALLOCATED; - } - } - hr = DirectSoundCaptureDevice_Create(&device); if (hr != DS_OK) { WARN("DirectSoundCaptureDevice_Create failed\n"); @@ -1025,8 +1066,6 @@ } } IAudioClient_Release(client); - - device->timerID = DSOUND_create_timer(DSOUND_capture_timer, (DWORD_PTR)device); list_add_tail(&DSOUND_capturers, &device->entry); Modified: trunk/reactos/dll/directx/wine/dsound/dsound.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dsound/ds…
============================================================================== --- trunk/reactos/dll/directx/wine/dsound/dsound.c [iso-8859-1] (original) +++ trunk/reactos/dll/directx/wine/dsound/dsound.c [iso-8859-1] Mon Sep 30 11:38:41 2013 @@ -738,30 +738,6 @@ return hr == S_OK; } -UINT DSOUND_create_timer(LPTIMECALLBACK cb, DWORD_PTR user) -{ - UINT triggertime = DS_TIME_DEL, res = DS_TIME_RES, id; - TIMECAPS time; - - timeGetDevCaps(&time, sizeof(TIMECAPS)); - TRACE("Minimum timer resolution: %u, max timer: %u\n", time.wPeriodMin, time.wPeriodMax); - if (triggertime < time.wPeriodMin) - triggertime = time.wPeriodMin; - if (res < time.wPeriodMin) - res = time.wPeriodMin; - if (timeBeginPeriod(res) == TIMERR_NOCANDO) - WARN("Could not set minimum resolution, don't expect sound\n"); - id = timeSetEvent(triggertime, res, cb, user, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS); - if (!id) - { - WARN("Timer not created! Retrying without TIME_KILL_SYNCHRONOUS\n"); - id = timeSetEvent(triggertime, res, cb, user, TIME_PERIODIC); - if (!id) - ERR("Could not create timer, sound playback will not occur\n"); - } - return id; -} - HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcGUID) { HRESULT hr = DS_OK; Modified: trunk/reactos/dll/directx/wine/dsound/dsound_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dsound/ds…
============================================================================== --- trunk/reactos/dll/directx/wine/dsound/dsound_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/directx/wine/dsound/dsound_main.c [iso-8859-1] Mon Sep 30 11:38:41 2013 @@ -800,20 +800,16 @@ switch (fdwReason) { case DLL_PROCESS_ATTACH: - TRACE("DLL_PROCESS_ATTACH\n"); instance = hInstDLL; DisableThreadLibraryCalls(hInstDLL); /* Increase refcount on dsound by 1 */ GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)hInstDLL, &hInstDLL); break; case DLL_PROCESS_DETACH: - TRACE("DLL_PROCESS_DETACH\n"); + if (lpvReserved) break; DeleteCriticalSection(&DSOUND_renderers_lock); DeleteCriticalSection(&DSOUND_capturers_lock); break; - default: - TRACE("UNKNOWN REASON\n"); - break; } return TRUE; } Modified: trunk/reactos/dll/directx/wine/dsound/dsound_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dsound/ds…
============================================================================== --- trunk/reactos/dll/directx/wine/dsound/dsound_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/directx/wine/dsound/dsound_private.h [iso-8859-1] Mon Sep 30 11:38:41 2013 @@ -261,6 +261,5 @@ BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate, DWORD depth, WORD channels) DECLSPEC_HIDDEN; -UINT DSOUND_create_timer(LPTIMECALLBACK cb, DWORD_PTR user) DECLSPEC_HIDDEN; HRESULT enumerate_mmdevices(EDataFlow flow, GUID *guids, LPDSENUMCALLBACKW cb, void *user) DECLSPEC_HIDDEN; Modified: trunk/reactos/dll/directx/wine/dsound/primary.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dsound/pr…
============================================================================== --- trunk/reactos/dll/directx/wine/dsound/primary.c [iso-8859-1] (original) +++ trunk/reactos/dll/directx/wine/dsound/primary.c [iso-8859-1] Mon Sep 30 11:38:41 2013 @@ -443,35 +443,24 @@ return DS_OK; } -static DWORD DSOUND_GetFormatSize(LPCWAVEFORMATEX wfex) -{ - if (wfex->wFormatTag == WAVE_FORMAT_PCM) - return sizeof(WAVEFORMATEX); - else - return sizeof(WAVEFORMATEX) + wfex->cbSize; -} - -LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) -{ - DWORD size = DSOUND_GetFormatSize(wfex); - LPWAVEFORMATEX pwfx = HeapAlloc(GetProcessHeap(),0,size); - if (pwfx == NULL) { - WARN("out of memory\n"); - } else if (wfex->wFormatTag != WAVE_FORMAT_PCM) { - CopyMemory(pwfx, wfex, size); - } else { - CopyMemory(pwfx, wfex, sizeof(PCMWAVEFORMAT)); - pwfx->cbSize=0; - if (pwfx->nBlockAlign != pwfx->nChannels * pwfx->wBitsPerSample/8) { - WARN("Fixing bad nBlockAlign (%u)\n", pwfx->nBlockAlign); - pwfx->nBlockAlign = pwfx->nChannels * pwfx->wBitsPerSample/8; - } - if (pwfx->nAvgBytesPerSec != pwfx->nSamplesPerSec * pwfx->nBlockAlign) { - WARN("Fixing bad nAvgBytesPerSec (%u)\n", pwfx->nAvgBytesPerSec); - pwfx->nAvgBytesPerSec = pwfx->nSamplesPerSec * pwfx->nBlockAlign; - } - } - return pwfx; +WAVEFORMATEX *DSOUND_CopyFormat(const WAVEFORMATEX *wfex) +{ + WAVEFORMATEX *pwfx; + if(wfex->wFormatTag == WAVE_FORMAT_PCM){ + pwfx = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEFORMATEX)); + CopyMemory(pwfx, wfex, sizeof(PCMWAVEFORMAT)); + pwfx->cbSize = 0; + }else{ + pwfx = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEFORMATEX) + wfex->cbSize); + CopyMemory(pwfx, wfex, sizeof(WAVEFORMATEX) + wfex->cbSize); + } + + if(pwfx->wFormatTag == WAVE_FORMAT_PCM || + (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE && + IsEqualGUID(&((const WAVEFORMATEXTENSIBLE*)pwfx)->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))) + pwfx->nBlockAlign = (pwfx->nChannels * pwfx->wBitsPerSample) / 8; + + return pwfx; } HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX passed_fmt) @@ -548,27 +537,9 @@ device->primary_pwfx = old_fmt; else HeapFree(GetProcessHeap(), 0, old_fmt); - } else if (passed_fmt->wFormatTag == WAVE_FORMAT_PCM || - passed_fmt->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) { - /* Fill in "real" values to primary_pwfx */ - WAVEFORMATEX *fmt = device->primary_pwfx; - - *fmt = *device->pwfx; - fmtex = (void*)device->pwfx; - - if (IsEqualGUID(&fmtex->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT) && - passed_fmt->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) { - fmt->wFormatTag = WAVE_FORMAT_IEEE_FLOAT; - } else { - fmt->wFormatTag = WAVE_FORMAT_PCM; - fmt->wBitsPerSample = 16; - } - fmt->nBlockAlign = fmt->nChannels * fmt->wBitsPerSample / 8; - fmt->nAvgBytesPerSec = fmt->nBlockAlign * fmt->nSamplesPerSec; - fmt->cbSize = 0; } else { - device->primary_pwfx = HeapReAlloc(GetProcessHeap(), 0, device->primary_pwfx, sizeof(*fmtex)); - memcpy(device->primary_pwfx, device->pwfx, sizeof(*fmtex)); + HeapFree(GetProcessHeap(), 0, device->primary_pwfx); + device->primary_pwfx = DSOUND_CopyFormat(passed_fmt); } out: Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Mon Sep 30 11:38:41 2013 @@ -39,7 +39,7 @@ reactos/dll/directx/wine/dmusic # Synced to Wine-1.5.26 reactos/dll/directx/wine/dplay # Synced to Wine-1.5.26 reactos/dll/directx/wine/dplayx # Synced to Wine-1.5.26 -reactos/dll/directx/wine/dsound # Synced to Wine-1.5.26 +reactos/dll/directx/wine/dsound # Synced to Wine-1.7.1 reactos/dll/directx/wine/dxdiagn # Synced to Wine-0_9_5 reactos/dll/directx/wine/dxgi # Synced to Wine-1.7.1 reactos/dll/directx/wine/msdmo # Autosync
11 years, 2 months
1
0
0
0
[spetreolle] 60473: [PSAPI_WINETEST] Don't forget brackets on Monday, thanks Pierre :)
by spetreolle@svn.reactos.org
Author: spetreolle Date: Mon Sep 30 08:54:02 2013 New Revision: 60473 URL:
http://svn.reactos.org/svn/reactos?rev=60473&view=rev
Log: [PSAPI_WINETEST] Don't forget brackets on Monday, thanks Pierre :) Modified: trunk/rostests/winetests/psapi/psapi_main.c Modified: trunk/rostests/winetests/psapi/psapi_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/psapi/psapi_mai…
============================================================================== --- trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] (original) +++ trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] Mon Sep 30 08:54:02 2013 @@ -106,8 +106,10 @@ DWORD ret, cbNeeded = 0xdeadbeef; if(!winetest_interactive) - win_skip("Stack corruption - ROSTEST-122\n"); - return; + { + win_skip("Stack corruption - ROSTEST-122\n"); + return; + } SetLastError(0xdeadbeef); pEnumProcessModules(NULL, NULL, 0, &cbNeeded);
11 years, 2 months
1
0
0
0
[spetreolle] 60472: [PSAPI_WINETEST] * Amine, don't deny the user's rights to run disabled tests on demand.
by spetreolle@svn.reactos.org
Author: spetreolle Date: Mon Sep 30 08:46:05 2013 New Revision: 60472 URL:
http://svn.reactos.org/svn/reactos?rev=60472&view=rev
Log: [PSAPI_WINETEST] * Amine, don't deny the user's rights to run disabled tests on demand. Modified: trunk/rostests/winetests/psapi/psapi_main.c Modified: trunk/rostests/winetests/psapi/psapi_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/psapi/psapi_mai…
============================================================================== --- trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] (original) +++ trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] Mon Sep 30 08:46:05 2013 @@ -105,6 +105,7 @@ HMODULE hMod = GetModuleHandle(NULL); DWORD ret, cbNeeded = 0xdeadbeef; + if(!winetest_interactive) win_skip("Stack corruption - ROSTEST-122\n"); return;
11 years, 2 months
1
0
0
0
[akhaldi] 60471: [PSAPI_WINETEST] * Fix MSVC build. * Speedup build. * Pierre, can you please consult with me before stepping on my toes (with improper syncs) ?
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 30 08:10:07 2013 New Revision: 60471 URL:
http://svn.reactos.org/svn/reactos?rev=60471&view=rev
Log: [PSAPI_WINETEST] * Fix MSVC build. * Speedup build. * Pierre, can you please consult with me before stepping on my toes (with improper syncs) ? Modified: trunk/rostests/winetests/psapi/CMakeLists.txt trunk/rostests/winetests/psapi/psapi_main.c trunk/rostests/winetests/psapi/testlist.c Modified: trunk/rostests/winetests/psapi/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/psapi/CMakeList…
============================================================================== --- trunk/rostests/winetests/psapi/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/psapi/CMakeLists.txt [iso-8859-1] Mon Sep 30 08:10:07 2013 @@ -1,10 +1,5 @@ - -add_definitions( - -D__ROS_LONG64__ - -D_DLL -D__USE_CRTIMP) add_executable(psapi_winetest psapi_main.c testlist.c) -target_link_libraries(psapi_winetest wine) set_module_type(psapi_winetest win32cui) -add_importlibs(psapi_winetest psapi msvcrt kernel32 ntdll) +add_importlibs(psapi_winetest msvcrt kernel32) add_cd_file(TARGET psapi_winetest DESTINATION reactos/bin FOR all) Modified: trunk/rostests/winetests/psapi/psapi_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/psapi/psapi_mai…
============================================================================== --- trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] (original) +++ trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] Mon Sep 30 08:10:07 2013 @@ -102,11 +102,11 @@ static void test_EnumProcessModules(void) { + HMODULE hMod = GetModuleHandle(NULL); + DWORD ret, cbNeeded = 0xdeadbeef; + win_skip("Stack corruption - ROSTEST-122\n"); return; - - HMODULE hMod = GetModuleHandle(NULL); - DWORD ret, cbNeeded = 0xdeadbeef; SetLastError(0xdeadbeef); pEnumProcessModules(NULL, NULL, 0, &cbNeeded); Modified: trunk/rostests/winetests/psapi/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/psapi/testlist.…
============================================================================== --- trunk/rostests/winetests/psapi/testlist.c [iso-8859-1] (original) +++ trunk/rostests/winetests/psapi/testlist.c [iso-8859-1] Mon Sep 30 08:10:07 2013 @@ -1,10 +1,7 @@ /* Automatically generated file; DO NOT EDIT!! */ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - #define STANDALONE -#include "wine/test.h" +#include <wine/test.h> extern void func_psapi_main(void);
11 years, 2 months
1
0
0
0
[pschweitzer] 60470: [PSAPI_WINETEST] Sync with Wine 1.7.1 CORE-7469 Tests for EnumProcessModules() have been skipped since they cause stack corruption ROSTESTS-122
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Mon Sep 30 06:27:03 2013 New Revision: 60470 URL:
http://svn.reactos.org/svn/reactos?rev=60470&view=rev
Log: [PSAPI_WINETEST] Sync with Wine 1.7.1 CORE-7469 Tests for EnumProcessModules() have been skipped since they cause stack corruption ROSTESTS-122 Modified: trunk/rostests/winetests/psapi/psapi_main.c Modified: trunk/rostests/winetests/psapi/psapi_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/psapi/psapi_mai…
============================================================================== --- trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] (original) +++ trunk/rostests/winetests/psapi/psapi_main.c [iso-8859-1] Mon Sep 30 06:27:03 2013 @@ -2,6 +2,7 @@ * Unit test suite for PSAPI * * Copyright (C) 2005 Felix Nawothnig + * Copyright (C) 2012 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,18 +20,18 @@ */ #include <stdarg.h> -#include <stdio.h> - -#include "windows.h" + +#include "ntstatus.h" +#define WIN32_NO_STATUS + +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "winnt.h" +#include "winternl.h" +#include "winnls.h" +#include "psapi.h" #include "wine/test.h" -#include "psapi.h" - -#define expect_eq_d(expected, actual) \ - do { \ - int value = (actual); \ - ok((expected) == value, "Expected " #actual " to be %d (" #expected ") is %d\n", \ - (expected), value); \ - } while (0) #define PSAPI_GET_PROC(func) \ p ## func = (void*)GetProcAddress(hpsapi, #func); \ @@ -40,41 +41,22 @@ return FALSE; \ } -/* All PSAPI functions return non-zero and call SetLastError() - * on failure so we can use some macros for convenience */ - -#define w32_suc(x) \ - (SetLastError(0xdeadbeef), \ - (x) \ - ? (ok(1, "succeeded\n"), 1) \ - : GetLastError() == 0xdeadbeef \ - ? (ok(0, "failed without error code\n"), 0) \ - : (ok(0, "failed with %d\n", GetLastError()), 0)) - -#define w32_err(x, e) \ - (SetLastError(0xdeadbeef), \ - (x) \ - ? (ok(0, "expected error=%d but succeeded\n", e), 0) \ - : GetLastError() == e \ - ? (ok(1, "failed with %d\n", e), 1) \ - : GetLastError() == 0xdeadbeef \ - ? (ok(0, "failed without error code\n"), 0) \ - : (ok(0, "expected error=%d but failed with %d\n", \ - e, GetLastError()), 0)) - static BOOL (WINAPI *pEmptyWorkingSet)(HANDLE); static BOOL (WINAPI *pEnumProcesses)(DWORD*, DWORD, DWORD*); static BOOL (WINAPI *pEnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD); static DWORD (WINAPI *pGetModuleBaseNameA)(HANDLE, HMODULE, LPSTR, DWORD); static DWORD (WINAPI *pGetModuleFileNameExA)(HANDLE, HMODULE, LPSTR, DWORD); +static DWORD (WINAPI *pGetModuleFileNameExW)(HANDLE, HMODULE, LPWSTR, DWORD); static BOOL (WINAPI *pGetModuleInformation)(HANDLE, HMODULE, LPMODULEINFO, DWORD); static DWORD (WINAPI *pGetMappedFileNameA)(HANDLE, LPVOID, LPSTR, DWORD); +static DWORD (WINAPI *pGetMappedFileNameW)(HANDLE, LPVOID, LPWSTR, DWORD); static DWORD (WINAPI *pGetProcessImageFileNameA)(HANDLE, LPSTR, DWORD); static DWORD (WINAPI *pGetProcessImageFileNameW)(HANDLE, LPWSTR, DWORD); static BOOL (WINAPI *pGetProcessMemoryInfo)(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD); static BOOL (WINAPI *pGetWsChanges)(HANDLE, PPSAPI_WS_WATCH_INFORMATION, DWORD); static BOOL (WINAPI *pInitializeProcessForWsWatch)(HANDLE); static BOOL (WINAPI *pQueryWorkingSet)(HANDLE, PVOID, DWORD); +static NTSTATUS (WINAPI *pNtQueryVirtualMemory)(HANDLE, LPCVOID, ULONG, PVOID, SIZE_T, SIZE_T *); static BOOL InitFunctionPtrs(HMODULE hpsapi) { @@ -83,8 +65,10 @@ PSAPI_GET_PROC(EnumProcesses); PSAPI_GET_PROC(GetModuleBaseNameA); PSAPI_GET_PROC(GetModuleFileNameExA); + PSAPI_GET_PROC(GetModuleFileNameExW); PSAPI_GET_PROC(GetModuleInformation); PSAPI_GET_PROC(GetMappedFileNameA); + PSAPI_GET_PROC(GetMappedFileNameW); PSAPI_GET_PROC(GetProcessMemoryInfo); PSAPI_GET_PROC(GetWsChanges); PSAPI_GET_PROC(InitializeProcessForWsWatch); @@ -94,6 +78,7 @@ (void *)GetProcAddress(hpsapi, "GetProcessImageFileNameA"); pGetProcessImageFileNameW = (void *)GetProcAddress(hpsapi, "GetProcessImageFileNameW"); + pNtQueryVirtualMemory = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQueryVirtualMemory"); return TRUE; } @@ -102,51 +87,162 @@ static void test_EnumProcesses(void) { - DWORD pid, cbUsed = 0xdeadbeef; - - if(w32_suc(pEnumProcesses(NULL, 0, &cbUsed))) - ok(cbUsed == 0, "cbUsed=%d\n", cbUsed); - if(w32_suc(pEnumProcesses(&pid, 4, &cbUsed))) - ok(cbUsed == 4, "cbUsed=%d\n", cbUsed); + DWORD pid, ret, cbUsed = 0xdeadbeef; + + SetLastError(0xdeadbeef); + ret = pEnumProcesses(NULL, 0, &cbUsed); + ok(ret == 1, "failed with %d\n", GetLastError()); + ok(cbUsed == 0, "cbUsed=%d\n", cbUsed); + + SetLastError(0xdeadbeef); + ret = pEnumProcesses(&pid, 4, &cbUsed); + ok(ret == 1, "failed with %d\n", GetLastError()); + ok(cbUsed == 4, "cbUsed=%d\n", cbUsed); } static void test_EnumProcessModules(void) { + win_skip("Stack corruption - ROSTEST-122\n"); + return; + HMODULE hMod = GetModuleHandle(NULL); - DWORD cbNeeded = 0xdeadbeef; - - w32_err(pEnumProcessModules(NULL, NULL, 0, &cbNeeded), ERROR_INVALID_HANDLE); - w32_err(pEnumProcessModules(hpQI, NULL, 0, &cbNeeded), ERROR_ACCESS_DENIED); - w32_suc(pEnumProcessModules(hpQV, NULL, 0, &cbNeeded)); - if(!w32_suc(pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), &cbNeeded))) + DWORD ret, cbNeeded = 0xdeadbeef; + + SetLastError(0xdeadbeef); + pEnumProcessModules(NULL, NULL, 0, &cbNeeded); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pEnumProcessModules(hpQI, NULL, 0, &cbNeeded); + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pEnumProcessModules(hpQI, &hMod, sizeof(HMODULE), NULL); + ok(!ret, "succeeded\n"); + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), NULL); + ok(!ret, "succeeded\n"); + ok(GetLastError() == ERROR_NOACCESS, "expected error=ERROR_NOACCESS but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pEnumProcessModules(hpQV, NULL, 0, &cbNeeded); + ok(ret == 1, "failed with %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), &cbNeeded); + if(ret != 1) return; - ok(cbNeeded / sizeof(HMODULE) >= 3 && cbNeeded / sizeof(HMODULE) <= 5 * sizeof(HMODULE), - "cbNeeded=%d\n", cbNeeded); ok(hMod == GetModuleHandle(NULL), "hMod=%p GetModuleHandle(NULL)=%p\n", hMod, GetModuleHandle(NULL)); + ok(cbNeeded % sizeof(hMod) == 0, "not a multiple of sizeof(HMODULE) cbNeeded=%d\n", cbNeeded); + /* Windows sometimes has a bunch of extra dlls, presumably brought in by + * aclayers.dll. + */ + if (cbNeeded < 4 * sizeof(HMODULE) || cbNeeded > 30 * sizeof(HMODULE)) + { + HMODULE hmods[100]; + int i; + ok(0, "cbNeeded=%d\n", cbNeeded); + + pEnumProcessModules(hpQV, hmods, sizeof(hmods), &cbNeeded); + for (i = 0 ; i < cbNeeded/sizeof(*hmods); i++) + { + char path[1024]; + GetModuleFileNameA(hmods[i], path, sizeof(path)); + trace("i=%d hmod=%p path=[%s]\n", i, hmods[i], path); + } + } } static void test_GetModuleInformation(void) { HMODULE hMod = GetModuleHandle(NULL); MODULEINFO info; - - w32_err(pGetModuleInformation(NULL, hMod, &info, sizeof(info)), ERROR_INVALID_HANDLE); - w32_err(pGetModuleInformation(hpQI, hMod, &info, sizeof(info)), ERROR_ACCESS_DENIED); - w32_err(pGetModuleInformation(hpQV, hBad, &info, sizeof(info)), ERROR_INVALID_HANDLE); - w32_err(pGetModuleInformation(hpQV, hMod, &info, sizeof(info)-1), ERROR_INSUFFICIENT_BUFFER); - if(w32_suc(pGetModuleInformation(hpQV, hMod, &info, sizeof(info)))) - ok(info.lpBaseOfDll == hMod, "lpBaseOfDll=%p hMod=%p\n", info.lpBaseOfDll, hMod); + DWORD ret; + + SetLastError(0xdeadbeef); + pGetModuleInformation(NULL, hMod, &info, sizeof(info)); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetModuleInformation(hpQI, hMod, &info, sizeof(info)); + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetModuleInformation(hpQV, hBad, &info, sizeof(info)); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetModuleInformation(hpQV, hMod, &info, sizeof(info)-1); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetModuleInformation(hpQV, hMod, &info, sizeof(info)); + ok(ret == 1, "failed with %d\n", GetLastError()); + ok(info.lpBaseOfDll == hMod, "lpBaseOfDll=%p hMod=%p\n", info.lpBaseOfDll, hMod); } static void test_GetProcessMemoryInfo(void) { PROCESS_MEMORY_COUNTERS pmc; - - w32_err(pGetProcessMemoryInfo(NULL, &pmc, sizeof(pmc)), ERROR_INVALID_HANDLE); - todo_wine w32_err(pGetProcessMemoryInfo(hpSR, &pmc, sizeof(pmc)), ERROR_ACCESS_DENIED); - w32_err(pGetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc)-1), ERROR_INSUFFICIENT_BUFFER); - w32_suc(pGetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc))); + DWORD ret; + + SetLastError(0xdeadbeef); + ret = pGetProcessMemoryInfo(NULL, &pmc, sizeof(pmc)); + ok(!ret, "GetProcessMemoryInfo should fail\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetProcessMemoryInfo(hpSR, &pmc, sizeof(pmc)); +todo_wine + ok(!ret, "GetProcessMemoryInfo should fail\n"); +todo_wine + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc)-1); + ok(!ret, "GetProcessMemoryInfo should fail\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc)); + ok(ret == 1, "failed with %d\n", GetLastError()); +} + +static BOOL nt_get_mapped_file_name(HANDLE process, LPVOID addr, LPWSTR name, DWORD len) +{ + MEMORY_SECTION_NAME *section_name; + WCHAR *buf; + SIZE_T buf_len, ret_len; + NTSTATUS status; + + if (!pNtQueryVirtualMemory) return FALSE; + + buf_len = len * sizeof(WCHAR) + sizeof(MEMORY_SECTION_NAME); + buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf_len); + + ret_len = 0xdeadbeef; + status = pNtQueryVirtualMemory(process, addr, MemorySectionName, buf, buf_len, &ret_len); +todo_wine + ok(!status, "NtQueryVirtualMemory error %x\n", status); + /* FIXME: remove once Wine is fixed */ + if (status) return FALSE; + + section_name = (MEMORY_SECTION_NAME *)buf; + ok(ret_len == section_name->SectionFileName.MaximumLength + sizeof(*section_name), "got %lu, %u\n", + ret_len, section_name->SectionFileName.MaximumLength); + ok((char *)section_name->SectionFileName.Buffer == (char *)section_name + sizeof(*section_name), "got %p, %p\n", + section_name, section_name->SectionFileName.Buffer); + ok(section_name->SectionFileName.MaximumLength == section_name->SectionFileName.Length + sizeof(WCHAR), "got %u, %u\n", + section_name->SectionFileName.MaximumLength, section_name->SectionFileName.Length); + ok(section_name->SectionFileName.Length == lstrlenW(section_name->SectionFileName.Buffer) * sizeof(WCHAR), "got %u, %u\n", + section_name->SectionFileName.Length, lstrlenW(section_name->SectionFileName.Buffer)); + + memcpy(name, section_name->SectionFileName.Buffer, section_name->SectionFileName.MaximumLength); + HeapFree(GetProcessHeap(), 0, buf); + return TRUE; } static void test_GetMappedFileName(void) @@ -154,26 +250,156 @@ HMODULE hMod = GetModuleHandle(NULL); char szMapPath[MAX_PATH], szModPath[MAX_PATH], *szMapBaseName; DWORD ret; - - w32_err(pGetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath)), ERROR_INVALID_HANDLE); - w32_err(pGetMappedFileNameA(hpSR, hMod, szMapPath, sizeof(szMapPath)), ERROR_ACCESS_DENIED); + char *base; + char temp_path[MAX_PATH], file_name[MAX_PATH], map_name[MAX_PATH], device_name[MAX_PATH], drive[3]; + WCHAR map_nameW[MAX_PATH], nt_map_name[MAX_PATH]; + HANDLE hfile, hmap; + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath)); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(hpSR, hMod, szMapPath, sizeof(szMapPath)); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); SetLastError( 0xdeadbeef ); ret = pGetMappedFileNameA(hpQI, hMod, szMapPath, sizeof(szMapPath)); +todo_wine ok( ret || broken(GetLastError() == ERROR_UNEXP_NET_ERR), /* win2k */ "GetMappedFileNameA failed with error %u\n", GetLastError() ); - if (!ret) return; - ok(ret == strlen(szMapPath), "szMapPath=\"%s\" ret=%d\n", szMapPath, ret); - ok(szMapPath[0] == '\\', "szMapPath=\"%s\"\n", szMapPath); - szMapBaseName = strrchr(szMapPath, '\\'); /* That's close enough for us */ - if(!szMapBaseName || !*szMapBaseName) - { - ok(0, "szMapPath=\"%s\"\n", szMapPath); - return; - } - GetModuleFileNameA(NULL, szModPath, sizeof(szModPath)); - ok(!strcmp(strrchr(szModPath, '\\'), szMapBaseName), - "szModPath=\"%s\" szMapBaseName=\"%s\"\n", szModPath, szMapBaseName); + if (ret) + { + ok(ret == strlen(szMapPath), "szMapPath=\"%s\" ret=%d\n", szMapPath, ret); + todo_wine + ok(szMapPath[0] == '\\', "szMapPath=\"%s\"\n", szMapPath); + szMapBaseName = strrchr(szMapPath, '\\'); /* That's close enough for us */ + todo_wine + ok(szMapBaseName && *szMapBaseName, "szMapPath=\"%s\"\n", szMapPath); + if (szMapBaseName) + { + GetModuleFileNameA(NULL, szModPath, sizeof(szModPath)); + ok(!strcmp(strrchr(szModPath, '\\'), szMapBaseName), + "szModPath=\"%s\" szMapBaseName=\"%s\"\n", szModPath, szMapBaseName); + } + } + + GetTempPath(MAX_PATH, temp_path); + GetTempFileName(temp_path, "map", 0, file_name); + + drive[0] = file_name[0]; + drive[1] = ':'; + drive[2] = 0; + SetLastError(0xdeadbeef); + ret = QueryDosDevice(drive, device_name, sizeof(device_name)); + ok(ret, "QueryDosDevice error %d\n", GetLastError()); + trace("%s -> %s\n", drive, device_name); + + SetLastError(0xdeadbeef); + hfile = CreateFile(file_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError()); + SetFilePointer(hfile, 0x4000, NULL, FILE_BEGIN); + SetEndOfFile(hfile); + + SetLastError(0xdeadbeef); + hmap = CreateFileMapping(hfile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL); + ok(hmap != 0, "CreateFileMapping error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + base = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0); + ok(base != NULL, "MapViewOfFile error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 0); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INSUFFICIENT_BUFFER, + "wrong error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), base, 0, sizeof(map_name)); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 1); +todo_wine + ok(ret == 1, "GetMappedFileName error %d\n", GetLastError()); + ok(!map_name[0] || broken(map_name[0] == device_name[0]) /* before win2k */, "expected 0, got %c\n", map_name[0]); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name)); +todo_wine { + ok(ret, "GetMappedFileName error %d\n", GetLastError()); + ok(ret > strlen(device_name), "map_name should be longer than device_name\n"); + ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name); +} + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameW(GetCurrentProcess(), base, map_nameW, sizeof(map_nameW)/sizeof(map_nameW[0])); +todo_wine { + ok(ret, "GetMappedFileNameW error %d\n", GetLastError()); + ok(ret > strlen(device_name), "map_name should be longer than device_name\n"); +} + if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name, sizeof(nt_map_name)/sizeof(nt_map_name[0]))) + { + ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name); + WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL); + ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name); + } + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), base + 0x2000, map_name, sizeof(map_name)); +todo_wine { + ok(ret, "GetMappedFileName error %d\n", GetLastError()); + ok(ret > strlen(device_name), "map_name should be longer than device_name\n"); + ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name); +} + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), base + 0x4000, map_name, sizeof(map_name)); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_UNEXP_NET_ERR, "expected ERROR_UNEXP_NET_ERR, got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), NULL, map_name, sizeof(map_name)); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_UNEXP_NET_ERR, "expected ERROR_UNEXP_NET_ERR, got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(0, base, map_name, sizeof(map_name)); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); + + UnmapViewOfFile(base); + CloseHandle(hmap); + CloseHandle(hfile); + DeleteFile(file_name); + + SetLastError(0xdeadbeef); + hmap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READONLY | SEC_COMMIT, 0, 4096, NULL); + ok(hmap != 0, "CreateFileMapping error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + base = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0); + ok(base != NULL, "MapViewOfFile error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name)); + ok(!ret, "GetMappedFileName should fail\n"); +todo_wine + ok(GetLastError() == ERROR_FILE_INVALID, "expected ERROR_FILE_INVALID, got %d\n", GetLastError()); + + UnmapViewOfFile(base); + CloseHandle(hmap); } static void test_GetProcessImageFileName(void) @@ -181,7 +407,7 @@ HMODULE hMod = GetModuleHandle(NULL); char szImgPath[MAX_PATH], szMapPath[MAX_PATH]; WCHAR szImgPathW[MAX_PATH]; - DWORD ret; + DWORD ret, ret1; if(pGetProcessImageFileNameA == NULL) return; @@ -201,55 +427,116 @@ todo_wine ok(0, "failed with %d\n", GetLastError()); } - todo_wine w32_err(pGetProcessImageFileNameA(NULL, szImgPath, sizeof(szImgPath)), ERROR_INVALID_HANDLE); - todo_wine w32_err(pGetProcessImageFileNameA(hpSR, szImgPath, sizeof(szImgPath)), ERROR_ACCESS_DENIED); - todo_wine w32_err(pGetProcessImageFileNameA(hpQI, szImgPath, 0), ERROR_INSUFFICIENT_BUFFER); - todo_wine - if(w32_suc(ret = pGetProcessImageFileNameA(hpQI, szImgPath, sizeof(szImgPath))) && - w32_suc(pGetMappedFileNameA(hpQV, hMod, szMapPath, sizeof(szMapPath)))) { + SetLastError(0xdeadbeef); + pGetProcessImageFileNameA(NULL, szImgPath, sizeof(szImgPath)); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetProcessImageFileNameA(hpSR, szImgPath, sizeof(szImgPath)); + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetProcessImageFileNameA(hpQI, szImgPath, 0); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError()); + + ret = pGetProcessImageFileNameA(hpQI, szImgPath, sizeof(szImgPath)); + ret1 = pGetMappedFileNameA(hpQV, hMod, szMapPath, sizeof(szMapPath)); + if(ret && ret1) + { /* Windows returns 2*strlen-1 */ - ok(ret >= strlen(szImgPath), "szImgPath=\"%s\" ret=%d\n", szImgPath, ret); - ok(!strcmp(szImgPath, szMapPath), - "szImgPath=\"%s\" szMapPath=\"%s\"\n", szImgPath, szMapPath); - } - - w32_err(pGetProcessImageFileNameW(NULL, szImgPathW, sizeof(szImgPathW)), ERROR_INVALID_HANDLE); + todo_wine ok(ret >= strlen(szImgPath), "szImgPath=\"%s\" ret=%d\n", szImgPath, ret); + todo_wine ok(!strcmp(szImgPath, szMapPath), "szImgPath=\"%s\" szMapPath=\"%s\"\n", szImgPath, szMapPath); + } + + SetLastError(0xdeadbeef); + pGetProcessImageFileNameW(NULL, szImgPathW, sizeof(szImgPathW)); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + /* no information about correct buffer size returned: */ - w32_err(pGetProcessImageFileNameW(hpQI, szImgPathW, 0), ERROR_INSUFFICIENT_BUFFER); - w32_err(pGetProcessImageFileNameW(hpQI, NULL, 0), ERROR_INSUFFICIENT_BUFFER); + SetLastError(0xdeadbeef); + pGetProcessImageFileNameW(hpQI, szImgPathW, 0); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetProcessImageFileNameW(hpQI, NULL, 0); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError()); /* correct call */ memset(szImgPathW, 0xff, sizeof(szImgPathW)); ret = pGetProcessImageFileNameW(hpQI, szImgPathW, sizeof(szImgPathW)/sizeof(WCHAR)); ok(ret > 0, "GetProcessImageFileNameW should have succeeded.\n"); ok(szImgPathW[0] == '\\', "GetProcessImageFileNameW should have returned an NT path.\n"); - expect_eq_d(lstrlenW(szImgPathW), ret); + ok(lstrlenW(szImgPathW) == ret, "Expected length to be %d, got %d\n", ret, lstrlenW(szImgPathW)); /* boundary values of 'size' */ - w32_err(pGetProcessImageFileNameW(hpQI, szImgPathW, ret), ERROR_INSUFFICIENT_BUFFER); + SetLastError(0xdeadbeef); + pGetProcessImageFileNameW(hpQI, szImgPathW, ret); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError()); memset(szImgPathW, 0xff, sizeof(szImgPathW)); ret = pGetProcessImageFileNameW(hpQI, szImgPathW, ret + 1); ok(ret > 0, "GetProcessImageFileNameW should have succeeded.\n"); ok(szImgPathW[0] == '\\', "GetProcessImageFileNameW should have returned an NT path.\n"); - expect_eq_d(lstrlenW(szImgPathW), ret); + ok(lstrlenW(szImgPathW) == ret, "Expected length to be %d, got %d\n", ret, lstrlenW(szImgPathW)); } static void test_GetModuleFileNameEx(void) { HMODULE hMod = GetModuleHandle(NULL); char szModExPath[MAX_PATH+1], szModPath[MAX_PATH+1]; + WCHAR buffer[MAX_PATH]; DWORD ret; - - w32_err(pGetModuleFileNameExA(NULL, hMod, szModExPath, sizeof(szModExPath)), ERROR_INVALID_HANDLE); - w32_err(pGetModuleFileNameExA(hpQI, hMod, szModExPath, sizeof(szModExPath)), ERROR_ACCESS_DENIED); - w32_err(pGetModuleFileNameExA(hpQV, hBad, szModExPath, sizeof(szModExPath)), ERROR_INVALID_HANDLE); - if(!w32_suc(ret = pGetModuleFileNameExA(hpQV, NULL, szModExPath, sizeof(szModExPath)))) - return; + + SetLastError(0xdeadbeef); + ret = pGetModuleFileNameExA(NULL, hMod, szModExPath, sizeof(szModExPath)); + ok( !ret, "GetModuleFileNameExA succeeded\n" ); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetModuleFileNameExA(hpQI, hMod, szModExPath, sizeof(szModExPath)); + ok( !ret, "GetModuleFileNameExA succeeded\n" ); + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetModuleFileNameExA(hpQV, hBad, szModExPath, sizeof(szModExPath)); + ok( !ret, "GetModuleFileNameExA succeeded\n" ); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + ret = pGetModuleFileNameExA(hpQV, NULL, szModExPath, sizeof(szModExPath)); + if(!ret) + return; ok(ret == strlen(szModExPath), "szModExPath=\"%s\" ret=%d\n", szModExPath, ret); GetModuleFileNameA(NULL, szModPath, sizeof(szModPath)); ok(!strncmp(szModExPath, szModPath, MAX_PATH), "szModExPath=\"%s\" szModPath=\"%s\"\n", szModExPath, szModPath); + + SetLastError(0xdeadbeef); + memset( szModExPath, 0xcc, sizeof(szModExPath) ); + ret = pGetModuleFileNameExA(hpQV, NULL, szModExPath, 4 ); + ok( ret == 4, "wrong length %u\n", ret ); + ok( broken(szModExPath[3]) /*w2kpro*/ || strlen(szModExPath) == 3, + "szModExPath=\"%s\" ret=%d\n", szModExPath, ret ); + ok(GetLastError() == 0xdeadbeef, "got error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetModuleFileNameExA(hpQV, NULL, szModExPath, 0 ); + ok( ret == 0, "wrong length %u\n", ret ); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + memset( buffer, 0xcc, sizeof(buffer) ); + ret = pGetModuleFileNameExW(hpQV, NULL, buffer, 4 ); + ok( ret == 4, "wrong length %u\n", ret ); + ok( broken(buffer[3]) /*w2kpro*/ || lstrlenW(buffer) == 3, + "buffer=%s ret=%d\n", wine_dbgstr_w(buffer), ret ); + ok(GetLastError() == 0xdeadbeef, "got error %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + buffer[0] = 0xcc; + ret = pGetModuleFileNameExW(hpQV, NULL, buffer, 0 ); + ok( ret == 0, "wrong length %u\n", ret ); + ok(GetLastError() == 0xdeadbeef, "got error %d\n", GetLastError()); + ok( buffer[0] == 0xcc, "buffer modified %s\n", wine_dbgstr_w(buffer) ); } static void test_GetModuleBaseName(void) @@ -258,10 +545,20 @@ char szModPath[MAX_PATH], szModBaseName[MAX_PATH]; DWORD ret; - w32_err(pGetModuleBaseNameA(NULL, hMod, szModBaseName, sizeof(szModBaseName)), ERROR_INVALID_HANDLE); - w32_err(pGetModuleBaseNameA(hpQI, hMod, szModBaseName, sizeof(szModBaseName)), ERROR_ACCESS_DENIED); - w32_err(pGetModuleBaseNameA(hpQV, hBad, szModBaseName, sizeof(szModBaseName)), ERROR_INVALID_HANDLE); - if(!w32_suc(ret = pGetModuleBaseNameA(hpQV, NULL, szModBaseName, sizeof(szModBaseName)))) + SetLastError(0xdeadbeef); + pGetModuleBaseNameA(NULL, hMod, szModBaseName, sizeof(szModBaseName)); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetModuleBaseNameA(hpQI, hMod, szModBaseName, sizeof(szModBaseName)); + ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pGetModuleBaseNameA(hpQV, hBad, szModBaseName, sizeof(szModBaseName)); + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + ret = pGetModuleBaseNameA(hpQV, NULL, szModBaseName, sizeof(szModBaseName)); + if(!ret) return; ok(ret == strlen(szModBaseName), "szModBaseName=\"%s\" ret=%d\n", szModBaseName, ret); GetModuleFileNameA(NULL, szModPath, sizeof(szModPath)); @@ -277,9 +574,17 @@ unsigned int i; BOOL ret; - todo_wine w32_err(pEmptyWorkingSet(NULL), ERROR_INVALID_HANDLE); - todo_wine w32_err(pEmptyWorkingSet(hpSR), ERROR_ACCESS_DENIED); - w32_suc(pEmptyWorkingSet(hpAA)); + SetLastError(0xdeadbeef); + pEmptyWorkingSet(NULL); + todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + pEmptyWorkingSet(hpSR); + todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pEmptyWorkingSet(hpAA); + ok(ret == 1, "failed with %d\n", GetLastError()); SetLastError( 0xdeadbeef ); ret = pInitializeProcessForWsWatch( NULL ); @@ -293,9 +598,12 @@ } ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() ); } - w32_suc(pInitializeProcessForWsWatch(hpAA)); + SetLastError(0xdeadbeef); + ret = pInitializeProcessForWsWatch(hpAA); + ok(ret == 1, "failed with %d\n", GetLastError()); - if(!w32_suc(addr = VirtualAlloc(NULL, 1, MEM_COMMIT, PAGE_READWRITE))) + addr = VirtualAlloc(NULL, 1, MEM_COMMIT, PAGE_READWRITE); + if(!addr) return; *addr = 0; /* make sure it's paged in (needed on wow64) */ @@ -305,29 +613,35 @@ goto free_page; } - todo_wine if(w32_suc(pQueryWorkingSet(hpQI, pages, 4096 * sizeof(ULONG_PTR)))) + SetLastError(0xdeadbeef); + ret = pQueryWorkingSet(hpQI, pages, 4096 * sizeof(ULONG_PTR)); + todo_wine ok(ret == 1, "failed with %d\n", GetLastError()); + if(ret == 1) { for(i = 0; i < pages[0]; i++) if((pages[i+1] & ~0xfffL) == (ULONG_PTR)addr) { - ok(1, "QueryWorkingSet found our page\n"); + todo_wine ok(ret == 1, "QueryWorkingSet found our page\n"); goto test_gwsc; } - ok(0, "QueryWorkingSet didn't find our page\n"); + todo_wine ok(0, "QueryWorkingSet didn't find our page\n"); } test_gwsc: - todo_wine if(w32_suc(pGetWsChanges(hpQI, wswi, sizeof(wswi)))) + SetLastError(0xdeadbeef); + ret = pGetWsChanges(hpQI, wswi, sizeof(wswi)); + todo_wine ok(ret == 1, "failed with %d\n", GetLastError()); + if(ret == 1) { for(i = 0; wswi[i].FaultingVa; i++) if(((ULONG_PTR)wswi[i].FaultingVa & ~0xfffL) == (ULONG_PTR)addr) { - ok(1, "GetWsChanges found our page\n"); + todo_wine ok(ret == 1, "GetWsChanges found our page\n"); goto free_page; } - ok(0, "GetWsChanges didn't find our page\n"); + todo_wine ok(0, "GetWsChanges didn't find our page\n"); } free_page: @@ -337,10 +651,10 @@ START_TEST(psapi_main) { HMODULE hpsapi = LoadLibraryA("psapi.dll"); - + if(!hpsapi) { - trace("Could not load psapi.dll\n"); + win_skip("Could not load psapi.dll\n"); return; } @@ -348,18 +662,19 @@ { DWORD pid = GetCurrentProcessId(); - w32_suc(hpSR = OpenProcess(STANDARD_RIGHTS_REQUIRED, FALSE, pid)); - w32_suc(hpQI = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)); - w32_suc(hpVR = OpenProcess(PROCESS_VM_READ, FALSE, pid)); - w32_suc(hpQV = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); - w32_suc(hpAA = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid)); - if(hpSR && hpQI && hpVR && hpQV && hpAA) + hpSR = OpenProcess(STANDARD_RIGHTS_REQUIRED, FALSE, pid); + hpQI = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); + hpVR = OpenProcess(PROCESS_VM_READ, FALSE, pid); + hpQV = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); + hpAA = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); + + if(hpSR && hpQI && hpVR && hpQV && hpAA) { test_EnumProcesses(); test_EnumProcessModules(); test_GetModuleInformation(); test_GetProcessMemoryInfo(); - todo_wine test_GetMappedFileName(); + test_GetMappedFileName(); test_GetProcessImageFileName(); test_GetModuleFileNameEx(); test_GetModuleBaseName();
11 years, 2 months
1
0
0
0
[pschweitzer] 60469: [PSDK] Add missing define for MEMORY_SECTION_NAME
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Mon Sep 30 06:22:27 2013 New Revision: 60469 URL:
http://svn.reactos.org/svn/reactos?rev=60469&view=rev
Log: [PSDK] Add missing define for MEMORY_SECTION_NAME Modified: trunk/reactos/include/psdk/winternl.h Modified: trunk/reactos/include/psdk/winternl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winternl.h?re…
============================================================================== --- trunk/reactos/include/psdk/winternl.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/winternl.h [iso-8859-1] Mon Sep 30 06:22:27 2013 @@ -837,6 +837,11 @@ MemorySectionName, MemoryBasicVlmInformation } MEMORY_INFORMATION_CLASS; + +typedef struct _MEMORY_SECTION_NAME +{ + UNICODE_STRING SectionFileName; +} MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME; typedef enum _MUTANT_INFORMATION_CLASS {
11 years, 2 months
1
0
0
0
[aandrejevic] 60468: [SOFT386] Fix previous fix.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Mon Sep 30 03:10:38 2013 New Revision: 60468 URL:
http://svn.reactos.org/svn/reactos?rev=60468&view=rev
Log: [SOFT386] Fix previous fix. Modified: branches/ntvdm/lib/soft386/common.c Modified: branches/ntvdm/lib/soft386/common.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.c?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.c [iso-8859-1] Mon Sep 30 03:10:38 2013 @@ -50,7 +50,7 @@ /* Get the cached descriptor */ CachedDescriptor = &State->SegmentRegs[SegmentReg]; - if ((Offset + Size) > CachedDescriptor->Limit) + if ((Offset + Size - 1) > CachedDescriptor->Limit) { /* Read beyond limit */ Soft386Exception(State, SOFT386_EXCEPTION_GP); @@ -190,7 +190,7 @@ /* Get the cached descriptor */ CachedDescriptor = &State->SegmentRegs[SegmentReg]; - if ((Offset + Size) >= CachedDescriptor->Limit) + if ((Offset + Size - 1) > CachedDescriptor->Limit) { /* Write beyond limit */ Soft386Exception(State, SOFT386_EXCEPTION_GP);
11 years, 2 months
1
0
0
0
[aandrejevic] 60467: [SOFT386] Fix limit check.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Mon Sep 30 03:05:08 2013 New Revision: 60467 URL:
http://svn.reactos.org/svn/reactos?rev=60467&view=rev
Log: [SOFT386] Fix limit check. Modified: branches/ntvdm/lib/soft386/common.c Modified: branches/ntvdm/lib/soft386/common.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.c?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.c [iso-8859-1] Mon Sep 30 03:05:08 2013 @@ -50,7 +50,7 @@ /* Get the cached descriptor */ CachedDescriptor = &State->SegmentRegs[SegmentReg]; - if ((Offset + Size) >= CachedDescriptor->Limit) + if ((Offset + Size) > CachedDescriptor->Limit) { /* Read beyond limit */ Soft386Exception(State, SOFT386_EXCEPTION_GP);
11 years, 2 months
1
0
0
0
← Newer
1
2
3
4
5
...
56
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Results per page:
10
25
50
100
200