mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
dsound/tests: Add tests for implicit MTA creation in IDirectSound::Initialize().
On recent Windows, at least Windows 7, a multithread apartment (MTA) is initialized within IDirectSound::Initialize().
This commit is contained in:
parent
4b0b489f6f
commit
67153fa0c3
3 changed files with 149 additions and 0 deletions
|
@ -41,6 +41,40 @@
|
|||
|
||||
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
static DWORD WINAPI test_apt_thread(void *param)
|
||||
{
|
||||
HRESULT hr;
|
||||
struct apt_data *test_apt_data = (struct apt_data *)param;
|
||||
|
||||
hr = CoGetApartmentType(&test_apt_data->type, &test_apt_data->qualifier);
|
||||
if (hr == CO_E_NOTINITIALIZED)
|
||||
{
|
||||
test_apt_data->type = APTTYPE_UNITIALIZED;
|
||||
test_apt_data->qualifier = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void check_apttype(struct apt_data *test_apt_data)
|
||||
{
|
||||
HANDLE thread;
|
||||
MSG msg;
|
||||
|
||||
memset(test_apt_data, 0xde, sizeof(*test_apt_data));
|
||||
|
||||
thread = CreateThread(NULL, 0, test_apt_thread, test_apt_data, 0, NULL);
|
||||
while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_ALLINPUT) != WAIT_OBJECT_0)
|
||||
{
|
||||
while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
}
|
||||
CloseHandle(thread);
|
||||
}
|
||||
|
||||
static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
|
||||
LPCGUID lpGuid)
|
||||
{
|
||||
|
@ -1823,10 +1857,63 @@ static void test_hw_buffers(void)
|
|||
IDirectSound_Release(ds);
|
||||
}
|
||||
|
||||
static void test_implicit_mta(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirectSound *dso;
|
||||
struct apt_data test_apt_data;
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
|
||||
/* test DirectSound object */
|
||||
hr = CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSound, (void**)&dso);
|
||||
ok(hr == S_OK, "CoCreateInstance(CLSID_DirectSound) failed: %08lx\n", hr);
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
|
||||
hr = IDirectSound_Initialize(dso, NULL);
|
||||
ok(hr == DS_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
|
||||
"IDirectSound_Initialize() failed: %08lx\n", hr);
|
||||
if (hr == DS_OK) {
|
||||
check_apttype(&test_apt_data);
|
||||
todo_wine
|
||||
ok(test_apt_data.type == APTTYPE_MTA, "got apt type %d.\n", test_apt_data.type);
|
||||
todo_wine
|
||||
ok(test_apt_data.qualifier == APTTYPEQUALIFIER_IMPLICIT_MTA,
|
||||
"got apt type qualifier %d.\n", test_apt_data.qualifier);
|
||||
}
|
||||
IDirectSound_Release(dso);
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
|
||||
/* test DirectSoundCreate */
|
||||
hr = DirectSoundCreate(NULL, &dso, NULL);
|
||||
ok(hr == DS_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
|
||||
"DirectSoundCreate() failed: %08lx\n", hr);
|
||||
if (hr == DS_OK) {
|
||||
check_apttype(&test_apt_data);
|
||||
todo_wine
|
||||
ok(test_apt_data.type == APTTYPE_MTA, "got apt type %d.\n", test_apt_data.type);
|
||||
todo_wine
|
||||
ok(test_apt_data.qualifier == APTTYPEQUALIFIER_IMPLICIT_MTA,
|
||||
"got apt type qualifier %d.\n", test_apt_data.qualifier);
|
||||
IDirectSound_Release(dso);
|
||||
}
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
}
|
||||
|
||||
START_TEST(dsound)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
|
||||
/* Run implicit MTA tests before IDirectSound_test so that a MTA won't be created before this test is run. */
|
||||
test_implicit_mta();
|
||||
IDirectSound_tests();
|
||||
dsound_tests();
|
||||
test_hw_buffers();
|
||||
|
|
|
@ -1881,6 +1881,57 @@ static void test_AcquireResources(void)
|
|||
IDirectSound_Release(dsound);
|
||||
}
|
||||
|
||||
static void test_implicit_mta(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirectSound8 *dso;
|
||||
struct apt_data test_apt_data;
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
|
||||
/* test DirectSound8 object */
|
||||
hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSound8, (void**)&dso);
|
||||
ok(hr == S_OK, "CoCreateInstance(CLSID_DirectSound8) failed: %08lx\n", hr);
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
|
||||
hr = IDirectSound8_Initialize(dso, NULL);
|
||||
ok(hr == DS_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
|
||||
"IDirectSound8_Initialize() failed: %08lx\n", hr);
|
||||
if (hr == DS_OK) {
|
||||
check_apttype(&test_apt_data);
|
||||
todo_wine
|
||||
ok(test_apt_data.type == APTTYPE_MTA, "got apt type %d.\n", test_apt_data.type);
|
||||
todo_wine
|
||||
ok(test_apt_data.qualifier == APTTYPEQUALIFIER_IMPLICIT_MTA,
|
||||
"got apt type qualifier %d.\n", test_apt_data.qualifier);
|
||||
}
|
||||
IDirectSound8_Release(dso);
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
|
||||
/* test DirectSoundCreate8 */
|
||||
hr = DirectSoundCreate8(NULL, &dso, NULL);
|
||||
ok(hr == DS_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
|
||||
"DirectSoundCreate8() failed: %08lx\n", hr);
|
||||
if (hr == DS_OK) {
|
||||
check_apttype(&test_apt_data);
|
||||
todo_wine
|
||||
ok(test_apt_data.type == APTTYPE_MTA, "got apt type %d.\n", test_apt_data.type);
|
||||
todo_wine
|
||||
ok(test_apt_data.qualifier == APTTYPEQUALIFIER_IMPLICIT_MTA,
|
||||
"got apt type qualifier %d.\n", test_apt_data.qualifier);
|
||||
IDirectSound8_Release(dso);
|
||||
}
|
||||
|
||||
check_apttype(&test_apt_data);
|
||||
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
|
||||
}
|
||||
|
||||
START_TEST(dsound8)
|
||||
{
|
||||
DWORD cookie;
|
||||
|
@ -1888,6 +1939,8 @@ START_TEST(dsound8)
|
|||
|
||||
CoInitialize(NULL);
|
||||
|
||||
/* Run implicit MTA tests before test COM so that a MTA won't be created before this test is run. */
|
||||
test_implicit_mta();
|
||||
test_COM();
|
||||
IDirectSound8_tests();
|
||||
dsound8_tests();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "wingdi.h"
|
||||
#include "mmreg.h"
|
||||
#include "combaseapi.h" /* APTTYPE, APTTYPEQUALIFIER */
|
||||
|
||||
static const unsigned int formats[][4]={
|
||||
{ 8000, 8, 1, 0 },
|
||||
|
@ -74,6 +75,13 @@ static const unsigned int formats[][4]={
|
|||
|
||||
static const unsigned int format_tags[] = {WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT};
|
||||
|
||||
#define APTTYPE_UNITIALIZED APTTYPE_CURRENT
|
||||
struct apt_data
|
||||
{
|
||||
APTTYPE type;
|
||||
APTTYPEQUALIFIER qualifier;
|
||||
};
|
||||
|
||||
/* The time slice determines how often we will service the buffer */
|
||||
#define TIME_SLICE 31
|
||||
#define BUFFER_LEN 400
|
||||
|
@ -90,3 +98,4 @@ extern void test_buffer8(LPDIRECTSOUND8,LPDIRECTSOUNDBUFFER*,
|
|||
extern const char * getDSBCAPS(DWORD xmask);
|
||||
extern int align(int length, int align);
|
||||
extern const char * format_string(const WAVEFORMATEX* wfx);
|
||||
extern void check_apttype(struct apt_data *);
|
||||
|
|
Loading…
Reference in a new issue