* Sync with Wine 1.5.26.

svn path=/trunk/; revision=58752
This commit is contained in:
Amine Khaldi 2013-04-13 23:33:54 +00:00
parent 58c8c13693
commit 18e14e7e3e
31 changed files with 6544 additions and 14691 deletions

View file

@ -1,7 +1,8 @@
add_definitions(
-D_WINE
-D_USE_MATH_DEFINES)
-D_USE_MATH_DEFINES
-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
@ -17,26 +18,11 @@ add_library(dsound SHARED
mixer.c
primary.c
propset.c
regsvr.c
sound3d.c
version.rc
${CMAKE_CURRENT_BINARY_DIR}/dsound.def)
set_module_type(dsound win32dll)
target_link_libraries(dsound
dxguid
uuid
wine)
add_importlibs(dsound
msvcrt
user32
advapi32
ole32
winmm
kernel32
ntdll)
target_link_libraries(dsound dxguid uuid wine)
add_importlibs(dsound winmm ole32 advapi32 user32 msvcrt kernel32 ntdll)
add_cd_file(TARGET dsound DESTINATION reactos/system32 FOR all)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
/*
* COM Classes for dsound
*
* Copyright 2010 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
[
helpstring("DirectSound Object"),
threading(both),
uuid(47d4d946-62e8-11cf-93bc-444553540000)
]
coclass DirectSound { interface IDirectSound; }
[
helpstring("DirectSound 8.0 Object"),
threading(both),
uuid(3901cc3f-84b5-4fa4-ba35-aa8172b8a09b)
]
coclass DirectSound8 { interface IDirectSound8; }
[
helpstring("DirectSoundBufferConfig Object"),
threading(both),
uuid(b2f586d4-5558-49d1-a07b-3249dbbb33c2)
]
coclass DirectSoundBufferConfig { interface IDirectSoundBufferConfig; }
[
helpstring("DirectSoundCapture Object"),
threading(both),
uuid(b0210780-89cd-11d0-af08-00a0c925cd16)
]
coclass DirectSoundCapture { interface IDirectSoundCapture; }
[
helpstring("DirectSoundCapture 8.0 Object"),
threading(both),
uuid(e4bcac13-7f99-4908-9a8e-74e3bf24b6e1)
]
coclass DirectSoundCapture8 { interface IDirectSoundCapture8; }
[
helpstring("DirectSoundFullDuplex Object"),
threading(both),
uuid(fea4300c-7959-4147-b26a-2377b9e7a91d)
]
coclass DirectSoundFullDuplex { interface IDirectSoundFullDuplex; }

View file

@ -0,0 +1,33 @@
HKCR
{
NoRemove Interface
{
}
NoRemove CLSID
{
'{47D4D946-62E8-11CF-93BC-444553540000}' = s 'DirectSound Object'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{3901CC3F-84B5-4FA4-BA35-AA8172B8A09B}' = s 'DirectSound 8.0 Object'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{B2F586D4-5558-49D1-A07B-3249DBBB33C2}' = s 'DirectSoundBufferConfig Object'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{B0210780-89CD-11D0-AF08-00A0C925CD16}' = s 'DirectSoundCapture Object'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{E4BCAC13-7F99-4908-9A8E-74E3BF24B6E1}' = s 'DirectSoundCapture 8.0 Object'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{FEA4300C-7959-4147-B26A-2377B9E7A91D}' = s 'DirectSoundFullDuplex Object'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
}
}

View file

@ -1,6 +1,7 @@
/* DirectSound format conversion and mixing routines
*
* Copyright 2007 Maarten Lankhorst
* Copyright 2011 Owen Rudge for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -36,6 +37,7 @@
#include <config.h>
#include <stdarg.h>
#include <math.h>
#define WIN32_NO_STATUS
#define _INC_WINDOWS
@ -49,7 +51,6 @@
#include <winternl.h>
#include <wine/debug.h>
#include <dsound.h>
#include <dsdriver.h>
#include "dsound_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
@ -62,378 +63,205 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
#define le32(x) (x)
#endif
static inline void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
/* This is an inlined version of lrintf. */
#if defined(_M_IX86) && defined(_MSC_VER)
FORCEINLINE
int
lrintf(float f)
{
*freqAcc += adj;
if (*freqAcc >= (1 << DSOUND_FREQSHIFT))
int result;
__asm
{
ULONG adv = (*freqAcc >> DSOUND_FREQSHIFT);
*freqAcc &= (1 << DSOUND_FREQSHIFT) - 1;
*(const char **)src += adv * stride;
*count -= adv;
fld f;
fistp result;
}
}
#endif
static void convert_8_to_8 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static float get8(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel)
{
while (count > 0)
{
*(BYTE *)dst = *(const BYTE *)src;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
const BYTE* buf = dsb->buffer->memory;
buf += pos + channel;
return (buf[0] - 0x80) / (float)0x80;
}
static void convert_8_to_16 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static float get16(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel)
{
while (count > 0)
{
WORD dest = *(const BYTE *)src, *dest16 = dst;
*dest16 = le16(dest * 257 - 32768);
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
const BYTE* buf = dsb->buffer->memory;
const SHORT *sbuf = (const SHORT*)(buf + pos + 2 * channel);
SHORT sample = (SHORT)le16(*sbuf);
return sample / (float)0x8000;
}
static void convert_8_to_24 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static float get24(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel)
{
while (count > 0)
{
BYTE dest = *(const BYTE *)src;
BYTE *dest24 = dst;
dest24[0] = dest;
dest24[1] = dest;
dest24[2] = dest - 0x80;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
LONG sample;
const BYTE* buf = dsb->buffer->memory;
buf += pos + 3 * channel;
/* The next expression deliberately has an overflow for buf[2] >= 0x80,
this is how negative values are made.
*/
sample = (buf[0] << 8) | (buf[1] << 16) | (buf[2] << 24);
return sample / (float)0x80000000U;
}
static void convert_8_to_32 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static float get32(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel)
{
while (count > 0)
{
DWORD dest = *(const BYTE *)src, *dest32 = dst;
*dest32 = le32(dest * 16843009 - 2147483648U);
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
const BYTE* buf = dsb->buffer->memory;
const LONG *sbuf = (const LONG*)(buf + pos + 4 * channel);
LONG sample = le32(*sbuf);
return sample / (float)0x80000000U;
}
static void convert_16_to_8 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static float getieee32(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel)
{
while (count > 0)
{
BYTE *dst8 = dst;
*dst8 = (le16(*(const WORD *)src)) / 256;
*dst8 -= 0x80;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
const BYTE* buf = dsb->buffer->memory;
const float *sbuf = (const float*)(buf + pos + 4 * channel);
/* The value will be clipped later, when put into some non-float buffer */
return *sbuf;
}
static void convert_16_to_16 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
{
while (count > 0)
{
*(WORD *)dst = *(const WORD *)src;
const bitsgetfunc getbpp[5] = {get8, get16, get24, get32, getieee32};
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
float get_mono(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel)
{
DWORD channels = dsb->pwfx->nChannels;
DWORD c;
float val = 0;
/* XXX: does Windows include LFE into the mix? */
for (c = 0; c < channels; c++)
val += dsb->get_aux(dsb, pos, c);
val /= channels;
return val;
}
static void convert_16_to_24 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static inline unsigned char f_to_8(float value)
{
while (count > 0)
{
WORD dest = le16(*(const WORD *)src);
BYTE *dest24 = dst;
dest24[0] = dest / 256;
dest24[1] = dest;
dest24[2] = dest / 256;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
if(value <= -1.f)
return 0;
if(value >= 1.f * 0x7f / 0x80)
return 0xFF;
return lrintf((value + 1.f) * 0x80);
}
static void convert_16_to_32 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static inline SHORT f_to_16(float value)
{
while (count > 0)
{
DWORD dest = *(const WORD *)src, *dest32 = dst;
*dest32 = dest * 65537;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
if(value <= -1.f)
return 0x8000;
if(value >= 1.f * 0x7FFF / 0x8000)
return 0x7FFF;
return le16(lrintf(value * 0x8000));
}
static void convert_24_to_8 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static LONG f_to_24(float value)
{
while (count > 0)
{
BYTE *dst8 = dst;
*dst8 = ((const BYTE *)src)[2];
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
if(value <= -1.f)
return 0x80000000;
if(value >= 1.f * 0x7FFFFF / 0x800000)
return 0x7FFFFF00;
return lrintf(value * 0x80000000U);
}
static void convert_24_to_16 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static inline LONG f_to_32(float value)
{
while (count > 0)
{
WORD *dest16 = dst;
const BYTE *source = src;
*dest16 = le16(source[2] * 256 + source[1]);
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
if(value <= -1.f)
return 0x80000000;
if(value >= 1.f * 0x7FFFFFFF / 0x80000000U) /* this rounds to 1.f */
return 0x7FFFFFFF;
return le32(lrintf(value * 0x80000000U));
}
static void convert_24_to_24 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
void putieee32(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value)
{
while (count > 0)
{
BYTE *dest24 = dst;
const BYTE *src24 = src;
dest24[0] = src24[0];
dest24[1] = src24[1];
dest24[2] = src24[2];
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
BYTE *buf = (BYTE *)dsb->device->tmp_buffer;
float *fbuf = (float*)(buf + pos + sizeof(float) * channel);
*fbuf = value;
}
static void convert_24_to_32 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
void put_mono2stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value)
{
while (count > 0)
{
DWORD *dest32 = dst;
const BYTE *source = src;
*dest32 = le32(source[2] * 16777217 + source[1] * 65536 + source[0] * 256);
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
dsb->put_aux(dsb, pos, 0, value);
dsb->put_aux(dsb, pos, 1, value);
}
static void convert_32_to_8 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
void mixieee32(float *src, float *dst, unsigned samples)
{
while (count > 0)
{
BYTE *dst8 = dst;
*dst8 = (le32(*(const DWORD *)src) / 16777216);
*dst8 -= 0x80;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
TRACE("%p - %p %d\n", src, dst, samples);
while (samples--)
*(dst++) += *(src++);
}
static void convert_32_to_16 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
{
while (count > 0)
{
WORD *dest16 = dst;
*dest16 = le16(le32(*(const DWORD *)src) / 65536);
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
}
static void convert_32_to_24 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
{
while (count > 0)
{
DWORD dest = le32(*(const DWORD *)src);
BYTE *dest24 = dst;
dest24[0] = dest / 256;
dest24[1] = dest / 65536;
dest24[2] = dest / 16777216;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
}
static void convert_32_to_32 (const void *src, void *dst, UINT src_stride,
UINT dst_stride, INT count, UINT freqAcc, UINT adj)
{
while (count > 0)
{
DWORD *dest = dst;
*dest = *(const DWORD *)src;
dst = (char *)dst + dst_stride;
src_advance(&src, src_stride, &count, &freqAcc, adj);
}
}
const bitsconvertfunc convertbpp[4][4] = {
{ convert_8_to_8, convert_8_to_16, convert_8_to_24, convert_8_to_32 },
{ convert_16_to_8, convert_16_to_16, convert_16_to_24, convert_16_to_32 },
{ convert_24_to_8, convert_24_to_16, convert_24_to_24, convert_24_to_32 },
{ convert_32_to_8, convert_32_to_16, convert_32_to_24, convert_32_to_32 },
};
static void mix8(signed char *src, INT *dst, unsigned len)
static void norm8(float *src, unsigned char *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
while (len--)
/* 8-bit WAV is unsigned, it's here converted to signed, normalize function will convert it back again */
*(dst++) += (signed char)((BYTE)*(src++) - (BYTE)0x80);
{
*dst = f_to_8(*src);
++dst;
++src;
}
}
static void mix16(SHORT *src, INT *dst, unsigned len)
static void norm16(float *src, SHORT *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
len /= 2;
while (len--)
{
*dst += le16(*src);
++dst; ++src;
*dst = f_to_16(*src);
++dst;
++src;
}
}
static void mix24(BYTE *src, INT *dst, unsigned len)
static void norm24(float *src, BYTE *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
len /= 3;
while (len--)
{
DWORD field;
field = ((DWORD)src[2] << 16) + ((DWORD)src[1] << 8) + (DWORD)src[0];
if (src[2] & 0x80)
field |= 0xFF000000U;
*(dst++) += field;
LONG t = f_to_24(*src);
dst[0] = (t >> 8) & 0xFF;
dst[1] = (t >> 16) & 0xFF;
dst[2] = t >> 24;
dst += 3;
++src;
}
}
static void mix32(INT *src, LONGLONG *dst, unsigned len)
static void norm32(float *src, INT *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
len /= 4;
while (len--)
*(dst++) += le32(*(src++));
}
const mixfunc mixfunctions[4] = {
(mixfunc)mix8,
(mixfunc)mix16,
(mixfunc)mix24,
(mixfunc)mix32
};
static void norm8(INT *src, signed char *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
while (len--)
{
*dst = (*src) + 0x80;
if (*src < -0x80)
*dst = 0;
else if (*src > 0x7f)
*dst = 0xff;
*dst = f_to_32(*src);
++dst;
++src;
}
}
static void norm16(INT *src, SHORT *dst, unsigned len)
static void normieee32(float *src, float *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
len /= 2;
len /= 4;
while (len--)
{
*dst = le16(*src);
if (*src <= -0x8000)
*dst = le16(0x8000);
else if (*src > 0x7fff)
*dst = le16(0x7fff);
++dst;
++src;
}
}
static void norm24(INT *src, BYTE *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
len /= 3;
while (len--)
{
if (*src <= -0x800000)
{
dst[0] = 0;
dst[1] = 0;
dst[2] = 0x80;
}
else if (*src > 0x7fffff)
{
dst[0] = 0xff;
dst[1] = 0xff;
dst[2] = 0x7f;
}
if(*src > 1)
*dst = 1;
else if(*src < -1)
*dst = -1;
else
{
dst[0] = *src;
dst[1] = *src >> 8;
dst[2] = *src >> 16;
}
*dst = *src;
++dst;
++src;
}
}
static void norm32(LONGLONG *src, INT *dst, unsigned len)
{
TRACE("%p - %p %d\n", src, dst, len);
len /= 4;
while (len--)
{
*dst = le32(*src);
if (*src <= -(LONGLONG)0x80000000)
*dst = le32(0x80000000);
else if (*src > 0x7fffffff)
*dst = le32(0x7fffffff);
++dst;
++src;
}
}
const normfunc normfunctions[4] = {
const normfunc normfunctions[5] = {
(normfunc)norm8,
(normfunc)norm16,
(normfunc)norm24,
(normfunc)norm32,
(normfunc)normieee32
};

View file

@ -53,56 +53,51 @@
#include <dsound.h>
#include <dsconf.h>
//#include "ks.h"
#include <rpcproxy.h>
//#include "rpc.h"
//#include "rpcndr.h"
//#include "unknwn.h"
//#include "oleidl.h"
//#include "shobjidl.h"
#include <initguid.h>
//#include "ksmedia.h"
#include <dsdriver.h>
//#include "propkey.h"
#include <devpkey.h>
#include "dsound_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
struct list DSOUND_renderers = LIST_INIT(DSOUND_renderers);
CRITICAL_SECTION DSOUND_renderers_lock;
static CRITICAL_SECTION_DEBUG DSOUND_renderers_lock_debug =
{
0, 0, &DSOUND_renderers_lock,
{ &DSOUND_renderers_lock_debug.ProcessLocksList, &DSOUND_renderers_lock_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": DSOUND_renderers_lock") }
};
CRITICAL_SECTION DSOUND_renderers_lock = { &DSOUND_renderers_lock_debug, -1, 0, 0, 0, 0 };
struct list DSOUND_capturers = LIST_INIT(DSOUND_capturers);
CRITICAL_SECTION DSOUND_capturers_lock;
static CRITICAL_SECTION_DEBUG DSOUND_capturers_lock_debug =
{
0, 0, &DSOUND_capturers_lock,
{ &DSOUND_capturers_lock_debug.ProcessLocksList, &DSOUND_capturers_lock_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": DSOUND_capturers_lock") }
};
CRITICAL_SECTION DSOUND_capturers_lock = { &DSOUND_capturers_lock_debug, -1, 0, 0, 0, 0 };
GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
HRESULT mmErr(UINT err)
{
switch(err) {
case MMSYSERR_NOERROR:
return DS_OK;
case MMSYSERR_ALLOCATED:
return DSERR_ALLOCATED;
case MMSYSERR_ERROR:
case MMSYSERR_INVALHANDLE:
case WAVERR_STILLPLAYING:
return DSERR_GENERIC; /* FIXME */
case MMSYSERR_NODRIVER:
return DSERR_NODRIVER;
case MMSYSERR_NOMEM:
return DSERR_OUTOFMEMORY;
case MMSYSERR_INVALPARAM:
case WAVERR_BADFORMAT:
case WAVERR_UNPREPARED:
return DSERR_INVALIDPARAM;
case MMSYSERR_NOTSUPPORTED:
return DSERR_UNSUPPORTED;
default:
FIXME("Unknown MMSYS error %d\n",err);
return DSERR_GENERIC;
}
}
WCHAR wine_vxd_drv[] = { 'w','i','n','e','m','m','.','v','x','d', 0 };
/* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
int ds_emuldriver = 0;
int ds_hel_buflen = 32768 * 2;
int ds_snd_queue_max = 10;
int ds_snd_queue_min = 6;
int ds_snd_shadow_maxsize = 2;
int ds_hw_accel = DS_HW_ACCEL_FULL;
int ds_default_sample_rate = 44100;
int ds_default_bits_per_sample = 16;
static int ds_default_playback;
static int ds_default_capture;
static HINSTANCE instance;
/*
* Get a config key from either the app-specific or the default config
@ -151,62 +146,18 @@ void setup_dsound_options(void)
/* get options */
if (!get_config_key( hkey, appkey, "EmulDriver", buffer, MAX_PATH ))
ds_emuldriver = strcmp(buffer, "N");
if (!get_config_key( hkey, appkey, "HelBuflen", buffer, MAX_PATH ))
ds_hel_buflen = atoi(buffer);
if (!get_config_key( hkey, appkey, "SndQueueMax", buffer, MAX_PATH ))
ds_snd_queue_max = atoi(buffer);
if (!get_config_key( hkey, appkey, "SndQueueMin", buffer, MAX_PATH ))
ds_snd_queue_min = atoi(buffer);
if (!get_config_key( hkey, appkey, "HardwareAcceleration", buffer, MAX_PATH )) {
if (strcmp(buffer, "Full") == 0)
ds_hw_accel = DS_HW_ACCEL_FULL;
else if (strcmp(buffer, "Standard") == 0)
ds_hw_accel = DS_HW_ACCEL_STANDARD;
else if (strcmp(buffer, "Basic") == 0)
ds_hw_accel = DS_HW_ACCEL_BASIC;
else if (strcmp(buffer, "Emulation") == 0)
ds_hw_accel = DS_HW_ACCEL_EMULATION;
}
if (!get_config_key( hkey, appkey, "DefaultPlayback", buffer, MAX_PATH ))
ds_default_playback = atoi(buffer);
if (!get_config_key( hkey, appkey, "MaxShadowSize", buffer, MAX_PATH ))
ds_snd_shadow_maxsize = atoi(buffer);
if (!get_config_key( hkey, appkey, "DefaultCapture", buffer, MAX_PATH ))
ds_default_capture = atoi(buffer);
if (!get_config_key( hkey, appkey, "DefaultSampleRate", buffer, MAX_PATH ))
ds_default_sample_rate = atoi(buffer);
if (!get_config_key( hkey, appkey, "DefaultBitsPerSample", buffer, MAX_PATH ))
ds_default_bits_per_sample = atoi(buffer);
if (appkey) RegCloseKey( appkey );
if (hkey) RegCloseKey( hkey );
TRACE("ds_emuldriver = %d\n", ds_emuldriver);
TRACE("ds_hel_buflen = %d\n", ds_hel_buflen);
TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max);
TRACE("ds_snd_queue_min = %d\n", ds_snd_queue_min);
TRACE("ds_hw_accel = %s\n",
ds_hw_accel==DS_HW_ACCEL_FULL ? "Full" :
ds_hw_accel==DS_HW_ACCEL_STANDARD ? "Standard" :
ds_hw_accel==DS_HW_ACCEL_BASIC ? "Basic" :
ds_hw_accel==DS_HW_ACCEL_EMULATION ? "Emulation" :
"Unknown");
TRACE("ds_default_playback = %d\n", ds_default_playback);
TRACE("ds_default_capture = %d\n", ds_default_playback);
TRACE("ds_default_sample_rate = %d\n", ds_default_sample_rate);
TRACE("ds_default_bits_per_sample = %d\n", ds_default_bits_per_sample);
TRACE("ds_snd_shadow_maxsize = %d\n", ds_snd_shadow_maxsize);
}
static const char * get_device_id(LPCGUID pGuid)
@ -222,6 +173,63 @@ static const char * get_device_id(LPCGUID pGuid)
return debugstr_guid(pGuid);
}
static HRESULT get_mmdevenum(IMMDeviceEnumerator **devenum)
{
HRESULT hr, init_hr;
init_hr = CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)devenum);
if(FAILED(hr)){
CoUninitialize();
*devenum = NULL;
ERR("CoCreateInstance failed: %08x\n", hr);
return hr;
}
return init_hr;
}
static void release_mmdevenum(IMMDeviceEnumerator *devenum, HRESULT init_hr)
{
IMMDeviceEnumerator_Release(devenum);
if(SUCCEEDED(init_hr))
CoUninitialize();
}
static HRESULT get_mmdevice_guid(IMMDevice *device, IPropertyStore *ps,
GUID *guid)
{
PROPVARIANT pv;
HRESULT hr;
if(!ps){
hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
if(FAILED(hr)){
WARN("OpenPropertyStore failed: %08x\n", hr);
return hr;
}
}else
IPropertyStore_AddRef(ps);
PropVariantInit(&pv);
hr = IPropertyStore_GetValue(ps, &PKEY_AudioEndpoint_GUID, &pv);
if(FAILED(hr)){
IPropertyStore_Release(ps);
WARN("GetValue(GUID) failed: %08x\n", hr);
return hr;
}
CLSIDFromString(pv.u.pwszVal, guid);
PropVariantClear(&pv);
IPropertyStore_Release(ps);
return S_OK;
}
/***************************************************************************
* GetDeviceID [DSOUND.9]
*
@ -244,38 +252,76 @@ static const char * get_device_id(LPCGUID pGuid)
*/
HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
{
IMMDeviceEnumerator *devenum;
EDataFlow flow = (EDataFlow)-1;
ERole role = (ERole)-1;
HRESULT hr, init_hr;
TRACE("(%s,%p)\n", get_device_id(pGuidSrc),pGuidDest);
if ( pGuidSrc == NULL) {
WARN("invalid parameter: pGuidSrc == NULL\n");
return DSERR_INVALIDPARAM;
if(!pGuidSrc || !pGuidDest)
return DSERR_INVALIDPARAM;
init_hr = get_mmdevenum(&devenum);
if(!devenum)
return init_hr;
if(IsEqualGUID(&DSDEVID_DefaultPlayback, pGuidSrc)){
role = eMultimedia;
flow = eRender;
}else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback, pGuidSrc)){
role = eCommunications;
flow = eRender;
}else if(IsEqualGUID(&DSDEVID_DefaultCapture, pGuidSrc)){
role = eMultimedia;
flow = eCapture;
}else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture, pGuidSrc)){
role = eCommunications;
flow = eCapture;
}
if ( pGuidDest == NULL ) {
WARN("invalid parameter: pGuidDest == NULL\n");
return DSERR_INVALIDPARAM;
if(role != (ERole)-1 && flow != (EDataFlow)-1){
IMMDevice *device;
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum,
flow, role, &device);
if(FAILED(hr)){
WARN("GetDefaultAudioEndpoint failed: %08x\n", hr);
release_mmdevenum(devenum, init_hr);
return DSERR_NODRIVER;
}
hr = get_mmdevice_guid(device, NULL, pGuidDest);
IMMDevice_Release(device);
release_mmdevenum(devenum, init_hr);
return (hr == S_OK) ? DS_OK : hr;
}
if ( IsEqualGUID( &DSDEVID_DefaultPlayback, pGuidSrc ) ||
IsEqualGUID( &DSDEVID_DefaultVoicePlayback, pGuidSrc ) ) {
*pGuidDest = DSOUND_renderer_guids[ds_default_playback];
TRACE("returns %s\n", get_device_id(pGuidDest));
return DS_OK;
}
if ( IsEqualGUID( &DSDEVID_DefaultCapture, pGuidSrc ) ||
IsEqualGUID( &DSDEVID_DefaultVoiceCapture, pGuidSrc ) ) {
*pGuidDest = DSOUND_capture_guids[ds_default_capture];
TRACE("returns %s\n", get_device_id(pGuidDest));
return DS_OK;
}
release_mmdevenum(devenum, init_hr);
*pGuidDest = *pGuidSrc;
TRACE("returns %s\n", get_device_id(pGuidDest));
return DS_OK;
}
struct morecontext
{
LPDSENUMCALLBACKA callA;
LPVOID data;
};
static BOOL CALLBACK a_to_w_callback(LPGUID guid, LPCWSTR descW, LPCWSTR modW, LPVOID data)
{
struct morecontext *context = data;
char descA[MAXPNAMELEN], modA[MAXPNAMELEN];
WideCharToMultiByte(CP_ACP, 0, descW, -1, descA, sizeof(descA), NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, modW, -1, modA, sizeof(modA), NULL, NULL);
return context->callA(guid, descA, modA, context->data);
}
/***************************************************************************
* DirectSoundEnumerateA [DSOUND.2]
@ -294,46 +340,198 @@ HRESULT WINAPI DirectSoundEnumerateA(
LPDSENUMCALLBACKA lpDSEnumCallback,
LPVOID lpContext)
{
unsigned devs, wod;
DSDRIVERDESC desc;
GUID guid;
int err;
TRACE("lpDSEnumCallback = %p, lpContext = %p\n",
lpDSEnumCallback, lpContext);
struct morecontext context;
if (lpDSEnumCallback == NULL) {
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
return DSERR_INVALIDPARAM;
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
return DSERR_INVALIDPARAM;
}
devs = waveOutGetNumDevs();
if (devs > 0) {
if (GetDeviceID(&DSDEVID_DefaultPlayback, &guid) == DS_OK) {
for (wod = 0; wod < devs; ++wod) {
if (IsEqualGUID( &guid, &DSOUND_renderer_guids[wod]) ) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Driver","",lpContext);
if (lpDSEnumCallback(NULL, "Primary Sound Driver", "", lpContext) == FALSE)
return DS_OK;
}
}
}
}
context.callA = lpDSEnumCallback;
context.data = lpContext;
return DirectSoundEnumerateW(a_to_w_callback, &context);
}
HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device)
{
IMMDeviceEnumerator *devenum;
IMMDeviceCollection *coll;
UINT count, i;
HRESULT hr, init_hr;
init_hr = get_mmdevenum(&devenum);
if(!devenum)
return init_hr;
hr = IMMDeviceEnumerator_EnumAudioEndpoints(devenum, flow,
DEVICE_STATE_ACTIVE, &coll);
if(FAILED(hr)){
WARN("EnumAudioEndpoints failed: %08x\n", hr);
release_mmdevenum(devenum, init_hr);
return hr;
}
for (wod = 0; wod < devs; ++wod) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
debugstr_guid(&DSOUND_renderer_guids[wod]),desc.szDesc,desc.szDrvname,lpContext);
if (lpDSEnumCallback(&DSOUND_renderer_guids[wod], desc.szDesc, desc.szDrvname, lpContext) == FALSE)
return DS_OK;
}
hr = IMMDeviceCollection_GetCount(coll, &count);
if(FAILED(hr)){
IMMDeviceCollection_Release(coll);
release_mmdevenum(devenum, init_hr);
WARN("GetCount failed: %08x\n", hr);
return hr;
}
return DS_OK;
for(i = 0; i < count; ++i){
GUID guid;
hr = IMMDeviceCollection_Item(coll, i, device);
if(FAILED(hr))
continue;
hr = get_mmdevice_guid(*device, NULL, &guid);
if(FAILED(hr)){
IMMDevice_Release(*device);
continue;
}
if(IsEqualGUID(&guid, tgt)){
IMMDeviceCollection_Release(coll);
release_mmdevenum(devenum, init_hr);
return DS_OK;
}
IMMDevice_Release(*device);
}
WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt));
IMMDeviceCollection_Release(coll);
release_mmdevenum(devenum, init_hr);
return DSERR_INVALIDPARAM;
}
static BOOL send_device(IMMDevice *device, GUID *guid,
LPDSENUMCALLBACKW cb, void *user)
{
IPropertyStore *ps;
PROPVARIANT pv;
BOOL keep_going;
HRESULT hr;
PropVariantInit(&pv);
hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
if(FAILED(hr)){
WARN("OpenPropertyStore failed: %08x\n", hr);
return TRUE;
}
hr = get_mmdevice_guid(device, ps, guid);
if(FAILED(hr)){
IPropertyStore_Release(ps);
return TRUE;
}
hr = IPropertyStore_GetValue(ps,
(const PROPERTYKEY *)&DEVPKEY_Device_FriendlyName, &pv);
if(FAILED(hr)){
IPropertyStore_Release(ps);
WARN("GetValue(FriendlyName) failed: %08x\n", hr);
return TRUE;
}
TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid),
wine_dbgstr_w(pv.u.pwszVal));
keep_going = cb(guid, pv.u.pwszVal, wine_vxd_drv, user);
PropVariantClear(&pv);
IPropertyStore_Release(ps);
return keep_going;
}
/* S_FALSE means the callback returned FALSE at some point
* S_OK means the callback always returned TRUE */
HRESULT enumerate_mmdevices(EDataFlow flow, GUID *guids,
LPDSENUMCALLBACKW cb, void *user)
{
IMMDeviceEnumerator *devenum;
IMMDeviceCollection *coll;
IMMDevice *defdev = NULL;
UINT count, i, n;
BOOL keep_going;
HRESULT hr, init_hr;
static const WCHAR primary_desc[] = {'P','r','i','m','a','r','y',' ',
'S','o','u','n','d',' ','D','r','i','v','e','r',0};
static const WCHAR empty_drv[] = {0};
init_hr = get_mmdevenum(&devenum);
if(!devenum)
return init_hr;
hr = IMMDeviceEnumerator_EnumAudioEndpoints(devenum, flow,
DEVICE_STATE_ACTIVE, &coll);
if(FAILED(hr)){
release_mmdevenum(devenum, init_hr);
WARN("EnumAudioEndpoints failed: %08x\n", hr);
return DS_OK;
}
hr = IMMDeviceCollection_GetCount(coll, &count);
if(FAILED(hr)){
IMMDeviceCollection_Release(coll);
release_mmdevenum(devenum, init_hr);
WARN("GetCount failed: %08x\n", hr);
return DS_OK;
}
if(count == 0){
release_mmdevenum(devenum, init_hr);
return DS_OK;
}
TRACE("Calling back with NULL (%s)\n", wine_dbgstr_w(primary_desc));
keep_going = cb(NULL, primary_desc, empty_drv, user);
/* always send the default device first */
if(keep_going){
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum, flow,
eMultimedia, &defdev);
if(FAILED(hr)){
defdev = NULL;
n = 0;
}else{
keep_going = send_device(defdev, &guids[0], cb, user);
n = 1;
}
}
for(i = 0; keep_going && i < count; ++i){
IMMDevice *device;
hr = IMMDeviceCollection_Item(coll, i, &device);
if(FAILED(hr)){
WARN("Item failed: %08x\n", hr);
continue;
}
if(device != defdev){
send_device(device, &guids[n], cb, user);
++n;
}
IMMDevice_Release(device);
}
if(defdev)
IMMDevice_Release(defdev);
IMMDeviceCollection_Release(coll);
release_mmdevenum(devenum, init_hr);
return (keep_going == TRUE) ? S_OK : S_FALSE;
}
/***************************************************************************
@ -353,55 +551,84 @@ HRESULT WINAPI DirectSoundEnumerateW(
LPDSENUMCALLBACKW lpDSEnumCallback,
LPVOID lpContext )
{
unsigned devs, wod;
DSDRIVERDESC desc;
GUID guid;
int err;
WCHAR wDesc[MAXPNAMELEN];
WCHAR wName[MAXPNAMELEN];
HRESULT hr;
TRACE("lpDSEnumCallback = %p, lpContext = %p\n",
lpDSEnumCallback, lpContext);
TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext);
if (lpDSEnumCallback == NULL) {
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
return DSERR_INVALIDPARAM;
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
return DSERR_INVALIDPARAM;
}
devs = waveOutGetNumDevs();
if (devs > 0) {
if (GetDeviceID(&DSDEVID_DefaultPlayback, &guid) == DS_OK) {
static const WCHAR empty[] = { 0 };
for (wod = 0; wod < devs; ++wod) {
if (IsEqualGUID( &guid, &DSOUND_renderer_guids[wod] ) ) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
if (lpDSEnumCallback(NULL, wDesc, empty, lpContext) == FALSE)
return DS_OK;
}
}
}
}
setup_dsound_options();
hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids,
lpDSEnumCallback, lpContext);
return SUCCEEDED(hr) ? DS_OK : hr;
}
/***************************************************************************
* DirectSoundCaptureEnumerateA [DSOUND.7]
*
* Enumerate all DirectSound drivers installed in the system.
*
* PARAMS
* lpDSEnumCallback [I] Address of callback function.
* lpContext [I] Address of user defined context passed to callback function.
*
* RETURNS
* Success: DS_OK
* Failure: DSERR_INVALIDPARAM
*/
HRESULT WINAPI DirectSoundCaptureEnumerateA(
LPDSENUMCALLBACKA lpDSEnumCallback,
LPVOID lpContext)
{
struct morecontext context;
if (lpDSEnumCallback == NULL) {
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
return DSERR_INVALIDPARAM;
}
for (wod = 0; wod < devs; ++wod) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
debugstr_guid(&DSOUND_renderer_guids[wod]),desc.szDesc,desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(&DSOUND_renderer_guids[wod], wDesc, wName, lpContext) == FALSE)
return DS_OK;
}
context.callA = lpDSEnumCallback;
context.data = lpContext;
return DirectSoundCaptureEnumerateW(a_to_w_callback, &context);
}
/***************************************************************************
* DirectSoundCaptureEnumerateW [DSOUND.8]
*
* Enumerate all DirectSound drivers installed in the system.
*
* PARAMS
* lpDSEnumCallback [I] Address of callback function.
* lpContext [I] Address of user defined context passed to callback function.
*
* RETURNS
* Success: DS_OK
* Failure: DSERR_INVALIDPARAM
*/
HRESULT WINAPI
DirectSoundCaptureEnumerateW(
LPDSENUMCALLBACKW lpDSEnumCallback,
LPVOID lpContext)
{
HRESULT hr;
TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
if (lpDSEnumCallback == NULL) {
WARN("invalid parameter: lpDSEnumCallback == NULL\n");
return DSERR_INVALIDPARAM;
}
return DS_OK;
setup_dsound_options();
hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids,
lpDSEnumCallback, lpContext);
return SUCCEEDED(hr) ? DS_OK : hr;
}
/*******************************************************************************
@ -411,16 +638,20 @@ HRESULT WINAPI DirectSoundEnumerateW(
typedef HRESULT (*FnCreateInstance)(REFIID riid, LPVOID *ppobj);
typedef struct {
const IClassFactoryVtbl *lpVtbl;
LONG ref;
IClassFactory IClassFactory_iface;
REFCLSID rclsid;
FnCreateInstance pfnCreateInstance;
} IClassFactoryImpl;
static HRESULT WINAPI
DSCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
}
static HRESULT WINAPI
DSCF_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppobj)
{
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj);
if (ppobj == NULL)
return E_POINTER;
@ -428,7 +659,7 @@ DSCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
IsEqualIID(riid, &IID_IClassFactory))
{
*ppobj = iface;
IUnknown_AddRef(iface);
IClassFactory_AddRef(iface);
return S_OK;
}
*ppobj = NULL;
@ -437,19 +668,13 @@ DSCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
ULONG ref = InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %d\n", This, ref - 1);
return ref;
return 2;
}
static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
ULONG ref = InterlockedDecrement(&(This->ref));
TRACE("(%p) ref was %d\n", This, ref + 1);
/* static class, won't be freed */
return ref;
return 1;
}
static HRESULT WINAPI DSCF_CreateInstance(
@ -458,7 +683,7 @@ static HRESULT WINAPI DSCF_CreateInstance(
REFIID riid,
LPVOID *ppobj)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), ppobj);
if (pOuter)
@ -474,7 +699,7 @@ static HRESULT WINAPI DSCF_CreateInstance(
static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
FIXME("(%p, %d) stub!\n", This, dolock);
return S_OK;
}
@ -488,13 +713,13 @@ static const IClassFactoryVtbl DSCF_Vtbl = {
};
static IClassFactoryImpl DSOUND_CF[] = {
{ &DSCF_Vtbl, 1, &CLSID_DirectSound, (FnCreateInstance)DSOUND_Create },
{ &DSCF_Vtbl, 1, &CLSID_DirectSound8, (FnCreateInstance)DSOUND_Create8 },
{ &DSCF_Vtbl, 1, &CLSID_DirectSoundCapture, (FnCreateInstance)DSOUND_CaptureCreate },
{ &DSCF_Vtbl, 1, &CLSID_DirectSoundCapture8, (FnCreateInstance)DSOUND_CaptureCreate8 },
{ &DSCF_Vtbl, 1, &CLSID_DirectSoundFullDuplex, (FnCreateInstance)DSOUND_FullDuplexCreate },
{ &DSCF_Vtbl, 1, &CLSID_DirectSoundPrivate, (FnCreateInstance)IKsPrivatePropertySetImpl_Create },
{ NULL, 0, NULL, NULL }
{ { &DSCF_Vtbl }, &CLSID_DirectSound, DSOUND_Create },
{ { &DSCF_Vtbl }, &CLSID_DirectSound8, DSOUND_Create8 },
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture, DSOUND_CaptureCreate },
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture8, DSOUND_CaptureCreate8 },
{ { &DSCF_Vtbl }, &CLSID_DirectSoundFullDuplex, DSOUND_FullDuplexCreate },
{ { &DSCF_Vtbl }, &CLSID_DirectSoundPrivate, IKsPrivatePropertySetImpl_Create },
{ { NULL }, NULL, NULL }
};
/*******************************************************************************
@ -534,7 +759,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
while (NULL != DSOUND_CF[i].rclsid) {
if (IsEqualGUID(rclsid, DSOUND_CF[i].rclsid)) {
DSCF_AddRef((IClassFactory*) &DSOUND_CF[i]);
DSCF_AddRef(&DSOUND_CF[i].IClassFactory_iface);
*ppv = &DSOUND_CF[i];
return S_OK;
}
@ -552,12 +777,11 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
* Determines whether the DLL is in use.
*
* RETURNS
* Success: S_OK
* Failure: S_FALSE
* Can unload now: S_OK
* Cannot unload now (the DLL is still active): S_FALSE
*/
HRESULT WINAPI DllCanUnloadNow(void)
{
FIXME("(void): stub\n");
return S_FALSE;
}
@ -572,24 +796,20 @@ HRESULT WINAPI DllCanUnloadNow(void)
*/
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
int i;
TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpvReserved);
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
TRACE("DLL_PROCESS_ATTACH\n");
for (i = 0; i < MAXWAVEDRIVERS; i++) {
DSOUND_renderer[i] = NULL;
DSOUND_capture[i] = NULL;
INIT_GUID(DSOUND_renderer_guids[i], 0xbd6dd71a, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i);
INIT_GUID(DSOUND_capture_guids[i], 0xbd6dd71b, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i);
}
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");
DeleteCriticalSection(&DSOUND_renderers_lock);
DeleteCriticalSection(&DSOUND_capturers_lock);
break;
default:
TRACE("UNKNOWN REASON\n");
@ -597,3 +817,19 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
}
return TRUE;
}
/***********************************************************************
* DllRegisterServer (DSOUND.@)
*/
HRESULT WINAPI DllRegisterServer(void)
{
return __wine_register_resources( instance );
}
/***********************************************************************
* DllUnregisterServer (DSOUND.@)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources( instance );
}

View file

@ -23,58 +23,41 @@
#define DS_TIME_RES 2 /* Resolution of multimedia timer */
#define DS_TIME_DEL 10 /* Delay of multimedia timer callback, and duration of HEL fragment */
#include <wine/list.h>
#include "wingdi.h"
#include "mmdeviceapi.h"
#include "audioclient.h"
#include "mmsystem.h"
/* direct sound hardware acceleration levels */
#define DS_HW_ACCEL_FULL 0 /* default on Windows 98 */
#define DS_HW_ACCEL_STANDARD 1 /* default on Windows 2000 */
#define DS_HW_ACCEL_BASIC 2
#define DS_HW_ACCEL_EMULATION 3
#include "wine/list.h"
extern int ds_emuldriver;
extern int ds_hel_buflen;
extern int ds_snd_queue_max;
extern int ds_snd_queue_min;
extern int ds_snd_shadow_maxsize;
extern int ds_hw_accel;
extern int ds_default_sample_rate;
extern int ds_default_bits_per_sample;
extern int ds_hel_buflen DECLSPEC_HIDDEN;
extern int ds_snd_queue_max DECLSPEC_HIDDEN;
/*****************************************************************************
* Predeclare the interface implementation structures
*/
typedef struct IDirectSoundImpl IDirectSoundImpl;
typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
typedef struct IDirectSoundFullDuplexImpl IDirectSoundFullDuplexImpl;
typedef struct IDirectSoundFullDuplex_IUnknown IDirectSoundFullDuplex_IUnknown;
typedef struct IDirectSoundFullDuplex_IDirectSound IDirectSoundFullDuplex_IDirectSound;
typedef struct IDirectSoundFullDuplex_IDirectSound8 IDirectSoundFullDuplex_IDirectSound8;
typedef struct IDirectSoundFullDuplex_IDirectSoundCapture IDirectSoundFullDuplex_IDirectSoundCapture;
typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl;
typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl;
typedef struct IKsPrivatePropertySetImpl IKsPrivatePropertySetImpl;
typedef struct PrimaryBufferImpl PrimaryBufferImpl;
typedef struct SecondaryBufferImpl SecondaryBufferImpl;
typedef struct DirectSoundDevice DirectSoundDevice;
typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
/* dsound_convert.h */
typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
extern const bitsconvertfunc convertbpp[4][4];
typedef void (*mixfunc)(const void *, void *, unsigned);
extern const mixfunc mixfunctions[4];
typedef float (*bitsgetfunc)(const IDirectSoundBufferImpl *, DWORD, DWORD);
typedef void (*bitsputfunc)(const IDirectSoundBufferImpl *, DWORD, DWORD, float);
extern const bitsgetfunc getbpp[5] DECLSPEC_HIDDEN;
void putieee32(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void mixieee32(float *src, float *dst, unsigned samples) DECLSPEC_HIDDEN;
typedef void (*normfunc)(const void *, void *, unsigned);
extern const normfunc normfunctions[4];
extern const normfunc normfunctions[5] DECLSPEC_HIDDEN;
typedef struct _DSVOLUMEPAN
{
DWORD dwTotalLeftAmpFactor;
DWORD dwTotalRightAmpFactor;
LONG lVolume;
DWORD dwVolAmpFactor;
LONG lPan;
DWORD dwPanLeftAmpFactor;
DWORD dwPanRightAmpFactor;
} DSVOLUMEPAN,*PDSVOLUMEPAN;
/*****************************************************************************
* IDirectSoundDevice implementation structure
@ -84,37 +67,38 @@ struct DirectSoundDevice
LONG ref;
GUID guid;
PIDSDRIVER driver;
DSDRIVERDESC drvdesc;
DSDRIVERCAPS drvcaps;
DWORD priolevel;
PWAVEFORMATEX pwfx;
HWAVEOUT hwo;
LPWAVEHDR pwave;
UINT timerID, pwplay, pwqueue, prebuf, helfrags;
DSCAPS drvcaps;
DWORD priolevel, sleeptime;
PWAVEFORMATEX pwfx, primary_pwfx;
UINT playing_offs_bytes, in_mmdev_bytes, prebuf;
DWORD fraglen;
PIDSDRIVERBUFFER hwbuf;
LPBYTE buffer;
DWORD writelead, buflen, state, playpos, mixpos;
int nrofbuffers;
IDirectSoundBufferImpl** buffers;
RTL_RWLOCK buffer_list_lock;
CRITICAL_SECTION mixlock;
PrimaryBufferImpl* primary;
DSBUFFERDESC dsbd;
IDirectSoundBufferImpl *primary;
DWORD speaker_config;
LPBYTE tmp_buffer, mix_buffer;
float *mix_buffer, *tmp_buffer;
DWORD tmp_buffer_len, mix_buffer_len;
DSVOLUMEPAN volpan;
mixfunc mixfunction;
normfunc normfunction;
/* DirectSound3DListener fields */
IDirectSound3DListenerImpl* listener;
DS3DLISTENER ds3dl;
BOOL ds3dl_need_recalc;
IMMDevice *mmdevice;
IAudioClient *client;
IAudioClock *clock;
IAudioStreamVolume *volume;
IAudioRenderClient *render;
HANDLE sleepev, thread;
struct list entry;
};
/* reference counted buffer memory for duplicated buffer memory */
@ -125,356 +109,135 @@ typedef struct BufferMemory
struct list buffers;
} BufferMemory;
ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
ULONG DirectSoundDevice_Release(DirectSoundDevice * device) DECLSPEC_HIDDEN;
HRESULT DirectSoundDevice_Initialize(
DirectSoundDevice ** ppDevice,
LPCGUID lpcGUID);
LPCGUID lpcGUID) DECLSPEC_HIDDEN;
HRESULT DirectSoundDevice_AddBuffer(
DirectSoundDevice * device,
IDirectSoundBufferImpl * pDSB);
HRESULT DirectSoundDevice_RemoveBuffer(
DirectSoundDevice * device,
IDirectSoundBufferImpl * pDSB);
HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
void DirectSoundDevice_RemoveBuffer(DirectSoundDevice * device, IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
HRESULT DirectSoundDevice_CreateSoundBuffer(
DirectSoundDevice * device,
LPCDSBUFFERDESC dsbd,
LPLPDIRECTSOUNDBUFFER ppdsb,
LPUNKNOWN lpunk,
BOOL from8);
BOOL from8) DECLSPEC_HIDDEN;
HRESULT DirectSoundDevice_DuplicateSoundBuffer(
DirectSoundDevice * device,
LPDIRECTSOUNDBUFFER psb,
LPLPDIRECTSOUNDBUFFER ppdsb);
HRESULT DirectSoundDevice_SetCooperativeLevel(
DirectSoundDevice * devcie,
HWND hwnd,
DWORD level);
HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
HRESULT DirectSoundDevice_GetSpeakerConfig(
DirectSoundDevice * device,
LPDWORD lpdwSpeakerConfig);
HRESULT DirectSoundDevice_SetSpeakerConfig(
DirectSoundDevice * device,
DWORD config);
LPLPDIRECTSOUNDBUFFER ppdsb) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirectSoundBuffer implementation structure
*/
struct IDirectSoundBufferImpl
{
/* FIXME: document */
/* IUnknown fields */
const IDirectSoundBuffer8Vtbl *lpVtbl;
LONG ref;
IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
IDirectSoundNotify IDirectSoundNotify_iface;
IDirectSound3DListener IDirectSound3DListener_iface; /* only primary buffer */
IDirectSound3DBuffer IDirectSound3DBuffer_iface; /* only secondary buffer */
IKsPropertySet IKsPropertySet_iface;
LONG numIfaces; /* "in use interfaces" refcount */
LONG ref, refn, ref3D, refiks;
/* IDirectSoundBufferImpl fields */
SecondaryBufferImpl* secondary;
DirectSoundDevice* device;
RTL_RWLOCK lock;
PIDSDRIVERBUFFER hwbuf;
PWAVEFORMATEX pwfx;
BufferMemory* buffer;
LPBYTE tmp_buffer;
DWORD playflags,state,leadin;
DWORD writelead,buflen;
DWORD nAvgBytesPerSec;
DWORD freq, tmp_buffer_len, max_buffer_len;
DWORD freq;
DSVOLUMEPAN volpan;
DSBUFFERDESC dsbd;
/* used for frequency conversion (PerfectPitch) */
ULONG freqneeded, freqAdjust, freqAcc, freqAccNext, resampleinmixer;
ULONG freqneeded;
DWORD firstep;
float freqAcc, freqAdjust, firgain;
/* used for mixing */
DWORD primary_mixpos, buf_mixpos, sec_mixpos;
DWORD sec_mixpos;
/* IDirectSoundNotifyImpl fields */
IDirectSoundNotifyImpl* notify;
/* IDirectSoundNotify fields */
LPDSBPOSITIONNOTIFY notifies;
int nrofnotifies;
PIDSDRIVERNOTIFY hwnotify;
/* DirectSound3DBuffer fields */
IDirectSound3DBufferImpl* ds3db;
DS3DBUFFER ds3db_ds3db;
LONG ds3db_lVolume;
BOOL ds3db_need_recalc;
/* Used for bit depth conversion */
int mix_channels;
bitsgetfunc get, get_aux;
bitsputfunc put, put_aux;
/* IKsPropertySet fields */
IKsBufferPropertySetImpl* iks;
bitsconvertfunc convert;
struct list entry;
};
float get_mono(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel) DECLSPEC_HIDDEN;
void put_mono2stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
HRESULT IDirectSoundBufferImpl_Create(
DirectSoundDevice *device,
IDirectSoundBufferImpl **ppdsb,
LPCDSBUFFERDESC dsbd);
HRESULT IDirectSoundBufferImpl_Destroy(
IDirectSoundBufferImpl *pdsb);
LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN;
HRESULT IDirectSoundBufferImpl_Duplicate(
DirectSoundDevice *device,
IDirectSoundBufferImpl **ppdsb,
IDirectSoundBufferImpl *pdsb);
IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
const IDirectSound3DListenerVtbl ds3dlvt DECLSPEC_HIDDEN;
const IDirectSound3DBufferVtbl ds3dbvt DECLSPEC_HIDDEN;
const IKsPropertySetVtbl iksbvt DECLSPEC_HIDDEN;
/*****************************************************************************
* SecondaryBuffer implementation structure
*/
struct SecondaryBufferImpl
{
const IDirectSoundBuffer8Vtbl *lpVtbl;
LONG ref;
IDirectSoundBufferImpl* dsb;
};
HRESULT SecondaryBufferImpl_Create(
IDirectSoundBufferImpl *dsb,
SecondaryBufferImpl **pdsb);
/*****************************************************************************
* PrimaryBuffer implementation structure
*/
struct PrimaryBufferImpl
{
const IDirectSoundBufferVtbl *lpVtbl;
LONG ref;
DirectSoundDevice* device;
};
HRESULT PrimaryBufferImpl_Create(
DirectSoundDevice * device,
PrimaryBufferImpl **ppdsb,
LPCDSBUFFERDESC dsbd);
/*****************************************************************************
* DirectSoundCaptureDevice implementation structure
*/
struct DirectSoundCaptureDevice
{
/* IDirectSoundCaptureImpl fields */
GUID guid;
LONG ref;
/* DirectSound driver stuff */
PIDSCDRIVER driver;
DSDRIVERDESC drvdesc;
DSCDRIVERCAPS drvcaps;
PIDSCDRIVERBUFFER hwbuf;
/* wave driver info */
HWAVEIN hwi;
/* more stuff */
LPBYTE buffer;
DWORD buflen;
PWAVEFORMATEX pwfx;
IDirectSoundCaptureBufferImpl* capture_buffer;
DWORD state;
LPWAVEHDR pwave;
int nrofpwaves;
int index;
CRITICAL_SECTION lock;
};
HRESULT DirectSoundCaptureDevice_Initialize(
DirectSoundCaptureDevice ** ppDevice,
LPCGUID lpcGUID);
ULONG DirectSoundCaptureDevice_Release(
DirectSoundCaptureDevice * device);
/*****************************************************************************
* IDirectSoundCaptureBuffer implementation structure
*/
struct IDirectSoundCaptureBufferImpl
{
/* IUnknown fields */
const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
LONG ref;
/* IDirectSoundCaptureBufferImpl fields */
DirectSoundCaptureDevice* device;
/* FIXME: don't need this */
LPDSCBUFFERDESC pdscbd;
DWORD flags;
/* IDirectSoundCaptureNotifyImpl fields */
IDirectSoundCaptureNotifyImpl* notify;
LPDSBPOSITIONNOTIFY notifies;
int nrofnotifies;
PIDSDRIVERNOTIFY hwnotify;
};
HRESULT IDirectSoundCaptureBufferImpl_Create(
DirectSoundCaptureDevice *device,
IDirectSoundCaptureBufferImpl ** ppobj,
LPCDSCBUFFERDESC lpcDSCBufferDesc);
/*****************************************************************************
* IDirectSoundFullDuplex implementation structure
*/
struct IDirectSoundFullDuplexImpl
{
/* IUnknown fields */
const IDirectSoundFullDuplexVtbl *lpVtbl;
LONG ref;
/* IDirectSoundFullDuplexImpl fields */
DirectSoundDevice *renderer_device;
DirectSoundCaptureDevice *capture_device;
LPUNKNOWN pUnknown;
LPDIRECTSOUND pDS;
LPDIRECTSOUND8 pDS8;
LPDIRECTSOUNDCAPTURE pDSC;
};
/*****************************************************************************
* IDirectSoundFullDuplex COM components
*/
struct IDirectSoundFullDuplex_IUnknown {
const IUnknownVtbl *lpVtbl;
LONG ref;
IDirectSoundFullDuplexImpl *pdsfd;
};
struct IDirectSoundFullDuplex_IDirectSound {
const IDirectSoundVtbl *lpVtbl;
LONG ref;
IDirectSoundFullDuplexImpl *pdsfd;
};
struct IDirectSoundFullDuplex_IDirectSound8 {
const IDirectSound8Vtbl *lpVtbl;
LONG ref;
IDirectSoundFullDuplexImpl *pdsfd;
};
struct IDirectSoundFullDuplex_IDirectSoundCapture {
const IDirectSoundCaptureVtbl *lpVtbl;
LONG ref;
IDirectSoundFullDuplexImpl *pdsfd;
};
/*****************************************************************************
* IDirectSound3DListener implementation structure
*/
struct IDirectSound3DListenerImpl
{
/* IUnknown fields */
const IDirectSound3DListenerVtbl *lpVtbl;
LONG ref;
/* IDirectSound3DListenerImpl fields */
DirectSoundDevice* device;
};
HRESULT IDirectSound3DListenerImpl_Create(
DirectSoundDevice *device,
IDirectSound3DListenerImpl **pdsl);
/*****************************************************************************
* IKsBufferPropertySet implementation structure
*/
struct IKsBufferPropertySetImpl
{
/* IUnknown fields */
const IKsPropertySetVtbl *lpVtbl;
LONG ref;
/* IKsPropertySetImpl fields */
IDirectSoundBufferImpl* dsb;
};
HRESULT IKsBufferPropertySetImpl_Create(
IDirectSoundBufferImpl *dsb,
IKsBufferPropertySetImpl **piks);
HRESULT IKsBufferPropertySetImpl_Destroy(
IKsBufferPropertySetImpl *piks);
/*****************************************************************************
* IKsPrivatePropertySet implementation structure
*/
struct IKsPrivatePropertySetImpl
{
/* IUnknown fields */
const IKsPropertySetVtbl *lpVtbl;
LONG ref;
};
HRESULT IKsPrivatePropertySetImpl_Create(
REFIID riid,
IKsPrivatePropertySetImpl **piks);
/*****************************************************************************
* IDirectSound3DBuffer implementation structure
*/
struct IDirectSound3DBufferImpl
{
/* IUnknown fields */
const IDirectSound3DBufferVtbl *lpVtbl;
LONG ref;
/* IDirectSound3DBufferImpl fields */
IDirectSoundBufferImpl* dsb;
};
HRESULT IDirectSound3DBufferImpl_Create(
IDirectSoundBufferImpl *dsb,
IDirectSound3DBufferImpl **pds3db);
HRESULT IDirectSound3DBufferImpl_Destroy(
IDirectSound3DBufferImpl *pds3db);
HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
/*******************************************************************************
*/
/* dsound.c */
HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS);
HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
HRESULT DSOUND_Create(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT DSOUND_Create8(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT IDirectSoundImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_ds8) DECLSPEC_HIDDEN;
/* primary.c */
DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign);
HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex, BOOL forced);
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave);
HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN;
LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
LONG capped_refcount_dec(LONG *ref) DECLSPEC_HIDDEN;
/* duplex.c */
HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD);
HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
/* mixer.c */
DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos);
void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len);
void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer);
DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot);
void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN;
void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, float *overshot) DECLSPEC_HIDDEN;
void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
DWORD CALLBACK DSOUND_mixthread(void *ptr) DECLSPEC_HIDDEN;
/* sound3d.c */
void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
/* capture.c */
HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC);
HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
LPDIRECTSOUNDCAPTURE iface,
LPCDSCBUFFERDESC lpcDSCBufferDesc,
LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
LPUNKNOWN pUnk);
HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
LPDIRECTSOUNDCAPTURE iface,
LPDSCCAPS lpDSCCaps);
HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
LPDIRECTSOUNDCAPTURE iface,
LPCGUID lpcGUID);
HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_dsc8) DECLSPEC_HIDDEN;
#define STATE_STOPPED 0
#define STATE_STARTING 1
@ -482,14 +245,22 @@ HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
#define STATE_CAPTURING 2
#define STATE_STOPPING 3
#define DSOUND_FREQSHIFT (20)
extern CRITICAL_SECTION DSOUND_renderers_lock DECLSPEC_HIDDEN;
extern CRITICAL_SECTION DSOUND_capturers_lock DECLSPEC_HIDDEN;
extern struct list DSOUND_capturers DECLSPEC_HIDDEN;
extern struct list DSOUND_renderers DECLSPEC_HIDDEN;
extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
extern WCHAR wine_vxd_drv[] DECLSPEC_HIDDEN;
HRESULT mmErr(UINT err);
void setup_dsound_options(void);
const char * dumpCooperativeLevel(DWORD level);
void setup_dsound_options(void) DECLSPEC_HIDDEN;
HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device) DECLSPEC_HIDDEN;
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;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,534 +0,0 @@
/*
* self-registerable dll functions for dsound.dll
*
* Copyright (C) 2003 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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 <stdarg.h>
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#include <windef.h>
#include <winbase.h>
//#include "winuser.h"
#include <winreg.h>
#include <mmsystem.h>
#include <dsound.h>
#include <wine/debug.h>
#include <wine/unicode.h>
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
static LSTATUS (WINAPI *pRegDeleteTreeW)(HKEY,LPCWSTR);
static LSTATUS (WINAPI *pRegDeleteTreeA)(HKEY,LPCSTR);
/*
* Near the bottom of this file are the exported DllRegisterServer and
* DllUnregisterServer, which make all this worthwhile.
*/
/***********************************************************************
* interface for self-registering
*/
struct regsvr_interface
{
IID const *iid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
IID const *base_iid; /* can be NULL to omit */
int num_methods; /* can be <0 to omit */
CLSID const *ps_clsid; /* can be NULL to omit */
CLSID const *ps_clsid32; /* can be NULL to omit */
};
static HRESULT register_interfaces(struct regsvr_interface const *list);
static HRESULT unregister_interfaces(struct regsvr_interface const *list);
struct regsvr_coclass
{
CLSID const *clsid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
LPCSTR ips; /* can be NULL to omit */
LPCSTR ips32; /* can be NULL to omit */
LPCSTR ips32_tmodel; /* can be NULL to omit */
LPCSTR progid; /* can be NULL to omit */
LPCSTR viprogid; /* can be NULL to omit */
LPCSTR progid_extra; /* can be NULL to omit */
};
static HRESULT register_coclasses(struct regsvr_coclass const *list);
static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
/***********************************************************************
* static string constants
*/
static WCHAR const interface_keyname[10] = {
'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
static WCHAR const base_ifa_keyname[14] = {
'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
'e', 0 };
static WCHAR const num_methods_keyname[11] = {
'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
static WCHAR const ps_clsid_keyname[15] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', 0 };
static WCHAR const ps_clsid32_keyname[17] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', '3', '2', 0 };
static WCHAR const clsid_keyname[6] = {
'C', 'L', 'S', 'I', 'D', 0 };
static WCHAR const curver_keyname[7] = {
'C', 'u', 'r', 'V', 'e', 'r', 0 };
static WCHAR const ips_keyname[13] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
0 };
static WCHAR const ips32_keyname[15] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
'3', '2', 0 };
static WCHAR const progid_keyname[7] = {
'P', 'r', 'o', 'g', 'I', 'D', 0 };
static WCHAR const viprogid_keyname[25] = {
'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
0 };
static char const tmodel_valuename[] = "ThreadingModel";
/***********************************************************************
* static helper functions
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
WCHAR const *value);
static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
char const *value);
static LONG register_progid(WCHAR const *clsid,
char const *progid, char const *curver_progid,
char const *name, char const *extra);
/***********************************************************************
* register_interfaces
*/
static HRESULT register_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
HKEY iid_key;
StringFromGUID2(list->iid, buf, 39);
res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_interface_key;
if (list->name) {
res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->base_iid) {
res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (0 <= list->num_methods) {
static WCHAR const fmt[3] = { '%', 'd', 0 };
HKEY key;
res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
sprintfW(buf, fmt, list->num_methods);
res = RegSetValueExW(key, NULL, 0, REG_SZ,
(CONST BYTE*)buf,
(lstrlenW(buf) + 1) * sizeof(WCHAR));
RegCloseKey(key);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid) {
res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid32) {
res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
error_close_iid_key:
RegCloseKey(iid_key);
}
error_close_interface_key:
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_interfaces
*/
static HRESULT unregister_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
KEY_READ | KEY_WRITE, &interface_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->iid, buf, 39);
res = pRegDeleteTreeW(interface_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
}
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* register_coclasses
*/
static HRESULT register_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
HKEY clsid_key;
StringFromGUID2(list->clsid, buf, 39);
res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->name) {
res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips) {
res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips32) {
HKEY ips32_key;
res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&ips32_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
(CONST BYTE*)list->ips32,
lstrlenA(list->ips32) + 1);
if (res == ERROR_SUCCESS && list->ips32_tmodel)
res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
(CONST BYTE*)list->ips32_tmodel,
strlen(list->ips32_tmodel) + 1);
RegCloseKey(ips32_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->progid) {
res = register_key_defvalueA(clsid_key, progid_keyname,
list->progid);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = register_progid(buf, list->progid, NULL,
list->name, list->progid_extra);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->viprogid) {
res = register_key_defvalueA(clsid_key, viprogid_keyname,
list->viprogid);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = register_progid(buf, list->viprogid, list->progid,
list->name, list->progid_extra);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
error_close_clsid_key:
RegCloseKey(clsid_key);
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_coclasses
*/
static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
KEY_READ | KEY_WRITE, &coclass_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->clsid, buf, 39);
res = pRegDeleteTreeW(coclass_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->progid) {
res = pRegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
if (list->viprogid) {
res = pRegDeleteTreeA(HKEY_CLASSES_ROOT, list->viprogid);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* regsvr_key_guid
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
{
WCHAR buf[39];
StringFromGUID2(guid, buf, 39);
return register_key_defvalueW(base, name, buf);
}
/***********************************************************************
* regsvr_key_defvalueW
*/
static LONG register_key_defvalueW(
HKEY base,
WCHAR const *name,
WCHAR const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
(lstrlenW(value) + 1) * sizeof(WCHAR));
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_key_defvalueA
*/
static LONG register_key_defvalueA(
HKEY base,
WCHAR const *name,
char const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
lstrlenA(value) + 1);
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_progid
*/
static LONG register_progid(
WCHAR const *clsid,
char const *progid,
char const *curver_progid,
char const *name,
char const *extra)
{
LONG res;
HKEY progid_key;
res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
NULL, 0, KEY_READ | KEY_WRITE, NULL,
&progid_key, NULL);
if (res != ERROR_SUCCESS) return res;
if (name) {
res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
(CONST BYTE*)name, strlen(name) + 1);
if (res != ERROR_SUCCESS) goto error_close_progid_key;
}
if (clsid) {
res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
if (res != ERROR_SUCCESS) goto error_close_progid_key;
}
if (curver_progid) {
res = register_key_defvalueA(progid_key, curver_keyname,
curver_progid);
if (res != ERROR_SUCCESS) goto error_close_progid_key;
}
if (extra) {
HKEY extra_key;
res = RegCreateKeyExA(progid_key, extra, 0,
NULL, 0, KEY_READ | KEY_WRITE, NULL,
&extra_key, NULL);
if (res == ERROR_SUCCESS)
RegCloseKey(extra_key);
}
error_close_progid_key:
RegCloseKey(progid_key);
return res;
}
/***********************************************************************
* coclass list
*/
static GUID const CLSID_DirectSoundBufferConfig = {
0xB2F586D4, 0x5558, 0x49D1, {0xA0,0x7B,0x32,0x49,0xDB,0xBB,0x33,0xC2} };
static struct regsvr_coclass const coclass_list[] = {
{ &CLSID_DirectSound,
"DirectSound Object",
NULL,
"dsound.dll",
"Both"
},
{ &CLSID_DirectSound8,
"DirectSound 8.0 Object",
NULL,
"dsound.dll",
"Both"
},
{ &CLSID_DirectSoundBufferConfig,
"DirectSoundBufferConfig Object",
NULL,
"dsound.dll",
"Both"
},
{ &CLSID_DirectSoundCapture,
"DirectSoundCapture Object",
NULL,
"dsound.dll",
"Both"
},
{ &CLSID_DirectSoundCapture8,
"DirectSoundCapture 8.0 Object",
NULL,
"dsound.dll",
"Both"
},
{ &CLSID_DirectSoundFullDuplex,
"DirectSoundFullDuplex Object",
NULL,
"dsound.dll",
"Both"
},
{ NULL } /* list terminator */
};
/***********************************************************************
* interface list
*/
static struct regsvr_interface const interface_list[] = {
{ NULL } /* list terminator */
};
/***********************************************************************
* DllRegisterServer (DSOUND.@)
*/
HRESULT WINAPI DllRegisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = register_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = register_interfaces(interface_list);
return hr;
}
/***********************************************************************
* DllUnregisterServer (DSOUND.@)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
HRESULT hr;
HMODULE advapi32 = GetModuleHandleA("advapi32");
if (!advapi32) return E_FAIL;
pRegDeleteTreeA = (void *) GetProcAddress(advapi32, "RegDeleteTreeA");
pRegDeleteTreeW = (void *) GetProcAddress(advapi32, "RegDeleteTreeW");
if (!pRegDeleteTreeA || !pRegDeleteTreeW) return E_FAIL;
TRACE("\n");
hr = unregister_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = unregister_interfaces(interface_list);
return hr;
}

File diff suppressed because it is too large Load diff

View file

@ -1,8 +0,0 @@
Makefile
capture.ok
ds3d.ok
ds3d8.ok
dsound.ok
dsound8.ok
propset.ok
testlist.c

View file

@ -1,19 +0,0 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = dsound.dll
IMPORTS = dsound ole32 version user32 kernel32
EXTRALIBS = -ldxguid -luuid -ldxerr8
CTESTS = \
capture.c \
ds3d.c \
ds3d8.c \
dsound.c \
dsound8.c \
propset.c
@MAKE_TEST_RULES@
### Dependencies:

View file

@ -1,723 +0,0 @@
/*
* Unit tests for capture functions
*
* Copyright (c) 2002 Francois Gouget
* Copyright (c) 2003 Robert Reif
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#include <windows.h>
#include <stdio.h>
#include "wine/test.h"
#include "dsound.h"
#include "mmreg.h"
#include "dxerr8.h"
#include "dsconf.h"
#include "dsound_test.h"
#define NOTIFICATIONS 5
static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
static HRESULT (WINAPI *pDirectSoundCaptureEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
static const char * get_format_str(WORD format)
{
static char msg[32];
#define WAVE_FORMAT(f) case f: return #f
switch (format) {
WAVE_FORMAT(WAVE_FORMAT_PCM);
WAVE_FORMAT(WAVE_FORMAT_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD);
WAVE_FORMAT(WAVE_FORMAT_ALAW);
WAVE_FORMAT(WAVE_FORMAT_MULAW);
WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_DIGISTD);
WAVE_FORMAT(WAVE_FORMAT_DIGIFIX);
WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_SONARC);
WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH);
WAVE_FORMAT(WAVE_FORMAT_ECHOSC1);
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36);
WAVE_FORMAT(WAVE_FORMAT_APTX);
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10);
WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2);
WAVE_FORMAT(WAVE_FORMAT_GSM610);
WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME);
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC);
WAVE_FORMAT(WAVE_FORMAT_DIGIREAL);
WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM);
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10);
WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM);
WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_MPEG);
WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3);
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM);
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8);
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10);
WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND);
WAVE_FORMAT(WAVE_FORMAT_OLIGSM);
WAVE_FORMAT(WAVE_FORMAT_OLIADPCM);
WAVE_FORMAT(WAVE_FORMAT_OLICELP);
WAVE_FORMAT(WAVE_FORMAT_OLISBC);
WAVE_FORMAT(WAVE_FORMAT_OLIOPR);
WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT);
WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE);
}
#undef WAVE_FORMAT
sprintf(msg, "Unknown(0x%04x)", format);
return msg;
}
static char * format_string(WAVEFORMATEX* wfx)
{
static char str[64];
sprintf(str, "%5ldx%2dx%d %s",
wfx->nSamplesPerSec, wfx->wBitsPerSample, wfx->nChannels,
get_format_str(wfx->wFormatTag));
return str;
}
static void IDirectSoundCapture_test(LPDIRECTSOUNDCAPTURE dsco,
BOOL initialized, LPCGUID lpGuid)
{
HRESULT rc;
DSCCAPS dsccaps;
int ref;
IUnknown * unknown;
IDirectSoundCapture * dsc;
/* Try to Query for objects */
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IUnknown,
(LPVOID*)&unknown);
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IUnknown) "
"failed: %s\n", DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSoundCapture_Release(unknown);
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IDirectSoundCapture,
(LPVOID*)&dsc);
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IDirectSoundCapture) "
"failed: %s\n", DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSoundCapture_Release(dsc);
if (initialized == FALSE) {
/* try unitialized object */
rc=IDirectSoundCapture_GetCaps(dsco,0);
ok(rc==DSERR_UNINITIALIZED, "IDirectSoundCapture_GetCaps(NULL) "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
ok(rc==DSERR_UNINITIALIZED,"IDirectSoundCapture_GetCaps() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"IDirectSoundCapture_Initialize() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DSERR_NODRIVER) {
trace(" No Driver\n");
goto EXIT;
} else if (rc==E_FAIL) {
trace(" No Device\n");
goto EXIT;
} else if (rc==DSERR_ALLOCATED) {
trace(" Already In Use\n");
goto EXIT;
}
}
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSoundCapture_Initialize() "
"should have returned DSERR_ALREADYINITIALIZED: %s\n",
DXGetErrorString8(rc));
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSoundCapture_GetCaps(dsco, 0);
ok(rc==DSERR_INVALIDPARAM, "IDirectSoundCapture_GetCaps(NULL) "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
ZeroMemory(&dsccaps, sizeof(dsccaps));
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound_GetCaps(dsco, &dsccaps);
ok(rc==DSERR_INVALIDPARAM, "IDirectSound_GetCaps() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
dsccaps.dwSize=sizeof(dsccaps);
/* DSOUND: Running on a certified driver */
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
ok(rc==DS_OK, "IDirectSoundCapture_GetCaps() failed: %s\n",
DXGetErrorString8(rc));
EXIT:
ref=IDirectSoundCapture_Release(dsco);
ok(ref==0, "IDirectSoundCapture_Release() has %d references, "
"should have 0\n", ref);
}
static void IDirectSoundCapture_tests(void)
{
HRESULT rc;
LPDIRECTSOUNDCAPTURE dsco=NULL;
trace("Testing IDirectSoundCapture\n");
/* try the COM class factory method of creation with no device specified */
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSoundCapture, (void**)&dsco);
ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s\n",
DXGetErrorString8(rc));
if (rc==REGDB_E_CLASSNOTREG) {
trace(" Class Not Registered\n");
return;
}
if (dsco)
IDirectSoundCapture_test(dsco, FALSE, NULL);
/* try the COM class factory method of creation with default capture
* device specified */
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSoundCapture, (void**)&dsco);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s\n",
DXGetErrorString8(rc));
if (dsco)
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultCapture);
/* try the COM class factory method of creation with default voice
* capture device specified */
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSoundCapture, (void**)&dsco);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s\n",
DXGetErrorString8(rc));
if (dsco)
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultVoiceCapture);
/* try the COM class factory method of creation with a bad
* IID specified */
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
&CLSID_DirectSoundPrivate, (void**)&dsco);
ok(rc==E_NOINTERFACE,
"CoCreateInstance(CLSID_DirectSoundCapture,CLSID_DirectSoundPrivate) "
"should have failed: %s\n",DXGetErrorString8(rc));
/* try with no device specified */
rc=pDirectSoundCaptureCreate(NULL,&dsco,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCaptureCreate(NULL) failed: %s\n",DXGetErrorString8(rc));
if (rc==S_OK && dsco)
IDirectSoundCapture_test(dsco, TRUE, NULL);
/* try with default capture device specified */
rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultCapture,&dsco,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCaptureCreate(DSDEVID_DefaultCapture) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && dsco)
IDirectSoundCapture_test(dsco, TRUE, NULL);
/* try with default voice capture device specified */
rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultVoiceCapture,&dsco,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCaptureCreate(DSDEVID_DefaultVoiceCapture) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && dsco)
IDirectSoundCapture_test(dsco, TRUE, NULL);
/* try with a bad device specified */
rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultVoicePlayback,&dsco,NULL);
ok(rc==DSERR_NODRIVER,
"DirectSoundCaptureCreate(DSDEVID_DefaultVoicePlatback) "
"should have failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && dsco)
IDirectSoundCapture_Release(dsco);
}
typedef struct {
char* wave;
DWORD wave_len;
LPDIRECTSOUNDCAPTUREBUFFER dscbo;
LPWAVEFORMATEX wfx;
DSBPOSITIONNOTIFY posnotify[NOTIFICATIONS];
HANDLE event[NOTIFICATIONS];
LPDIRECTSOUNDNOTIFY notify;
DWORD buffer_size;
DWORD read;
DWORD offset;
DWORD size;
DWORD last_pos;
} capture_state_t;
static int capture_buffer_service(capture_state_t* state)
{
HRESULT rc;
LPVOID ptr1,ptr2;
DWORD len1,len2;
DWORD capture_pos,read_pos;
rc=IDirectSoundCaptureBuffer_GetCurrentPosition(state->dscbo,&capture_pos,
&read_pos);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCurrentPosition() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
return 0;
rc=IDirectSoundCaptureBuffer_Lock(state->dscbo,state->offset,state->size,
&ptr1,&len1,&ptr2,&len2,0);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Lock() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
return 0;
rc=IDirectSoundCaptureBuffer_Unlock(state->dscbo,ptr1,len1,ptr2,len2);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Unlock() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
return 0;
state->offset = (state->offset + state->size) % state->buffer_size;
return 1;
}
static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
LPDIRECTSOUNDCAPTUREBUFFER dscbo, int record)
{
HRESULT rc;
DSCBCAPS dscbcaps;
WAVEFORMATEX wfx;
DWORD size,status;
capture_state_t state;
int i, ref;
/* Private dsound.dll: Error: Invalid caps pointer */
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
"have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
/* Private dsound.dll: Error: Invalid caps pointer */
dscbcaps.dwSize=0;
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
"have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
dscbcaps.dwSize=sizeof(dscbcaps);
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCaps() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && winetest_debug > 1) {
trace(" Caps: size = %ld flags=0x%08lx buffer size=%ld\n",
dscbcaps.dwSize,dscbcaps.dwFlags,dscbcaps.dwBufferBytes);
}
/* Query the format size. Note that it may not match sizeof(wfx) */
/* Private dsound.dll: Error: Either pwfxFormat or pdwSizeWritten must
* be non-NULL */
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetFormat() should "
"have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
size=0;
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,&size);
ok(rc==DS_OK && size!=0,"IDirectSoundCaptureBuffer_GetFormat() should "
"have returned the needed size: rc=%s, size=%ld\n",
DXGetErrorString8(rc),size);
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,&wfx,sizeof(wfx),NULL);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetFormat() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && winetest_debug > 1) {
trace(" Format: tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
}
/* Private dsound.dll: Error: Invalid status pointer */
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetStatus() should "
"have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && winetest_debug > 1) {
trace(" Status=0x%04lx\n",status);
}
ZeroMemory(&state, sizeof(state));
state.dscbo=dscbo;
state.wfx=&wfx;
state.buffer_size = dscbcaps.dwBufferBytes;
for (i = 0; i < NOTIFICATIONS; i++)
state.event[i] = CreateEvent( NULL, FALSE, FALSE, NULL );
state.size = dscbcaps.dwBufferBytes / NOTIFICATIONS;
rc=IDirectSoundCaptureBuffer_QueryInterface(dscbo,&IID_IDirectSoundNotify,
(void **)&(state.notify));
ok((rc==DS_OK)&&(state.notify!=NULL),
"IDirectSoundCaptureBuffer_QueryInterface() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
return;
for (i = 0; i < NOTIFICATIONS; i++) {
state.posnotify[i].dwOffset = (i * state.size) + state.size - 1;
state.posnotify[i].hEventNotify = state.event[i];
}
rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS,
state.posnotify);
ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed: %s\n",
DXGetErrorString8(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;
if (record) {
rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
return;
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %s\n",
DXGetErrorString8(rc));
ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING),
"GetStatus: bad status: %lx\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);
ok(rc==(WAIT_OBJECT_0+(i%NOTIFICATIONS)),
"WaitForMultipleObjects failed: 0x%lx\n",rc);
if (rc!=(WAIT_OBJECT_0+(i%NOTIFICATIONS))) {
ok((rc==WAIT_TIMEOUT)||(rc==WAIT_FAILED),
"Wrong notification: should be %d, got %ld\n",
i%NOTIFICATIONS,rc-WAIT_OBJECT_0);
}
if (!capture_buffer_service(&state))
break;
}
rc=IDirectSoundCaptureBuffer_Stop(dscbo);
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
return;
}
}
static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
LPCSTR lpcstrModule, LPVOID lpContext)
{
HRESULT rc;
LPDIRECTSOUNDCAPTURE dsco=NULL;
LPDIRECTSOUNDCAPTUREBUFFER dscbo=NULL;
DSCBUFFERDESC bufdesc;
WAVEFORMATEX wfx;
DSCCAPS dsccaps;
DWORD f;
int ref;
/* Private dsound.dll: Error: Invalid interface buffer */
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
rc=pDirectSoundCaptureCreate(lpGuid,NULL,NULL);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCaptureCreate() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
ref=IDirectSoundCapture_Release(dsco);
ok(ref==0,"IDirectSoundCapture_Release() has %d references, should "
"have 0\n",ref);
}
rc=pDirectSoundCaptureCreate(lpGuid,&dsco,NULL);
ok((rc==DS_OK)||(rc==DSERR_NODRIVER)||(rc==E_FAIL)||(rc==DSERR_ALLOCATED),
"DirectSoundCaptureCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK) {
if (rc==DSERR_NODRIVER)
trace(" No Driver\n");
else if (rc==E_FAIL)
trace(" No Device\n");
else if (rc==DSERR_ALLOCATED)
trace(" Already In Use\n");
goto EXIT;
}
/* Private dsound.dll: Error: Invalid caps buffer */
rc=IDirectSoundCapture_GetCaps(dsco,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* Private dsound.dll: Error: Invalid caps buffer */
dsccaps.dwSize=0;
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
dsccaps.dwSize=sizeof(dsccaps);
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
ok(rc==DS_OK,"IDirectSoundCapture_GetCaps() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && winetest_debug > 1) {
trace(" Caps: size=%ld flags=0x%08lx formats=%05lx channels=%ld\n",
dsccaps.dwSize,dsccaps.dwFlags,dsccaps.dwFormats,
dsccaps.dwChannels);
}
/* Private dsound.dll: Error: Invalid size */
/* Private dsound.dll: Error: Invalid capture buffer description */
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=0;
bufdesc.dwFlags=0;
bufdesc.dwBufferBytes=0;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=NULL;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
"should have 0\n",ref);
}
/* Private dsound.dll: Error: Invalid buffer size */
/* Private dsound.dll: Error: Invalid capture buffer description */
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=0;
bufdesc.dwBufferBytes=0;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=NULL;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
"should have returned DSERR_INVALIDPARAM, returned %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
"should have 0\n",ref);
}
/* Private dsound.dll: Error: Invalid buffer size */
/* Private dsound.dll: Error: Invalid capture buffer description */
ZeroMemory(&bufdesc, sizeof(bufdesc));
ZeroMemory(&wfx, sizeof(wfx));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=0;
bufdesc.dwBufferBytes=0;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
"should have returned DSERR_INVALIDPARAM, returned :%s\n",
DXGetErrorString8(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
"should have 0\n",ref);
}
/* Private dsound.dll: Error: Invalid buffer size */
/* Private dsound.dll: Error: Invalid capture buffer description */
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=0;
bufdesc.dwBufferBytes=0;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
"should have 0\n",ref);
}
for (f=0;f<NB_FORMATS;f++) {
dscbo=NULL;
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
formats[f][2]);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=0;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive)
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(((rc==DS_OK)&&(dscbo!=NULL))||(rc==DSERR_BADFORMAT)||
((rc==DSERR_NODRIVER))||(rc==DSERR_ALLOCATED)||(rc==E_INVALIDARG),
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
"%s capture buffer: %s\n",format_string(&wfx),DXGetErrorString8(rc));
if (rc==DS_OK) {
test_capture_buffer(dsco, dscbo, winetest_interactive);
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
"should have 0\n",ref);
} else if (rc==DSERR_BADFORMAT) {
ok(!(dsccaps.dwFormats & formats[f][3]),
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
"capture buffer: format listed as supported but using it failed\n");
if (!(dsccaps.dwFormats & formats[f][3]))
trace(" Format not supported: %s\n", format_string(&wfx));
} else if (rc==DSERR_NODRIVER) {
trace(" No Driver\n");
} else if (rc==DSERR_ALLOCATED) {
trace(" Already In Use\n");
} else if (rc==E_INVALIDARG) { /* try the old version struct */
DSCBUFFERDESC1 bufdesc1;
ZeroMemory(&bufdesc1, sizeof(bufdesc1));
bufdesc1.dwSize=sizeof(bufdesc1);
bufdesc1.dwFlags=0;
bufdesc1.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc1.dwReserved=0;
bufdesc1.lpwfxFormat=&wfx;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,
(DSCBUFFERDESC*)&bufdesc1,&dscbo,NULL);
ok(rc==DS_OK,
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
"%s capture buffer: %s\n",format_string(&wfx),
DXGetErrorString8(rc));
if (rc==DS_OK) {
test_capture_buffer(dsco, dscbo, winetest_interactive);
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d "
"references, should have 0\n",ref);
}
}
}
/* try a non PCM format */
#if 0
init_format(&wfx,WAVE_FORMAT_MULAW,8000,8,1);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive)
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok((rc==DS_OK)&&(dscbo!=NULL),"IDirectSoundCapture_CreateCaptureBuffer() "
"failed to create a capture buffer: %s\n",DXGetErrorString8(rc));
if ((rc==DS_OK)&&(dscbo!=NULL)) {
test_capture_buffer(dsco, dscbo, winetest_interactive);
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
"should have 0\n",ref);
}
#endif
/* Try an invalid format to test error handling */
#if 0
init_format(&wfx,WAVE_FORMAT_PCM,2000000,16,2);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive)
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc!=DS_OK,"IDirectSoundCapture_CreateCaptureBuffer() should have failed "
"at 2 MHz %s\n",DXGetErrorString8(rc));
#endif
EXIT:
if (dsco!=NULL) {
ref=IDirectSoundCapture_Release(dsco);
ok(ref==0,"IDirectSoundCapture_Release() has %d references, should "
"have 0\n",ref);
}
return TRUE;
}
static void capture_tests(void)
{
HRESULT rc;
rc=pDirectSoundCaptureEnumerateA(&dscenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundCaptureEnumerateA() failed: %s\n",
DXGetErrorString8(rc));
}
START_TEST(capture)
{
HMODULE hDsound;
CoInitialize(NULL);
hDsound = LoadLibraryA("dsound.dll");
if (!hDsound) {
trace("dsound.dll not found\n");
return;
}
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate");
pDirectSoundCaptureEnumerateA=(void*)GetProcAddress(hDsound,"DirectSoundCaptureEnumerateA");
if (!pDirectSoundCaptureCreate || !pDirectSoundCaptureEnumerateA)
{
trace("capture test skipped\n");
return;
}
IDirectSoundCapture_tests();
capture_tests();
CoUninitialize();
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,947 +0,0 @@
/*
* Tests basic sound playback in DirectSound.
* In particular we test each standard Windows sound format to make sure
* we handle the sound card/driver quirks correctly.
*
* Part of this test involves playing test tones. But this only makes
* sense if someone is going to carefully listen to it, and would only
* bother everyone else.
* So this is only done if the test is being run in interactive mode.
*
* Copyright (c) 2002-2004 Francois Gouget
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#include <windows.h>
#include "wine/test.h"
#include "dsound.h"
#include "dxerr8.h"
#include "dsconf.h"
#include "dsound_test.h"
static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
LPCGUID lpGuid)
{
HRESULT rc;
DSCAPS dscaps;
int ref;
IUnknown * unknown;
IDirectSound * ds;
IDirectSound8 * ds8;
DWORD speaker_config, new_speaker_config;
/* Try to Query for objects */
rc=IDirectSound_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IUnknown) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSound_Release(unknown);
rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IDirectSound) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSound_Release(ds);
rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) "
"should have failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSound8_Release(ds8);
if (initialized == FALSE) {
/* try unitialized object */
rc=IDirectSound_GetCaps(dso,0);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps(NULL) "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound_Compact(dso);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_Compact() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetSpeakerConfig() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound_Initialize(dso,lpGuid);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"IDirectSound_Initialize() failed: %s\n",DXGetErrorString8(rc));
if (rc==DSERR_NODRIVER) {
trace(" No Driver\n");
goto EXIT;
} else if (rc==E_FAIL) {
trace(" No Device\n");
goto EXIT;
} else if (rc==DSERR_ALLOCATED) {
trace(" Already In Use\n");
goto EXIT;
}
}
rc=IDirectSound_Initialize(dso,lpGuid);
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound_Initialize() "
"should have returned DSERR_ALREADYINITIALIZED: %s\n",
DXGetErrorString8(rc));
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound_GetCaps(dso,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps(NULL) "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
ZeroMemory(&dscaps, sizeof(dscaps));
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
dscaps.dwSize=sizeof(dscaps);
/* DSOUND: Running on a certified driver */
rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
rc=IDirectSound_Compact(dso);
ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound_Compact() failed: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound_Compact(dso);
ok(rc==DS_OK,"IDirectSound_Compact() failed: %s\n",DXGetErrorString8(rc));
rc=IDirectSound_GetSpeakerConfig(dso,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetSpeakerConfig(NULL) "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n",
DXGetErrorString8(rc));
speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
DSSPEAKER_GEOMETRY_WIDE);
rc=IDirectSound_SetSpeakerConfig(dso,speaker_config);
ok(rc==DS_OK,"IDirectSound_SetSpeakerConfig() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK) {
rc=IDirectSound_GetSpeakerConfig(dso,&new_speaker_config);
ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && speaker_config!=new_speaker_config)
trace("IDirectSound_GetSpeakerConfig() failed to set speaker "
"config: expected 0x%08lx, got 0x%08lx\n",
speaker_config,new_speaker_config);
}
EXIT:
ref=IDirectSound_Release(dso);
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
}
static void IDirectSound_tests(void)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
trace("Testing IDirectSound\n");
/* try the COM class factory method of creation with no device specified */
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
DXGetErrorString8(rc));
if (dso)
IDirectSound_test(dso, FALSE, NULL);
/* try the COM class factory method of creation with default playback
* device specified */
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
DXGetErrorString8(rc));
if (dso)
IDirectSound_test(dso, FALSE, &DSDEVID_DefaultPlayback);
/* try the COM class factory method of creation with default voice
* playback device specified */
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
DXGetErrorString8(rc));
if (dso)
IDirectSound_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
/* try the COM class factory method of creation with a bad
* IID specified */
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
&CLSID_DirectSoundPrivate, (void**)&dso);
ok(rc==E_NOINTERFACE,
"CoCreateInstance(CLSID_DirectSound,CLSID_DirectSoundPrivate) "
"should have failed: %s\n",DXGetErrorString8(rc));
/* try the COM class factory method of creation with a bad
* GUID and IID specified */
rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound, (void**)&dso);
ok(rc==REGDB_E_CLASSNOTREG,
"CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound) "
"should have failed: %s\n",DXGetErrorString8(rc));
/* try with no device specified */
rc=DirectSoundCreate(NULL,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate(NULL) failed: %s\n",DXGetErrorString8(rc));
if (rc==S_OK && dso)
IDirectSound_test(dso, TRUE, NULL);
/* try with default playback device specified */
rc=DirectSoundCreate(&DSDEVID_DefaultPlayback,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate(DSDEVID_DefaultPlayback) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && dso)
IDirectSound_test(dso, TRUE, NULL);
/* try with default voice playback device specified */
rc=DirectSoundCreate(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate(DSDEVID_DefaultVoicePlayback) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && dso)
IDirectSound_test(dso, TRUE, NULL);
/* try with a bad device specified */
rc=DirectSoundCreate(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
ok(rc==DSERR_NODRIVER,"DirectSoundCreate(DSDEVID_DefaultVoiceCapture) "
"should have failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && dso)
IDirectSound_Release(dso);
}
static HRESULT test_dsound(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
int ref;
/* DSOUND: Error: Invalid interface buffer */
rc=DirectSoundCreate(lpGuid,0,NULL);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Try the enumerated device */
IDirectSound_test(dso, TRUE, lpGuid);
/* Try the COM class factory method of creation with enumerated device */
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
DXGetErrorString8(rc));
if (dso)
IDirectSound_test(dso, FALSE, lpGuid);
/* Create a DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
LPDIRECTSOUND dso1=NULL;
/* Create a second DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso1,NULL);
ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
/* Release the second DirectSound object */
ref=IDirectSound_Release(dso1);
ok(ref==0,"IDirectSound_Release() has %d references, should have "
"0\n",ref);
ok(dso!=dso1,"DirectSound objects should be unique: dso=%p,dso1=%p\n",dso,dso1);
}
/* Release the first DirectSound object */
ref=IDirectSound_Release(dso);
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
ref);
if (ref!=0)
return DSERR_GENERIC;
} else
return rc;
/* Create a DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
LPDIRECTSOUNDBUFFER secondary;
DSBUFFERDESC bufdesc;
WAVEFORMATEX wfx;
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary!=NULL,
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
"buffer %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
LPDIRECTSOUND3DBUFFER buffer3d;
rc=IDirectSound_QueryInterface(secondary, &IID_IDirectSound3DBuffer,
(void **)&buffer3d);
ok(rc==DS_OK && buffer3d!=NULL,"IDirectSound_QueryInterface() "
"failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && buffer3d!=NULL) {
ref=IDirectSound3DBuffer_AddRef(buffer3d);
ok(ref==2,"IDirectSound3DBuffer_AddRef() has %d references, "
"should have 2\n",ref);
}
ref=IDirectSoundBuffer_AddRef(secondary);
ok(ref==2,"IDirectSoundBuffer_AddRef() has %d references, "
"should have 2\n",ref);
}
/* release with buffer */
ref=IDirectSound_Release(dso);
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
ref);
if (ref!=0)
return DSERR_GENERIC;
} else
return rc;
return DS_OK;
}
static HRESULT test_primary(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx;
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Get the device capabilities */
ZeroMemory(&dscaps, sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* DSOUND: Error: Invalid buffer description pointer */
rc=IDirectSound_CreateSoundBuffer(dso,0,0,NULL);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound_CreateSoundBuffer() should have failed: %s\n",
DXGetErrorString8(rc));
/* DSOUND: Error: Invalid buffer description pointer */
rc=IDirectSound_CreateSoundBuffer(dso,0,&primary,NULL);
ok(rc==DSERR_INVALIDPARAM && primary==0,
"IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
"dsbo=%p\n",DXGetErrorString8(rc),primary);
/* DSOUND: Error: Invalid buffer description pointer */
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,0,NULL);
ok(rc==DSERR_INVALIDPARAM && primary==0,
"IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
"dsbo=0x%p\n",DXGetErrorString8(rc),primary);
ZeroMemory(&bufdesc, sizeof(bufdesc));
/* DSOUND: Error: Invalid size */
/* DSOUND: Error: Invalid buffer description */
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DSERR_INVALIDPARAM && primary==0,
"IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
"primary=%p\n",DXGetErrorString8(rc),primary);
/* We must call SetCooperativeLevel before calling CreateSoundBuffer */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* Testing the primary buffer */
primary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
bufdesc.lpwfxFormat = &wfx;
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2);
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL)
IDirectSoundBuffer_Release(primary);
primary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
"IDirectSound_CreateSoundBuffer() failed to create a primary buffer: "
"%s\n",DXGetErrorString8(rc));
if (rc==DSERR_CONTROLUNAVAIL)
trace(" No Primary\n");
else if (rc==DS_OK && primary!=NULL) {
LONG vol;
/* Try to create a second primary buffer */
/* DSOUND: Error: The primary buffer already exists.
* Any changes made to the buffer description will be ignored. */
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
ok(rc==DS_OK && second==primary,
"IDirectSound_CreateSoundBuffer() should have returned original "
"primary buffer: %s\n",DXGetErrorString8(rc));
ref=IDirectSoundBuffer_Release(second);
ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 1\n",ref);
/* Try to duplicate a primary buffer */
/* DSOUND: Error: Can't duplicate primary buffers */
rc=IDirectSound_DuplicateSoundBuffer(dso,primary,&third);
/* rc=0x88780032 */
ok(rc!=DS_OK,"IDirectSound_DuplicateSoundBuffer() primary buffer "
"should have failed %s\n",DXGetErrorString8(rc));
rc=IDirectSoundBuffer_GetVolume(primary,&vol);
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n",
DXGetErrorString8(rc));
if (winetest_interactive) {
trace("Playing a 5 seconds reference tone at the current "
"volume.\n");
if (rc==DS_OK)
trace("(the current volume is %ld according to DirectSound)\n",
vol);
trace("All subsequent tones should be identical to this one.\n");
trace("Listen for stutter, changes in pitch, volume, etc.\n");
}
test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive &&
!(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, "
"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: %s\n",
DXGetErrorString8(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;
}
/*
* Test the primary buffer at different formats while keeping the
* secondary buffer at a constant format.
*/
static HRESULT test_primary_secondary(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx2;
int f,ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Get the device capabilities */
ZeroMemory(&dscaps, sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* 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: %s\n",
DXGetErrorString8(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 "
"%s\n",DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL) {
for (f=0;f<NB_FORMATS;f++) {
/* We must call SetCooperativeLevel to be allowed to call
* SetFormat */
/* DSOUND: Setting DirectSound cooperative level to
* DSSCL_PRIORITY */
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
formats[f][2]);
wfx2=wfx;
rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat() failed: %s\n",
DXGetErrorString8(rc));
/* There is no garantee that SetFormat will actually change the
* format to what we asked for. It depends on what the soundcard
* supports. So we must re-query the format.
*/
rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL);
ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK &&
(wfx.wFormatTag!=wfx2.wFormatTag ||
wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
wfx.nChannels!=wfx2.nChannels)) {
trace("Requested primary format tag=0x%04x %ldx%dx%d "
"avg.B/s=%ld align=%d\n",
wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
trace("Got tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
}
/* 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: %s\n",
DXGetErrorString8(rc));
init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx2;
if (winetest_interactive) {
trace(" Testing a primary buffer at %ldx%dx%d with a "
"secondary buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
}
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary!=NULL,
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
"buffer %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
}
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary 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: %s\n",
DXGetErrorString8(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_secondary(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx1;
DWORD f;
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Get the device capabilities */
ZeroMemory(&dscaps, sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* 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: %s\n",
DXGetErrorString8(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 "
"%s\n",DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL) {
rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT1;
for (f=0;f<NB_FORMATS;f++) {
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
formats[f][2]);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL)
IDirectSoundBuffer_Release(secondary);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive) {
trace(" Testing a secondary buffer at %ldx%dx%d "
"with a primary buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
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 secondary "
"buffer %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
}
EXIT1:
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary 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: %s\n",
DXGetErrorString8(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_block_align(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
LPDIRECTSOUNDBUFFER secondary=NULL;
DSBUFFERDESC bufdesc;
DSBCAPS dsbcaps;
WAVEFORMATEX wfx;
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
init_format(&wfx,WAVE_FORMAT_PCM,11025,16,2);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
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: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
ZeroMemory(&dsbcaps, sizeof(dsbcaps));
dsbcaps.dwSize = sizeof(dsbcaps);
rc=IDirectSoundBuffer_GetCaps(secondary,&dsbcaps);
ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() should have returned DS_OK, "
"returned: %s\n", DXGetErrorString8(rc));
if (rc==DS_OK)
ok(dsbcaps.dwBufferBytes==(wfx.nAvgBytesPerSec + wfx.nBlockAlign),
"Buffer size not a multiple of nBlockAlign: requested %ld, "
"got %ld, should be %ld\n", bufdesc.dwBufferBytes,
dsbcaps.dwBufferBytes, wfx.nAvgBytesPerSec + wfx.nBlockAlign);
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d references, "
"should have 0\n",ref);
}
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 struct fmt {
int bits;
int channels;
} fmts[] = { { 8, 1 }, { 8, 2 }, { 16, 1 }, {16, 2 } };
static HRESULT test_frequency(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx1;
DWORD f, r;
int ref;
int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100,
48000, 96000 };
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Get the device capabilities */
ZeroMemory(&dscaps, sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* 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: %s\n",
DXGetErrorString8(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 "
"%s\n",DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL) {
rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT1;
for (f=0;f<sizeof(fmts)/sizeof(fmts[0]);f++) {
for (r=0;r<sizeof(rates)/sizeof(rates[0]);r++) {
init_format(&wfx,WAVE_FORMAT_PCM,11025,fmts[f].bits,
fmts[f].channels);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLFREQUENCY;
bufdesc.dwBufferBytes=align((wfx.nAvgBytesPerSec*rates[r]/11025)*
BUFFER_LEN/1000,wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive) {
trace(" Testing a secondary buffer at %ldx%dx%d "
"with a primary buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
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 secondary "
"buffer %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
winetest_interactive,1.0,0,NULL,0,0,TRUE,rates[r]);
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
}
}
EXIT1:
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary 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: %s\n",
DXGetErrorString8(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 BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
LPCSTR lpcstrModule, LPVOID lpContext)
{
HRESULT rc;
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
rc = test_dsound(lpGuid);
if (rc == DSERR_NODRIVER)
trace(" No Driver\n");
else if (rc == DSERR_ALLOCATED)
trace(" Already In Use\n");
else if (rc == E_FAIL)
trace(" No Device\n");
else {
test_block_align(lpGuid);
test_primary(lpGuid);
test_primary_secondary(lpGuid);
test_secondary(lpGuid);
test_frequency(lpGuid);
}
return 1;
}
static void dsound_tests(void)
{
HRESULT rc;
rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
}
START_TEST(dsound)
{
CoInitialize(NULL);
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
IDirectSound_tests();
dsound_tests();
CoUninitialize();
}

View file

@ -1,858 +0,0 @@
/*
* Tests basic sound playback in DirectSound.
* In particular we test each standard Windows sound format to make sure
* we handle the sound card/driver quirks correctly.
*
* Part of this test involves playing test tones. But this only makes
* sense if someone is going to carefully listen to it, and would only
* bother everyone else.
* So this is only done if the test is being run in interactive mode.
*
* Copyright (c) 2002-2004 Francois Gouget
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#include <windows.h>
#include <stdio.h>
#include "wine/test.h"
#include "dsound.h"
#include "dxerr8.h"
#include "dsconf.h"
#include "dsound_test.h"
static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;
int align(int length, int align)
{
return (length / align) * align;
}
static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized,
LPCGUID lpGuid)
{
HRESULT rc;
DSCAPS dscaps;
int ref;
IUnknown * unknown;
IDirectSound * ds;
IDirectSound8 * ds8;
DWORD speaker_config, new_speaker_config;
DWORD certified;
/* Try to Query for objects */
rc=IDirectSound8_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IUnknown) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSound8_Release(unknown);
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound) failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSound_Release(ds);
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound8) "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK)
IDirectSound8_Release(ds8);
if (initialized == FALSE) {
/* try unitialized object */
rc=IDirectSound8_GetCaps(dso,0);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps(NULL) "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_Compact(dso);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_Compact() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetSpeakerConfig() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_VerifyCertification(dso, &certified);
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_VerifyCertification() "
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_Initialize(dso,lpGuid);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"IDirectSound8_Initialize() failed: %s\n",DXGetErrorString8(rc));
if (rc==DSERR_NODRIVER) {
trace(" No Driver\n");
goto EXIT;
} else if (rc==E_FAIL) {
trace(" No Device\n");
goto EXIT;
} else if (rc==DSERR_ALLOCATED) {
trace(" Already In Use\n");
goto EXIT;
}
}
rc=IDirectSound8_Initialize(dso,lpGuid);
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound8_Initialize() "
"should have returned DSERR_ALREADYINITIALIZED: %s\n",
DXGetErrorString8(rc));
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound8_GetCaps(dso,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
ZeroMemory(&dscaps, sizeof(dscaps));
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
dscaps.dwSize=sizeof(dscaps);
/* DSOUND: Running on a certified driver */
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
rc=IDirectSound8_Compact(dso);
ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound8_Compact() failed: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_Compact(dso);
ok(rc==DS_OK,"IDirectSound8_Compact() failed: %s\n",DXGetErrorString8(rc));
rc=IDirectSound8_GetSpeakerConfig(dso,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetSpeakerConfig(NULL) "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %s\n",
DXGetErrorString8(rc));
speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
DSSPEAKER_GEOMETRY_WIDE);
rc=IDirectSound8_SetSpeakerConfig(dso,speaker_config);
ok(rc==DS_OK,"IDirectSound8_SetSpeakerConfig() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK) {
rc=IDirectSound8_GetSpeakerConfig(dso,&new_speaker_config);
ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && speaker_config!=new_speaker_config)
trace("IDirectSound8_GetSpeakerConfig() failed to set speaker "
"config: expected 0x%08lx, got 0x%08lx\n",
speaker_config,new_speaker_config);
}
rc=IDirectSound8_VerifyCertification(dso, &certified);
ok(rc==DS_OK||rc==E_NOTIMPL,"IDirectSound8_VerifyCertification() failed: %s\n",
DXGetErrorString8(rc));
EXIT:
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
}
static void IDirectSound8_tests(void)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
trace("Testing IDirectSound8\n");
/* try the COM class factory method of creation with no device specified */
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound8, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance() failed: %s\n",DXGetErrorString8(rc));
if (dso)
IDirectSound8_test(dso, FALSE, NULL);
/* try the COM class factory method of creation with default playback
* device specified */
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound8, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %s\n",
DXGetErrorString8(rc));
if (dso)
IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultPlayback);
/* try the COM class factory method of creation with default voice
* playback device specified */
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound8, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %s\n",
DXGetErrorString8(rc));
if (dso)
IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
/* try the COM class factory method of creation with a bad
* IID specified */
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
&CLSID_DirectSoundPrivate, (void**)&dso);
ok(rc==E_NOINTERFACE,
"CoCreateInstance(CLSID_DirectSound8,CLSID_DirectSoundPrivate) "
"should have failed: %s\n",DXGetErrorString8(rc));
/* try the COM class factory method of creation with a bad
* GUID and IID specified */
rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound8, (void**)&dso);
ok(rc==REGDB_E_CLASSNOTREG,
"CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound8) "
"should have failed: %s\n",DXGetErrorString8(rc));
/* try with no device specified */
rc=pDirectSoundCreate8(NULL,&dso,NULL);
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && dso)
IDirectSound8_test(dso, TRUE, NULL);
/* try with default playback device specified */
rc=pDirectSoundCreate8(&DSDEVID_DefaultPlayback,&dso,NULL);
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && dso)
IDirectSound8_test(dso, TRUE, NULL);
/* try with default voice playback device specified */
rc=pDirectSoundCreate8(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && dso)
IDirectSound8_test(dso, TRUE, NULL);
/* try with a bad device specified */
rc=pDirectSoundCreate8(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
ok(rc==DSERR_NODRIVER,"DirectSoundCreate8(DSDEVID_DefaultVoiceCapture) "
"should have failed: %s\n",DXGetErrorString8(rc));
}
static HRESULT test_dsound8(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
int ref;
/* DSOUND: Error: Invalid interface buffer */
rc=pDirectSoundCreate8(lpGuid,0,NULL);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate8() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* Create the DirectSound8 object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Try the enumerated device */
IDirectSound8_test(dso, TRUE, lpGuid);
/* Try the COM class factory method of creation with enumerated device */
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound8, (void**)&dso);
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
DXGetErrorString8(rc));
if (dso)
IDirectSound8_test(dso, FALSE, lpGuid);
/* Create a DirectSound8 object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
LPDIRECTSOUND8 dso1=NULL;
/* Create a second DirectSound8 object */
rc=pDirectSoundCreate8(lpGuid,&dso1,NULL);
ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
/* Release the second DirectSound8 object */
ref=IDirectSound8_Release(dso1);
ok(ref==0,"IDirectSound8_Release() has %d references, "
"should have 0\n",ref);
ok(dso!=dso1,"DirectSound8 objects should be unique: "
"dso=%p,dso1=%p\n",dso,dso1);
}
/* Release the first DirectSound8 object */
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
ref);
if (ref!=0)
return DSERR_GENERIC;
} else
return rc;
/* Create a DirectSound8 object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
LPDIRECTSOUNDBUFFER secondary;
DSBUFFERDESC bufdesc;
WAVEFORMATEX wfx;
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary!=NULL,
"IDirectSound8_CreateSoundBuffer() failed to create a secondary "
"buffer: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
LPDIRECTSOUND3DBUFFER buffer3d;
LPDIRECTSOUNDBUFFER8 buffer8;
rc=IDirectSound8_QueryInterface(secondary,
&IID_IDirectSound3DBuffer,
(void **)&buffer3d);
ok(rc==DS_OK && buffer3d!=NULL,
"IDirectSound8_QueryInterface() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && buffer3d!=NULL) {
ref=IDirectSound3DBuffer_AddRef(buffer3d);
ok(ref==2,"IDirectSound3DBuffer_AddRef() has %d references, "
"should have 2\n",ref);
}
rc=IDirectSound8_QueryInterface(secondary,
&IID_IDirectSoundBuffer8,
(void **)&buffer8);
if (rc==DS_OK && buffer8!=NULL) {
ref=IDirectSoundBuffer8_AddRef(buffer8);
ok(ref==3,"IDirectSoundBuffer8_AddRef() has %d references, "
"should have 3\n",ref);
}
ref=IDirectSoundBuffer_AddRef(secondary);
ok(ref==4,"IDirectSoundBuffer_AddRef() has %d references, "
"should have 4\n",ref);
}
/* release with buffer */
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
ref);
if (ref!=0)
return DSERR_GENERIC;
} else
return rc;
return DS_OK;
}
static HRESULT test_primary8(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx;
int ref;
/* Create the DirectSound object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Get the device capabilities */
ZeroMemory(&dscaps, sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* DSOUND: Error: Invalid buffer description pointer */
rc=IDirectSound8_CreateSoundBuffer(dso,0,0,NULL);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound8_CreateSoundBuffer should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* DSOUND: Error: Invalid buffer description pointer */
rc=IDirectSound8_CreateSoundBuffer(dso,0,&primary,NULL);
ok(rc==DSERR_INVALIDPARAM && primary==0,
"IDirectSound8_CreateSoundBuffer() should have returned "
"DSERR_INVALIDPARAM, returned: rc=%s,dsbo=%p\n",
DXGetErrorString8(rc),primary);
/* DSOUND: Error: Invalid buffer description pointer */
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,0,NULL);
ok(rc==DSERR_INVALIDPARAM && primary==0,
"IDirectSound8_CreateSoundBuffer() should have failed: rc=%s,"
"dsbo=%p\n",DXGetErrorString8(rc),primary);
ZeroMemory(&bufdesc, sizeof(bufdesc));
/* DSOUND: Error: Invalid size */
/* DSOUND: Error: Invalid buffer description */
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DSERR_INVALIDPARAM && primary==0,
"IDirectSound8_CreateSoundBuffer() should have failed: rc=%s,"
"primary=%p\n",DXGetErrorString8(rc),primary);
/* We must call SetCooperativeLevel before calling CreateSoundBuffer */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* Testing the primary buffer */
primary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
bufdesc.lpwfxFormat = &wfx;
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2);
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL)
IDirectSoundBuffer_Release(primary);
primary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: "
"%s\n",DXGetErrorString8(rc));
if (rc==DSERR_CONTROLUNAVAIL)
trace(" No Primary\n");
else if (rc==DS_OK && primary!=NULL) {
LONG vol;
/* Try to create a second primary buffer */
/* DSOUND: Error: The primary buffer already exists.
* Any changes made to the buffer description will be ignored. */
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
ok(rc==DS_OK && second==primary,
"IDirectSound8_CreateSoundBuffer() should have returned original "
"primary buffer: %s\n",DXGetErrorString8(rc));
ref=IDirectSoundBuffer_Release(second);
ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 1\n",ref);
/* Try to duplicate a primary buffer */
/* DSOUND: Error: Can't duplicate primary buffers */
rc=IDirectSound8_DuplicateSoundBuffer(dso,primary,&third);
/* rc=0x88780032 */
ok(rc!=DS_OK,"IDirectSound8_DuplicateSoundBuffer() primary buffer "
"should have failed %s\n",DXGetErrorString8(rc));
rc=IDirectSoundBuffer_GetVolume(primary,&vol);
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n",
DXGetErrorString8(rc));
if (winetest_interactive) {
trace("Playing a 5 seconds reference tone at the current volume.\n");
if (rc==DS_OK)
trace("(the current volume is %ld according to DirectSound)\n",
vol);
trace("All subsequent tones should be identical to this one.\n");
trace("Listen for stutter, changes in pitch, volume, etc.\n");
}
test_buffer8(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive &&
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0);
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
}
/* Set the CooperativeLevel back to normal */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
EXIT:
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
if (ref!=0)
return DSERR_GENERIC;
return rc;
}
/*
* Test the primary buffer at different formats while keeping the
* secondary buffer at a constant format.
*/
static HRESULT test_primary_secondary8(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx2;
int ref;
unsigned int f;
/* Create the DirectSound object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Get the device capabilities */
ZeroMemory(&dscaps, sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* We must call SetCooperativeLevel before creating primary buffer */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DS_OK && primary!=NULL,
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
"%s\n",DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL) {
for (f=0;f<NB_FORMATS;f++) {
/* We must call SetCooperativeLevel to be allowed to call
* SetFormat */
/* DSOUND: Setting DirectSound cooperative level to
* DSSCL_PRIORITY */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
formats[f][2]);
wfx2=wfx;
rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat() failed: %s\n",
DXGetErrorString8(rc));
/* There is no garantee that SetFormat will actually change the
* format to what we asked for. It depends on what the soundcard
* supports. So we must re-query the format.
*/
rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL);
ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK &&
(wfx.wFormatTag!=wfx2.wFormatTag ||
wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
wfx.nChannels!=wfx2.nChannels)) {
trace("Requested primary format tag=0x%04x %ldx%dx%d "
"avg.B/s=%ld align=%d\n",
wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
trace("Got tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
}
/* Set the CooperativeLevel back to normal */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx2;
if (winetest_interactive) {
trace(" Testing a primary buffer at %ldx%dx%d with a "
"secondary buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
}
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary!=NULL,
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
"buffer %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
test_buffer8(dso,secondary,0,FALSE,0,FALSE,0,
winetest_interactive,1.0,0,NULL,0,0);
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
}
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
}
/* Set the CooperativeLevel back to normal */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
EXIT:
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
if (ref!=0)
return DSERR_GENERIC;
return rc;
}
static HRESULT test_secondary8(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx1;
DWORD f;
int ref;
/* Create the DirectSound object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
/* Get the device capabilities */
ZeroMemory(&dscaps, sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* We must call SetCooperativeLevel before creating primary buffer */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DS_OK && primary!=NULL,
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
"%s\n",DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL) {
rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT1;
for (f=0;f<NB_FORMATS;f++) {
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
formats[f][2]);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL)
IDirectSoundBuffer_Release(secondary);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive) {
trace(" Testing a secondary buffer at %ldx%dx%d "
"with a primary buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
}
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary!=NULL,
"IDirectSound8_CreateSoundBuffer() failed to create a secondary "
"buffer: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
test_buffer8(dso,secondary,0,FALSE,0,FALSE,0,
winetest_interactive,1.0,0,NULL,0,0);
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
}
EXIT1:
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
}
/* Set the CooperativeLevel back to normal */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
EXIT:
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
if (ref!=0)
return DSERR_GENERIC;
return rc;
}
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
LPCSTR lpcstrModule, LPVOID lpContext)
{
HRESULT rc;
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
rc = test_dsound8(lpGuid);
if (rc == DSERR_NODRIVER)
trace(" No Driver\n");
else if (rc == DSERR_ALLOCATED)
trace(" Already In Use\n");
else if (rc == E_FAIL)
trace(" No Device\n");
else {
test_primary8(lpGuid);
test_primary_secondary8(lpGuid);
test_secondary8(lpGuid);
}
return 1;
}
static void dsound8_tests(void)
{
HRESULT rc;
rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
}
const char * get_file_version(const char * file_name)
{
static char version[32];
DWORD size;
DWORD handle;
size = GetFileVersionInfoSizeA("dsound.dll", &handle);
if (size) {
char * data = HeapAlloc(GetProcessHeap(), 0, size);
if (data) {
if (GetFileVersionInfoA("dsound.dll", handle, size, data)) {
VS_FIXEDFILEINFO *pFixedVersionInfo;
UINT len;
if (VerQueryValueA(data, "\\", (LPVOID *)&pFixedVersionInfo, &len)) {
sprintf(version, "%ld.%ld.%ld.%ld",
pFixedVersionInfo->dwFileVersionMS >> 16,
pFixedVersionInfo->dwFileVersionMS & 0xffff,
pFixedVersionInfo->dwFileVersionLS >> 16,
pFixedVersionInfo->dwFileVersionLS & 0xffff);
} else
sprintf(version, "not available");
} else
sprintf(version, "failed");
HeapFree(GetProcessHeap(), 0, data);
} else
sprintf(version, "failed");
} else
sprintf(version, "not available");
return version;
}
START_TEST(dsound8)
{
HMODULE hDsound;
CoInitialize(NULL);
hDsound = LoadLibraryA("dsound.dll");
if (!hDsound) {
trace("dsound.dll not found\n");
return;
}
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
if (!pDirectSoundCreate8) {
trace("dsound8 test skipped\n");
return;
}
IDirectSound8_tests();
dsound8_tests();
CoUninitialize();
}

View file

@ -1,64 +0,0 @@
/*
* Unit tests for dsound functions
*
* Copyright (c) 2004 Francois Gouget
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
static const unsigned int formats[][4]={
{ 8000, 8, 1, 0 },
{ 8000, 8, 2, 0 },
{ 8000, 16, 1, 0 },
{ 8000, 16, 2, 0 },
{11025, 8, 1, WAVE_FORMAT_1M08 },
{11025, 8, 2, WAVE_FORMAT_1S08 },
{11025, 16, 1, WAVE_FORMAT_1M16 },
{11025, 16, 2, WAVE_FORMAT_1S16 },
{22050, 8, 1, WAVE_FORMAT_2M08 },
{22050, 8, 2, WAVE_FORMAT_2S08 },
{22050, 16, 1, WAVE_FORMAT_2M16 },
{22050, 16, 2, WAVE_FORMAT_2S16 },
{44100, 8, 1, WAVE_FORMAT_4M08 },
{44100, 8, 2, WAVE_FORMAT_4S08 },
{44100, 16, 1, WAVE_FORMAT_4M16 },
{44100, 16, 2, WAVE_FORMAT_4S16 },
{48000, 8, 1, WAVE_FORMAT_48M08 },
{48000, 8, 2, WAVE_FORMAT_48S08 },
{48000, 16, 1, WAVE_FORMAT_48M16 },
{48000, 16, 2, WAVE_FORMAT_48S16 },
{96000, 8, 1, WAVE_FORMAT_96M08 },
{96000, 8, 2, WAVE_FORMAT_96S08 },
{96000, 16, 1, WAVE_FORMAT_96M16 },
{96000, 16, 2, WAVE_FORMAT_96S16 }
};
#define NB_FORMATS (sizeof(formats)/sizeof(*formats))
/* 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 HWND get_hwnd(void);
extern void init_format(WAVEFORMATEX*,int,int,int,int);
extern void test_buffer(LPDIRECTSOUND,LPDIRECTSOUNDBUFFER,
BOOL,BOOL,LONG,BOOL,LONG,BOOL,double,BOOL,
LPDIRECTSOUND3DLISTENER,BOOL,BOOL,BOOL,DWORD);
extern void test_buffer8(LPDIRECTSOUND8,LPDIRECTSOUNDBUFFER,
BOOL,BOOL,LONG,BOOL,LONG,BOOL,double,BOOL,
LPDIRECTSOUND3DLISTENER,BOOL,BOOL);
extern const char * getDSBCAPS(DWORD xmask);
extern int align(int length, int align);
extern const char * get_file_version(const char * file_name);

View file

@ -1,734 +0,0 @@
/*
* Unit tests for CLSID_DirectSoundPrivate property set functions
* (used by dxdiag)
*
* Copyright (c) 2003 Robert Reif
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#define COBJMACROS
#include <windows.h>
#include "wine/test.h"
#include "dsound.h"
#include "initguid.h"
#include "dsconf.h"
#include "dxerr8.h"
#include "dsound_test.h"
#ifndef DSBCAPS_CTRLDEFAULT
#define DSBCAPS_CTRLDEFAULT \
DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
#endif
DEFINE_GUID(DSPROPSETID_VoiceManager, \
0x62A69BAE,0xDF9D,0x11D1,0x99,0xA6,0x00,0xC0,0x4F,0xC9,0x9D,0x46);
DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties, \
0x306a6a8,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties, \
0x306a6a7,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
DEFINE_GUID(DSPROPSETID_I3DL2_ListenerProperties, \
0xDA0F0520,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
DEFINE_GUID(DSPROPSETID_I3DL2_BufferProperties, \
0xDA0F0521,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
DEFINE_GUID(DSPROPSETID_ZOOMFX_BufferProperties, \
0xCD5368E0,0x3450,0x11D3,0x8B,0x6E,0x00,0x10,0x5A,0x9B,0x7B,0xBC);
typedef HRESULT (CALLBACK * MYPROC)(REFCLSID, REFIID, LPVOID *);
static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,
LPUNKNOWN)=NULL;
static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,
LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
static HRESULT (WINAPI *pDirectSoundCaptureCreate8)(LPCGUID,
LPDIRECTSOUNDCAPTURE8*,LPUNKNOWN)=NULL;
static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID,LPCGUID,
LPCDSCBUFFERDESC,LPCDSBUFFERDESC,HWND,DWORD,LPDIRECTSOUNDFULLDUPLEX*,
LPDIRECTSOUNDCAPTUREBUFFER8*,LPDIRECTSOUNDBUFFER8*,LPUNKNOWN)=NULL;
BOOL CALLBACK callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data,
LPVOID context)
{
trace(" found device:\n");
trace(" Type: %s\n",
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
trace(" DataFlow: %s\n",
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
"Capture" : "Unknown");
trace(" DeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
trace(" Description: %s\n", data->Description);
trace(" Module: %s\n", data->Module);
trace(" Interface: %s\n", data->Interface);
trace(" WaveDeviceId: %ld\n", data->WaveDeviceId);
return TRUE;
}
BOOL CALLBACK callback1(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data,
LPVOID context)
{
char descriptionA[0x100];
char moduleA[MAX_PATH];
trace(" found device:\n");
trace(" Type: %s\n",
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
trace(" DataFlow: %s\n",
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
"Capture" : "Unknown");
trace(" DeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
trace(" DescriptionA: %s\n", data->DescriptionA);
WideCharToMultiByte(CP_ACP, 0, data->DescriptionW, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
trace(" DescriptionW: %s\n", descriptionA);
trace(" ModuleA: %s\n", data->ModuleA);
WideCharToMultiByte(CP_ACP, 0, data->ModuleW, -1, moduleA, sizeof(moduleA), NULL, NULL);
trace(" ModuleW: %s\n", moduleA);
trace(" WaveDeviceId: %ld\n", data->WaveDeviceId);
return TRUE;
}
BOOL CALLBACK callbackA(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data,
LPVOID context)
{
trace(" found device:\n");
trace(" Type: %s\n",
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
trace(" DataFlow: %s\n",
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
"Capture" : "Unknown");
trace(" DeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
trace(" Description: %s\n", data->Description);
trace(" Module: %s\n", data->Module);
trace(" Interface: %s\n", data->Interface);
trace(" WaveDeviceId: %ld\n", data->WaveDeviceId);
return TRUE;
}
BOOL CALLBACK callbackW(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data,
LPVOID context)
{
char descriptionA[0x100];
char moduleA[MAX_PATH];
char interfaceA[MAX_PATH];
trace("found device:\n");
trace("\tType: %s\n",
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
trace("\tDataFlow: %s\n",
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
"Capture" : "Unknown");
trace("\tDeviceId: {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
WideCharToMultiByte(CP_ACP, 0, data->Description, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, data->Module, -1, moduleA, sizeof(moduleA), NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, data->Interface, -1, interfaceA, sizeof(interfaceA), NULL, NULL);
trace("\tDescription: %s\n", descriptionA);
trace("\tModule: %s\n", moduleA);
trace("\tInterface: %s\n", interfaceA);
trace("\tWaveDeviceId: %ld\n", data->WaveDeviceId);
return TRUE;
}
static void propset_private_tests(void)
{
HMODULE hDsound;
HRESULT rc;
IClassFactory * pcf;
IKsPropertySet * pps;
MYPROC fProc;
ULONG support;
hDsound = LoadLibrary("dsound.dll");
ok(hDsound!=0,"LoadLibrary(dsound.dll) failed\n");
if (hDsound==0)
return;
fProc = (MYPROC)GetProcAddress(hDsound, "DllGetClassObject");
/* try direct sound first */
/* DSOUND: Error: Invalid interface buffer */
rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)0);
ok(rc==DSERR_INVALIDPARAM,"DllGetClassObject(CLSID_DirectSound, "
"IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
"returned: %s\n",DXGetErrorString8(rc));
rc = (fProc)(&CLSID_DirectSound, &IID_IClassFactory, (void **)(&pcf));
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
"failed: %s\n",DXGetErrorString8(rc));
if (pcf==0)
goto error;
/* direct sound doesn't have an IKsPropertySet */
/* DSOUND: Error: Invalid interface buffer */
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
(void **)0);
ok(rc==DSERR_INVALIDPARAM, "CreateInstance(IID_IKsPropertySet) should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
(void **)(&pps));
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
"returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
/* and the direct sound 8 version */
if (pDirectSoundCreate8) {
rc = (fProc)(&CLSID_DirectSound8, &IID_IClassFactory, (void **)(&pcf));
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
"failed: %s\n",DXGetErrorString8(rc));
if (pcf==0)
goto error;
/* direct sound 8 doesn't have an IKsPropertySet */
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
(void **)(&pps));
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
"returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
}
/* try direct sound capture next */
if (pDirectSoundCaptureCreate) {
rc = (fProc)(&CLSID_DirectSoundCapture, &IID_IClassFactory,
(void **)(&pcf));
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
"failed: %s\n",DXGetErrorString8(rc));
if (pcf==0)
goto error;
/* direct sound capture doesn't have an IKsPropertySet */
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
(void **)(&pps));
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
"returned E_NOINTERFACE,returned: %s\n",DXGetErrorString8(rc));
}
/* and the direct sound capture 8 version */
if (pDirectSoundCaptureCreate8) {
rc = (fProc)(&CLSID_DirectSoundCapture8, &IID_IClassFactory,
(void **)(&pcf));
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
"IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
if (pcf==0)
goto error;
/* direct sound capture 8 doesn't have an IKsPropertySet */
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
(void **)(&pps));
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
"returned E_NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
}
/* try direct sound full duplex next */
if (pDirectSoundFullDuplexCreate) {
rc = (fProc)(&CLSID_DirectSoundFullDuplex, &IID_IClassFactory,
(void **)(&pcf));
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
"IID_IClassFactory) failed: %s\n",DXGetErrorString8(rc));
if (pcf==0)
goto error;
/* direct sound full duplex doesn't have an IKsPropertySet */
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
(void **)(&pps));
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
"returned NOINTERFACE, returned: %s\n",DXGetErrorString8(rc));
}
/* try direct sound private last */
rc = (fProc)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
(void **)(&pcf));
/* some early versions of Direct Sound do not have this */
if (pcf==0)
goto error;
/* direct sound private does have an IKsPropertySet */
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
(void **)(&pps));
ok(rc==DS_OK, "CreateInstance(IID_IKsPropertySet) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
/* test generic DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION */
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
&support);
ok(rc==DS_OK||rc==E_INVALIDARG,
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK) {
if (rc==E_INVALIDARG)
trace(" Not Supported\n");
goto error;
}
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
"support = 0x%lx\n",support);
/* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 */
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1,
&support);
ok(rc==DS_OK||rc==E_INVALIDARG,
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK) {
if (rc==E_INVALIDARG)
trace(" Not Supported\n");
goto error;
}
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
"support = 0x%lx\n",support);
/* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A,
&support);
ok(rc==DS_OK||rc==E_INVALIDARG,
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK) {
if (rc==E_INVALIDARG)
trace(" Not Supported\n");
goto error;
}
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
"support = 0x%lx\n",support);
/* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W */
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W,
&support);
ok(rc==DS_OK||rc==E_INVALIDARG,
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK) {
if (rc==E_INVALIDARG)
trace(" Not Supported\n");
goto error;
}
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
"support = 0x%lx\n",support);
/* test generic DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING */
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING, &support);
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
"0x%lx\n",support);
/* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A */
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A, &support);
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: support = "
"0x%lx\n",support);
/* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W */
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W, &support);
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: support = "
"0x%lx\n",support);
/* test generic DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE */
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE ***\n");
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
&support);
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%lx\n",support);
if (support & KSPROPERTY_SUPPORT_GET) {
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
ULONG bytes;
data.Callback = callback;
data.Context = 0;
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
NULL, 0, &data, sizeof(data), &bytes);
ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
}
/* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 ***\n");
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
&support);
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: support = 0x%lx\n",support);
if (support & KSPROPERTY_SUPPORT_GET) {
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
ULONG bytes;
data.Callback = callback1;
data.Context = 0;
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
NULL, 0, &data, sizeof(data), &bytes);
ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
}
/* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A */
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A ***\n");
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
&support);
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: support = 0x%lx\n",support);
if (support & KSPROPERTY_SUPPORT_GET) {
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
ULONG bytes;
data.Callback = callbackA;
data.Context = 0;
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
NULL, 0, &data, sizeof(data), &bytes);
ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
}
/* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W */
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W ***\n");
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
&support);
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W) failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto error;
ok(support & KSPROPERTY_SUPPORT_GET,
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: "
"support = 0x%lx\n",support);
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: support = 0x%lx\n",support);
if (support & KSPROPERTY_SUPPORT_GET) {
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
ULONG bytes;
data.Callback = callbackW;
data.Context = 0;
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
NULL, 0, &data, sizeof(data), &bytes);
ok(rc==DS_OK, "Couldn't enumerate: 0x%lx\n",rc);
}
error:
FreeLibrary(hDsound);
}
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
LPCSTR lpcstrModule, LPVOID lpContext)
{
HRESULT rc;
LPDIRECTSOUND dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
DSBUFFERDESC bufdesc;
WAVEFORMATEX wfx;
int ref;
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK) {
if (rc==DSERR_NODRIVER)
trace(" No Driver\n");
else if (rc == DSERR_ALLOCATED)
trace(" Already In Use\n");
else if (rc == E_FAIL)
trace(" No Device\n");
goto EXIT;
}
/* We must call SetCooperativeLevel before calling CreateSoundBuffer */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
goto EXIT;
/* Testing 3D buffers */
primary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DS_OK&&primary!=NULL,"IDirectSound_CreateSoundBuffer() failed to "
"create a hardware 3D primary buffer: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK&&primary!=NULL) {
ZeroMemory(&wfx, sizeof(wfx));
wfx.wFormatTag=WAVE_FORMAT_PCM;
wfx.nChannels=1;
wfx.wBitsPerSample=16;
wfx.nSamplesPerSec=44100;
wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.lpwfxFormat=&wfx;
trace(" Testing a secondary buffer at %ldx%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: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK&&secondary!=NULL) {
IKsPropertySet * pPropertySet=NULL;
rc=IDirectSoundBuffer_QueryInterface(secondary,
&IID_IKsPropertySet,
(void **)&pPropertySet);
/* it's not an error for this to fail */
if(rc==DS_OK) {
ULONG ulTypeSupport;
trace(" Supports property sets\n");
/* it's not an error for these to fail */
rc=IKsPropertySet_QuerySupport(pPropertySet,
&DSPROPSETID_VoiceManager,
0,&ulTypeSupport);
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
KSPROPERTY_SUPPORT_SET)))
trace(" DSPROPSETID_VoiceManager supported\n");
else
trace(" DSPROPSETID_VoiceManager not supported\n");
rc=IKsPropertySet_QuerySupport(pPropertySet,
&DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport);
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
KSPROPERTY_SUPPORT_SET)))
trace(" DSPROPSETID_EAX20_ListenerProperties "
"supported\n");
else
trace(" DSPROPSETID_EAX20_ListenerProperties not "
"supported\n");
rc=IKsPropertySet_QuerySupport(pPropertySet,
&DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport);
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
KSPROPERTY_SUPPORT_SET)))
trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
else
trace(" DSPROPSETID_EAX20_BufferProperties not "
"supported\n");
rc=IKsPropertySet_QuerySupport(pPropertySet,
&DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport);
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
KSPROPERTY_SUPPORT_SET)))
trace(" DSPROPSETID_I3DL2_ListenerProperties "
"supported\n");
else
trace(" DSPROPSETID_I3DL2_ListenerProperties not "
"supported\n");
rc=IKsPropertySet_QuerySupport(pPropertySet,
&DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport);
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
KSPROPERTY_SUPPORT_SET)))
trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
else
trace(" DSPROPSETID_I3DL2_BufferProperties not "
"supported\n");
rc=IKsPropertySet_QuerySupport(pPropertySet,
&DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport);
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
KSPROPERTY_SUPPORT_SET)))
trace(" DSPROPSETID_ZOOMFX_BufferProperties "
"supported\n");
else
trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
"supported\n");
ref=IKsPropertySet_Release(pPropertySet);
/* try a few common ones */
ok(ref==0,"IKsPropertySet_Release() secondary has %d "
"references, should have 0\n",ref);
} else
trace(" Doesn't support property sets\n");
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
"references, should have 0\n",ref);
}
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
}
EXIT:
if (dso!=NULL) {
ref=IDirectSound_Release(dso);
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
ref);
}
return 1;
}
static void propset_buffer_tests(void)
{
HRESULT rc;
rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
}
START_TEST(propset)
{
HMODULE hDsound;
CoInitialize(NULL);
hDsound = LoadLibraryA("dsound.dll");
if (!hDsound) {
trace("dsound.dll not found\n");
return;
}
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate");
pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate8");
pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,"DirectSoundFullDuplexCreate");
propset_private_tests();
propset_buffer_tests();
CoUninitialize();
}

View file

@ -16,12 +16,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WINE_OLESELFREGISTER
1 WINE_REGISTRY dsound_classes.rgs
#define WINE_FILEDESCRIPTION_STR "Wine DirectSound"
#define WINE_FILENAME_STR "dsound.dll"
#define WINE_FILEVERSION 5,3,1,904
#define WINE_FILEVERSION_STR "5.3.1.904"
#define WINE_PRODUCTVERSION 5,3,1,904
#define WINE_PRODUCTVERSION_STR "5.3.1.904"
#define WINE_EXTRAVALUES VALUE "OLESelfRegister",""
#include "wine/wine_common_ver.rc"
#include <wine/wine_common_ver.rc>

View file

@ -77,19 +77,27 @@ typedef struct _DEVPROPKEY {
DEVPROPID pid;
} DEVPROPKEY, *PDEVPROPKEY;
#endif /* DEVPROPKEY_DEFINED */
#define DEVPROPID_FIRST_USABLE 2
#endif /* DEVPROPKEY_DEFINED */
#endif /* _DEVPROPDEF_H_ */
#ifdef DEFINE_DEVPROPKEY
#undef DEFINE_DEVPROPKEY
#endif
#ifdef INITGUID
#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY DECLSPEC_SELECTANY name = {{ l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}, pid}
#ifdef __cplusplus
#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \
EXTERN_C const DEVPROPKEY DECLSPEC_HIDDEN DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
#else
#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY name
#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \
const DEVPROPKEY DECLSPEC_HIDDEN DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
#endif
#else
#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \
EXTERN_C const DEVPROPKEY DECLSPEC_HIDDEN DECLSPEC_SELECTANY name
#endif /* INITGUID */
#ifndef IsEqualDevPropKey

View file

@ -1,369 +0,0 @@
/*
* DirectSound driver
* (DirectX 5 version)
*
* Copyright (C) 2000 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __WINE_DSDRIVER_H
#define __WINE_DSDRIVER_H
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* Predeclare the interfaces
*/
DEFINE_GUID(IID_IDsDriver, 0x8C4233C0l, 0xB4CC, 0x11CE, 0x92, 0x94, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
typedef struct IDsDriver *PIDSDRIVER;
DEFINE_GUID(IID_IDsDriverBuffer, 0x8C4233C1l, 0xB4CC, 0x11CE, 0x92, 0x94, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
typedef struct IDsDriverBuffer *PIDSDRIVERBUFFER;
DEFINE_GUID(IID_IDsDriverPropertySet, 0x0F6F2E8E0, 0xD842, 0x11D0, 0x8F, 0x75, 0x00, 0xC0, 0x4F, 0xC2, 0x8A, 0xCA);
typedef struct IDsDriverPropertySet *PIDSDRIVERPROPERTYSET;
DEFINE_GUID(IID_IDsDriverNotify, 0x00363EF44, 0x3B57, 0x11D3, 0xAC, 0x79, 0x00, 0x10, 0x5A, 0x01, 0x7f, 0xe1);
typedef struct IDsDriverNotify *PIDSDRIVERNOTIFY;
DEFINE_GUID(IID_IDsCaptureDriver, 0x03DD10C47, 0x74FB, 0x11D3, 0x90, 0x49, 0xCB, 0xB4, 0xB3, 0x2E, 0xAA, 0x08);
typedef struct IDsCaptureDriver *PIDSCDRIVER;
DEFINE_GUID(IID_IDsCaptureDriverBuffer, 0x03DD10C48, 0x74FB, 0x11D3, 0x90, 0x49, 0xCB, 0xB4, 0xB3, 0x2E, 0xAA, 0x08);
typedef struct IDsCaptureDriverBuffer *PIDSCDRIVERBUFFER;
#define DSDDESC_DOMMSYSTEMOPEN 0x00000001
#define DSDDESC_DOMMSYSTEMSETFORMAT 0x00000002
#define DSDDESC_USESYSTEMMEMORY 0x00000004
#define DSDDESC_DONTNEEDPRIMARYLOCK 0x00000008
#define DSDDESC_DONTNEEDSECONDARYLOCK 0x00000010
#define DSDDESC_DONTNEEDWRITELEAD 0x00000020
#define DSDHEAP_NOHEAP 0
#define DSDHEAP_CREATEHEAP 1
#define DSDHEAP_USEDIRECTDRAWHEAP 2
#define DSDHEAP_PRIVATEHEAP 3
typedef struct _DSDRIVERDESC
{
DWORD dwFlags;
TCHAR szDesc[256];
TCHAR szDrvname[256];
DWORD_PTR dnDevNode;
WORD wVxdId;
WORD wReserved;
ULONG ulDeviceNum;
DWORD dwHeapType;
LPVOID pvDirectDrawHeap;
DWORD dwMemStartAddress;
DWORD dwMemEndAddress;
DWORD dwMemAllocExtra;
LPVOID pvReserved1;
LPVOID pvReserved2;
} DSDRIVERDESC,*PDSDRIVERDESC;
typedef struct _DSDRIVERCAPS
{
DWORD dwFlags;
DWORD dwMinSecondarySampleRate;
DWORD dwMaxSecondarySampleRate;
DWORD dwPrimaryBuffers;
DWORD dwMaxHwMixingAllBuffers;
DWORD dwMaxHwMixingStaticBuffers;
DWORD dwMaxHwMixingStreamingBuffers;
DWORD dwFreeHwMixingAllBuffers;
DWORD dwFreeHwMixingStaticBuffers;
DWORD dwFreeHwMixingStreamingBuffers;
DWORD dwMaxHw3DAllBuffers;
DWORD dwMaxHw3DStaticBuffers;
DWORD dwMaxHw3DStreamingBuffers;
DWORD dwFreeHw3DAllBuffers;
DWORD dwFreeHw3DStaticBuffers;
DWORD dwFreeHw3DStreamingBuffers;
DWORD dwTotalHwMemBytes;
DWORD dwFreeHwMemBytes;
DWORD dwMaxContigFreeHwMemBytes;
} DSDRIVERCAPS,*PDSDRIVERCAPS;
typedef struct _DSVOLUMEPAN
{
DWORD dwTotalLeftAmpFactor;
DWORD dwTotalRightAmpFactor;
LONG lVolume;
DWORD dwVolAmpFactor;
LONG lPan;
DWORD dwPanLeftAmpFactor;
DWORD dwPanRightAmpFactor;
} DSVOLUMEPAN,*PDSVOLUMEPAN;
typedef union _DSPROPERTY
{
struct {
GUID Set;
ULONG Id;
ULONG Flags;
ULONG_PTR InstanceId;
} DUMMYSTRUCTNAME;
ULONGLONG Alignment;
} DSPROPERTY,*PDSPROPERTY;
typedef struct _DSCDRIVERCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwFormats;
DWORD dwChannels;
} DSCDRIVERCAPS,*PDSCDRIVERCAPS;
/*****************************************************************************
* IDsDriver interface
*/
#define INTERFACE IDsDriver
DECLARE_INTERFACE_(IDsDriver,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDsDriver methods ***/
STDMETHOD(GetDriverDesc)(THIS_ PDSDRIVERDESC pDsDriverDesc) PURE;
STDMETHOD(Open)(THIS) PURE;
STDMETHOD(Close)(THIS) PURE;
STDMETHOD(GetCaps)(THIS_ PDSDRIVERCAPS pDsDrvCaps) PURE;
STDMETHOD(CreateSoundBuffer)(THIS_ LPWAVEFORMATEX pwfx,DWORD dwFlags,DWORD dwCardAddress,LPDWORD pdwcbBufferSize,LPBYTE *ppbBuffer,LPVOID *ppvObj) PURE;
STDMETHOD(DuplicateSoundBuffer)(THIS_ PIDSDRIVERBUFFER pIDsDriverBuffer,LPVOID *ppvObj) PURE;
};
#undef INTERFACE
#if !defined (__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IDsDriver_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDsDriver_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDsDriver_Release(p) (p)->lpVtbl->Release(p)
/*** IDsDriver methods ***/
#define IDsDriver_GetDriverDesc(p,a) (p)->lpVtbl->GetDriverDesc(p,a)
#define IDsDriver_Open(p) (p)->lpVtbl->Open(p)
#define IDsDriver_Close(p) (p)->lpVtbl->Close(p)
#define IDsDriver_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDsDriver_CreateSoundBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c,d,e,f)
#define IDsDriver_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b)
#endif
/*****************************************************************************
* IDsDriverBuffer interface
*/
#define INTERFACE IDsDriverBuffer
DECLARE_INTERFACE_(IDsDriverBuffer,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDsDriverBuffer methods ***/
STDMETHOD(Lock)(THIS_ LPVOID *ppvAudio1,LPDWORD pdwLen1,LPVOID *pdwAudio2,LPDWORD pdwLen2,DWORD dwWritePosition,DWORD dwWriteLen,DWORD dwFlags) PURE;
STDMETHOD(Unlock)(THIS_ LPVOID pvAudio1,DWORD dwLen1,LPVOID pvAudio2,DWORD dwLen2) PURE;
STDMETHOD(SetFormat)(THIS_ LPWAVEFORMATEX pwfxToSet) PURE;
STDMETHOD(SetFrequency)(THIS_ DWORD dwFrequency) PURE;
STDMETHOD(SetVolumePan)(THIS_ PDSVOLUMEPAN pDsVolumePan) PURE;
STDMETHOD(SetPosition)(THIS_ DWORD dwNewPosition) PURE;
STDMETHOD(GetPosition)(THIS_ LPDWORD lpdwCurrentPlayCursor,LPDWORD lpdwCurrentWriteCursor) PURE;
STDMETHOD(Play)(THIS_ DWORD dwReserved1,DWORD dwReserved2,DWORD dwFlags) PURE;
STDMETHOD(Stop)(THIS) PURE;
};
#undef INTERFACE
#if !defined (__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IDsDriverBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDsDriverBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDsDriverBuffer_Release(p) (p)->lpVtbl->Release(p)
/*** IDsDriverBuffer methods ***/
#define IDsDriverBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
#define IDsDriverBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
#define IDsDriverBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a)
#define IDsDriverBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a)
#define IDsDriverBuffer_SetVolumePan(p,a) (p)->lpVtbl->SetVolumePan(p,a)
#define IDsDriverBuffer_SetPosition(p,a) (p)->lpVtbl->SetPosition(p,a)
#define IDsDriverBuffer_GetPosition(p,a,b) (p)->lpVtbl->GetPosition(p,a,b)
#define IDsDriverBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c)
#define IDsDriverBuffer_Stop(p) (p)->lpVtbl->Stop(p)
#endif
/*****************************************************************************
* IDsDriverPropertySet interface
*/
#define INTERFACE IDsDriverPropertySet
DECLARE_INTERFACE_(IDsDriverPropertySet,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDsDriverPropertySet methods ***/
STDMETHOD(Get)(THIS_ PDSPROPERTY pDsProperty,LPVOID pPropertyParams,ULONG cbPropertyParams,LPVOID pPropertyData,ULONG cbPropertyData,PULONG pcbReturnedData) PURE;
STDMETHOD(Set)(THIS_ PDSPROPERTY pDsProperty,LPVOID pPropertyParams,ULONG cbPropertyParams,LPVOID pPropertyData,ULONG cbPropertyData) PURE;
STDMETHOD(QuerySupport)(THIS_ REFGUID PropertySetId,ULONG PropertyId,PULONG pSupport) PURE;
};
#undef INTERFACE
#if !defined (__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IDsDriverPropertySet_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDsDriverPropertySet_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDsDriverPropertySet_Release(p) (p)->lpVtbl->Release(p)
/*** IDsDriverPropertySet methods ***/
#define IDsDriverPropertySet_Get(p,a,b,c,d,e,f) (p)->lpVtbl->Get(p,a,b,c,d,e,f)
#define IDsDriverPropertySet_Set(p,a,b,c,d,e) (p)->lpVtbl->Set(p,a,b,c,d,e)
#define IDsDriverPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c)
#endif
/* Defined property sets */
DEFINE_GUID(DSPROPSETID_DirectSound3DListener, 0x6D047B40, 0x7AF9, 0x11D0, 0x92, 0x94, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
typedef enum
{
DSPROPERTY_DIRECTSOUND3DLISTENER_ALL,
DSPROPERTY_DIRECTSOUND3DLISTENER_POSITION,
DSPROPERTY_DIRECTSOUND3DLISTENER_VELOCITY,
DSPROPERTY_DIRECTSOUND3DLISTENER_ORIENTATION,
DSPROPERTY_DIRECTSOUND3DLISTENER_DISTANCEFACTOR,
DSPROPERTY_DIRECTSOUND3DLISTENER_ROLLOFFFACTOR,
DSPROPERTY_DIRECTSOUND3DLISTENER_DOPPLERFACTOR,
DSPROPERTY_DIRECTSOUND3DLISTENER_BATCH,
DSPROPERTY_DIRECTSOUND3DLISTENER_ALLOCATION
} DSPROPERTY_DIRECTSOUND3DLISTENER;
DEFINE_GUID(DSPROPSETID_DirectSound3DBuffer, 0x6D047B41, 0x7AF9, 0x11D0, 0x92, 0x94, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
typedef enum
{
DSPROPERTY_DIRECTSOUND3DBUFFER_ALL,
DSPROPERTY_DIRECTSOUND3DBUFFER_POSITION,
DSPROPERTY_DIRECTSOUND3DBUFFER_VELOCITY,
DSPROPERTY_DIRECTSOUND3DBUFFER_CONEANGLES,
DSPROPERTY_DIRECTSOUND3DBUFFER_CONEORIENTATION,
DSPROPERTY_DIRECTSOUND3DBUFFER_CONEOUTSIDEVOLUME,
DSPROPERTY_DIRECTSOUND3DBUFFER_MINDISTANCE,
DSPROPERTY_DIRECTSOUND3DBUFFER_MAXDISTANCE,
DSPROPERTY_DIRECTSOUND3DBUFFER_MODE
} DSPROPERTY_DIRECTSOUND3DBUFFER;
DEFINE_GUID(DSPROPSETID_DirectSoundSpeakerConfig, 0x6D047B42, 0x7AF9, 0x11D0, 0x92, 0x94, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
typedef enum
{
DSPROPERTY_DIRECTSOUNDSPEAKERCONFIG_SPEAKERCONFIG
} DSPROPERTY_DIRECTSOUNDSPEAKERCONFIG;
/*****************************************************************************
* IDsDriverNotify interface
*/
#define INTERFACE IDsDriverNotify
DECLARE_INTERFACE_(IDsDriverNotify,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDsDriverNotify methods ***/
STDMETHOD(SetNotificationPositions)(THIS_ DWORD dwPositionNotifies,LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE;
};
#undef INTERFACE
#if !defined (__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IDsDriverNotify_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDsDriverNotify_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDsDriverNotify_Release(p) (p)->lpVtbl->Release(p)
/*** IDsDriverNotify methods ***/
#define IDsDriverNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b)
#endif
/*****************************************************************************
* IDsCaptureDriver interface
*/
#define INTERFACE IDsCaptureDriver
DECLARE_INTERFACE_(IDsCaptureDriver,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDsCaptureDriver methods ***/
STDMETHOD(GetDriverDesc)(THIS_ PDSDRIVERDESC pDsDriverDesc) PURE;
STDMETHOD(Open)(THIS) PURE;
STDMETHOD(Close)(THIS) PURE;
STDMETHOD(GetCaps)(THIS_ PDSCDRIVERCAPS pDsDrvCaps) PURE;
STDMETHOD(CreateCaptureBuffer)(THIS_ LPWAVEFORMATEX pwfx,DWORD dwFlags,DWORD dwCardAddress,LPDWORD pdwcbBufferSize,LPBYTE *ppbBuffer,LPVOID *ppvObj) PURE;
};
#undef INTERFACE
#if !defined (__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IDsCaptureDriver_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDsCaptureDriver_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDsCaptureDriver_Release(p) (p)->lpVtbl->Release(p)
/*** IDsCaptureDriver methods ***/
#define IDsCaptureDriver_GetDriverDesc(p,a) (p)->lpVtbl->GetDriverDesc(p,a)
#define IDsCaptureDriver_Open(p) (p)->lpVtbl->Open(p)
#define IDsCaptureDriver_Close(p) (p)->lpVtbl->Close(p)
#define IDsCaptureDriver_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDsCaptureDriver_CreateCaptureBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c,d,e,f)
#endif
/*****************************************************************************
* IDsCaptureDriverBuffer interface
*/
#define INTERFACE IDsCaptureDriverBuffer
DECLARE_INTERFACE_(IDsCaptureDriverBuffer,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDsCaptureDriverBuffer methods ***/
STDMETHOD(Lock)(THIS_ LPVOID *ppvAudio1,LPDWORD pdwLen1,LPVOID *ppvAudio2,LPDWORD pdwLen2,DWORD dwWritePosition,DWORD dwWriteLen,DWORD dwFlags) PURE;
STDMETHOD(Unlock)(THIS_ LPVOID pvAudio1,DWORD dwLen1,LPVOID pvAudio2,DWORD dwLen2) PURE;
STDMETHOD(SetFormat)(THIS_ LPWAVEFORMATEX pwfxToSet) PURE;
STDMETHOD(GetPosition)(THIS_ LPDWORD lpdwCurrentPlayCursor,LPDWORD lpdwCurrentWriteCursor) PURE;
STDMETHOD(GetStatus)(THIS_ LPDWORD lpdwStatus) PURE;
STDMETHOD(Start)(THIS_ DWORD dwFlags) PURE;
STDMETHOD(Stop)(THIS) PURE;
};
#undef INTERFACE
#if !defined (__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IDsCaptureDriverBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDsCaptureDriverBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDsCaptureDriverBuffer_Release(p) (p)->lpVtbl->Release(p)
/*** IDsCaptureDriverBuffer methods ***/
#define IDsCaptureDriverBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
#define IDsCaptureDriverBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
#define IDsCaptureDriverBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a)
#define IDsCaptureDriverBuffer_GetPosition(p,a,b) (p)->lpVtbl->GetPosition(p,a,b)
#define IDsCaptureDriverBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a)
#define IDsCaptureDriverBuffer_Start(p,a) (p)->lpVtbl->Start(p,a)
#define IDsCaptureDriverBuffer_Stop(p) (p)->lpVtbl->Stop(p)
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __WINE_DSDRIVER_H */

View file

@ -13,18 +13,12 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DSOUND_H
#define __WINE_DSOUND_H
// hack
#ifndef __DSOUND_INCLUDED__
#define __DSOUND_INCLUDED__
#ifndef DIRECTSOUND_VERSION
#define DIRECTSOUND_VERSION 0x0900
#endif
@ -60,8 +54,6 @@ typedef D3DVECTOR *LPD3DVECTOR;
#define LPD3DVECTOR_DEFINED
#endif
#define DX_SHARED_DEFINES
#endif /* DX_SHARED_DEFINES */
@ -240,6 +232,8 @@ typedef const DSCAPS *LPCDSCAPS;
#define DSBFREQUENCY_MAX 200000
#define DSBFREQUENCY_ORIGINAL 0
#define DSBNOTIFICATIONS_MAX 100000U
typedef struct _DSBCAPS
{
DWORD dwSize;
@ -307,13 +301,18 @@ typedef struct _DSBPOSITIONNOTIFY
} DSBPOSITIONNOTIFY,*LPDSBPOSITIONNOTIFY;
typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY;
#define DSSPEAKER_DIRECTOUT 0
#define DSSPEAKER_HEADPHONE 1
#define DSSPEAKER_MONO 2
#define DSSPEAKER_QUAD 3
#define DSSPEAKER_STEREO 4
#define DSSPEAKER_SURROUND 5
#define DSSPEAKER_5POINT1 6
#define DSSPEAKER_5POINT1_BACK 6
#define DSSPEAKER_7POINT1 7
#define DSSPEAKER_7POINT1_WIDE 7
#define DSSPEAKER_7POINT1_SURROUND 8
#define DSSPEAKER_5POINT1_SURROUND 9
#define DSSPEAKER_GEOMETRY_MIN 0x00000005 /* 5 degrees */
#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A /* 10 degrees */
@ -404,14 +403,16 @@ typedef const GUID *LPCGUID;
typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID,LPCWSTR,LPCWSTR,LPVOID);
typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID,LPCSTR,LPCSTR,LPVOID);
DECL_WINELIB_TYPE_AW(LPDSENUMCALLBACK)
extern HRESULT WINAPI DirectSoundCreate(LPCGUID lpGUID,LPDIRECTSOUND *ppDS,LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA, LPVOID);
extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW, LPVOID);
#define DirectSoundEnumerate WINELIB_NAME_AW(DirectSoundEnumerate)
extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID lpGUID, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA, LPVOID);
extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW, LPVOID);
#define DirectSoundCaptureEnumerate WINELIB_NAME_AW(DirectSoundCaptureEnumerate)
extern HRESULT WINAPI DirectSoundCreate8(LPCGUID lpGUID,LPDIRECTSOUND8 *ppDS8,LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID lpGUID, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter);
@ -421,15 +422,6 @@ extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, L
#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate
extern HRESULT WINAPI GetDeviceID(LPCGUID lpGuidSrc, LPGUID lpGuidDest);
#ifdef UNICODE
# define DirectSoundEnumerate DirectSoundEnumerateW
# define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW
# define LPDSENUMCALLBACK LPDSENUMCALLBACKW
#else
# define DirectSoundEnumerate DirectSoundEnumerateA
# define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA
# define LPDSENUMCALLBACK LPDSENUMCALLBACKA
#endif
/*****************************************************************************
* IDirectSound interface
@ -562,7 +554,7 @@ DECLARE_INTERFACE_(IDirectSoundBuffer,IUnknown)
STDMETHOD(GetFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
STDMETHOD(GetStatus)(THIS_ LPDWORD lpdwStatus) PURE;
STDMETHOD(Initialize)(THIS_ LPDIRECTSOUND lpDirectSound, LPCDSBUFFERDESC lpcDSBufferDesc) PURE;
STDMETHOD(Lock)(THIS_ DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOID *lplpvAudioPtr1, LPDWORD lpdwAudioBytes1, LPVOID *lplpvAudioPtr2, LPDWORD lpdwAudioBytes2, DWORD dwFlags) PURE;
STDMETHOD(Lock)(THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE;
STDMETHOD(Play)(THIS_ DWORD dwReserved1, DWORD dwReserved2, DWORD dwFlags) PURE;
STDMETHOD(SetCurrentPosition)(THIS_ DWORD dwNewPosition) PURE;
STDMETHOD(SetFormat)(THIS_ LPCWAVEFORMATEX lpcfxFormat) PURE;
@ -570,7 +562,7 @@ DECLARE_INTERFACE_(IDirectSoundBuffer,IUnknown)
STDMETHOD(SetPan)(THIS_ LONG lPan) PURE;
STDMETHOD(SetFrequency)(THIS_ DWORD dwFrequency) PURE;
STDMETHOD(Stop)(THIS) PURE;
STDMETHOD(Unlock)(THIS_ LPVOID lpvAudioPtr1, DWORD dwAudioBytes1, LPVOID lpvAudioPtr2, DWORD dwAudioPtr2) PURE;
STDMETHOD(Unlock)(THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioPtr2) PURE;
STDMETHOD(Restore)(THIS) PURE;
};
#undef INTERFACE
@ -645,7 +637,7 @@ DECLARE_INTERFACE_(IDirectSoundBuffer8,IUnknown)
STDMETHOD(GetFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
STDMETHOD(GetStatus)(THIS_ LPDWORD lpdwStatus) PURE;
STDMETHOD(Initialize)(THIS_ LPDIRECTSOUND lpDirectSound, LPCDSBUFFERDESC lpcDSBufferDesc) PURE;
STDMETHOD(Lock)(THIS_ DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOID *lplpvAudioPtr1, LPDWORD lpdwAudioBytes1, LPVOID *lplpvAudioPtr2, LPDWORD lpdwAudioBytes2, DWORD dwFlags) PURE;
STDMETHOD(Lock)(THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE;
STDMETHOD(Play)(THIS_ DWORD dwReserved1, DWORD dwReserved2, DWORD dwFlags) PURE;
STDMETHOD(SetCurrentPosition)(THIS_ DWORD dwNewPosition) PURE;
STDMETHOD(SetFormat)(THIS_ LPCWAVEFORMATEX lpcfxFormat) PURE;
@ -653,7 +645,7 @@ DECLARE_INTERFACE_(IDirectSoundBuffer8,IUnknown)
STDMETHOD(SetPan)(THIS_ LONG lPan) PURE;
STDMETHOD(SetFrequency)(THIS_ DWORD dwFrequency) PURE;
STDMETHOD(Stop)(THIS) PURE;
STDMETHOD(Unlock)(THIS_ LPVOID lpvAudioPtr1, DWORD dwAudioBytes1, LPVOID lpvAudioPtr2, DWORD dwAudioPtr2) PURE;
STDMETHOD(Unlock)(THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioPtr2) PURE;
STDMETHOD(Restore)(THIS) PURE;
STDMETHOD(SetFX)(THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE;
STDMETHOD(AcquireResources)(THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE;
@ -882,7 +874,6 @@ DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8,IDirectSoundCaptureBuffer)
#define WINE_NOBUFFER 0x80000000
#define DSBPN_OFFSETSTOP -1
#define DSBNOTIFICATIONS_MAX 100000UL
#define INTERFACE IDirectSoundNotify
DECLARE_INTERFACE_(IDirectSoundNotify,IUnknown)
@ -1091,7 +1082,7 @@ DECLARE_INTERFACE_(IDirectSound3DBuffer,IUnknown)
#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a)
#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a)
#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b) (p)->lpVtbl->SetConeAngles(p,a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c)
#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d)
#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b)
#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b)
@ -1115,7 +1106,7 @@ DECLARE_INTERFACE_(IDirectSound3DBuffer,IUnknown)
#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a)
#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a)
#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b) (p)->SetConeAngles(a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c)
#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d)
#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b)
#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b)
@ -1209,4 +1200,4 @@ DECLARE_INTERFACE_(IDirectSoundFullDuplex,IUnknown)
} /* extern "C" */
#endif /* defined(__cplusplus) */
#endif /* __WINE_DSOUND_H */
#endif /* __DSOUND_INCLUDED__ */

View file

@ -33,18 +33,16 @@
#ifdef INITGUID
#ifdef __cplusplus
#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \
EXTERN_C const PROPERTYKEY name DECLSPEC_HIDDEN DECLSPEC_SELECTANY; \
EXTERN_C const PROPERTYKEY name = \
EXTERN_C const PROPERTYKEY DECLSPEC_SELECTANY name DECLSPEC_HIDDEN = \
{ { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
#else
#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \
const PROPERTYKEY name DECLSPEC_HIDDEN DECLSPEC_SELECTANY; \
const PROPERTYKEY name = \
const PROPERTYKEY DECLSPEC_SELECTANY name DECLSPEC_HIDDEN = \
{ { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
#endif
#else
#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \
EXTERN_C const PROPERTYKEY name DECLSPEC_HIDDEN DECLSPEC_SELECTANY
EXTERN_C const PROPERTYKEY name DECLSPEC_HIDDEN
#endif
#ifndef IsEqualPropertyKey
@ -60,6 +58,7 @@
#ifdef __cplusplus
extern "C++"
{
inline bool operator==(REFPROPERTYKEY guidOne, REFPROPERTYKEY guidOther)
{
return IsEqualPropertyKey(guidOne, guidOther);
@ -68,6 +67,7 @@ inline bool operator!=(REFPROPERTYKEY guidOne, REFPROPERTYKEY guidOther)
{
return !(guidOne == guidOther);
}
} //extern "C++"
}
#endif
#endif

View file

@ -33,6 +33,7 @@ reactos/dll/directx/dinput8 # Synced to Wine-20090208
reactos/dll/directx/dmusic # Synced to Wine-1.5.26
reactos/dll/directx/dplay # Synced to Wine-1.5.26
reactos/dll/directx/dplayx # Synced to Wine-1.5.26
reactos/dll/directx/dsound # Synced to Wine-1.5.26
reactos/dll/directx/dxdiagn # Synced to Wine-0_9_5
reactos/dll/directx/msdmo # Autosync
reactos/dll/directx/qedit # Autosync