Some small dsound fixes I came up with while looking into Wine bug 30639
-- v4: dsound/tests: Mark weird DescriptionW propset failure on the AMD testbot machine. dsound: Return the mmdevapi endpoint ID as module. dsound: Fill all the DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE data. dsound: Check data size in propset methods. dsound: Consistently trace locked byte count as an unsigned value. dsound: Print time as an unsigned value. dsound: Simplify check in DSOUND_RecalcFormat(). dsound/tests: Get rid of a crashing test.
From: Matteo Bruni mbruni@codeweavers.com
The test was introduced by e28638afccdfda3ee44121405d9097d201b61445, for the fix in 70aeb7e4b0eb8efefd24c26d1c1442ea6c25d082. It looks like that particular game worked on Windows by chance more than anything. --- dlls/dsound/tests/dsound.c | 7 ------- 1 file changed, 7 deletions(-)
diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c index b995d112769..a7d6fa0fc3b 100644 --- a/dlls/dsound/tests/dsound.c +++ b/dlls/dsound/tests/dsound.c @@ -1177,13 +1177,6 @@ static HRESULT test_duplicate(LPGUID lpGuid) ok(rc==DS_OK && buf!=NULL, "IDirectSoundBuffer_Lock failed to lock the buffer %08lx\n",rc); if (rc==DS_OK && buf!=NULL) { - if (sizeof(void*)==4) { /* crashes on 64-bit */ - /* broken apps like Asuka 120% Return BURNING Fest, - pass the pointer to GlobalHandle. */ - HGLOBAL hmem = GlobalHandle(buf); - ok(!hmem,"GlobalHandle should return NULL " - "for buffer %p, got %p\n",buf,hmem); - } ZeroMemory(buf,bufsize); rc=IDirectSoundBuffer_Unlock(original,buf,bufsize, NULL,0);
From: Matteo Bruni mbruni@codeweavers.com
--- dlls/dsound/mixer.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index 552e11fc361..dbc84cbd04f 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -117,15 +117,10 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) * sample in the secondary buffer. firgain specifies what * to multiply the FIR output by in order to attenuate it correctly. */ - if (dsb->freqAdjustNum / dsb->freqAdjustDen > 0) { - /** - * Yes, round it a bit to make sure that the - * linear interpolation factor never changes. - */ + if (dsb->freqAdjustNum > dsb->freqAdjustDen) dsb->firstep = fir_step * dsb->freqAdjustDen / dsb->freqAdjustNum; - } else { + else dsb->firstep = fir_step; - } dsb->firgain = (float)dsb->firstep / fir_step;
/* calculate the 10ms write lead */
From: Matteo Bruni mbruni@codeweavers.com
--- dlls/dsound/buffer.c | 4 ++-- dlls/dsound/capture.c | 2 +- dlls/dsound/primary.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index c0fe0cc1fd6..4cab21fb84d 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -417,7 +417,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_GetCurrentPosition(IDirectSoundBuff
ReleaseSRWLockShared(&This->lock);
- TRACE("playpos = %ld, writepos = %ld, buflen=%ld (%p, time=%ld)\n", + TRACE("playpos = %ld, writepos = %ld, buflen=%ld (%p, time=%lu)\n", playpos?*playpos:-1, writepos?*writepos:-1, This->buflen, This, GetTickCount());
return DS_OK; @@ -491,7 +491,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(IDirectSoundBuffer8 *iface, DW IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface); HRESULT hres = DS_OK;
- TRACE("(%p,%ld,%ld,%p,%p,%p,%p,0x%08lx) at %ld\n", This, writecursor, writebytes, lplpaudioptr1, + TRACE("(%p,%ld,%ld,%p,%p,%p,%p,0x%08lx) at %lu\n", This, writecursor, writebytes, lplpaudioptr1, audiobytes1, lplpaudioptr2, audiobytes2, flags, GetTickCount());
if (!audiobytes1 || !lplpaudioptr1) diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index c3f6902c15b..dfb5e7d921c 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -429,7 +429,7 @@ static HRESULT WINAPI IDirectSoundCaptureBufferImpl_Lock(IDirectSoundCaptureBuff IDirectSoundCaptureBufferImpl *This = impl_from_IDirectSoundCaptureBuffer8(iface); HRESULT hres = DS_OK;
- TRACE( "(%p,%08lu,%08lu,%p,%p,%p,%p,0x%08lx) at %ld\n", This, dwReadCusor, + TRACE( "(%p,%08lu,%08lu,%p,%p,%p,%p,0x%08lx) at %lu\n", This, dwReadCusor, dwReadBytes, lplpvAudioPtr1, lpdwAudioBytes1, lplpvAudioPtr2, lpdwAudioBytes2, dwFlags, GetTickCount() );
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index 9a5557f2c83..6d15838bfac 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -725,7 +725,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetCurrentPosition(IDirectSoundBuffer8 * LeaveCriticalSection(&(device->mixlock)); /* **** */
- TRACE("playpos = %ld, writepos = %ld (%p, time=%ld)\n", playpos?*playpos:0, writepos?*writepos:0, device, GetTickCount()); + TRACE("playpos = %ld, writepos = %ld (%p, time=%lu)\n", playpos?*playpos:0, writepos?*writepos:0, device, GetTickCount()); return DS_OK; }
@@ -789,7 +789,7 @@ static HRESULT WINAPI PrimaryBufferImpl_Lock(IDirectSoundBuffer8 *iface, DWORD w HRESULT hres; IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface); DirectSoundDevice *device = This->device; - TRACE("(%p,%ld,%ld,%p,%p,%p,%p,0x%08lx) at %ld\n", + TRACE("(%p,%ld,%ld,%p,%p,%p,%p,0x%08lx) at %lu\n", iface, writecursor, writebytes,
From: Matteo Bruni mbruni@codeweavers.com
--- dlls/dsound/buffer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index 4cab21fb84d..c716e979b49 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -491,7 +491,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(IDirectSoundBuffer8 *iface, DW IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface); HRESULT hres = DS_OK;
- TRACE("(%p,%ld,%ld,%p,%p,%p,%p,0x%08lx) at %lu\n", This, writecursor, writebytes, lplpaudioptr1, + TRACE("(%p,%lu,%lu,%p,%p,%p,%p,0x%08lx) at %lu\n", This, writecursor, writebytes, lplpaudioptr1, audiobytes1, lplpaudioptr2, audiobytes2, flags, GetTickCount());
if (!audiobytes1 || !lplpaudioptr1) @@ -539,9 +539,9 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(IDirectSoundBuffer8 *iface, DW commit_next_chunk(This); } *audiobytes1 = writebytes; - TRACE("Locked %p(%li bytes) and %p(%li bytes) writecursor=%ld\n", + TRACE("Locked %p (%lu bytes) and %p (%lu bytes) writecursor=%lu\n", *(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor); - TRACE("->%ld.0\n",writebytes); + TRACE("->%lu\n", writebytes); This->buffer->lockedbytes += writebytes; } else { DWORD remainder = writebytes + writecursor - This->buflen; @@ -562,7 +562,9 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(IDirectSoundBuffer8 *iface, DW WARN("Overwriting mixing position, case 3\n"); commit_next_chunk(This); } - TRACE("Locked %p(%li bytes) and %p(%li bytes) writecursor=%ld\n", *(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor); + TRACE("Locked %p (%lu bytes) and %p (%lu bytes) writecursor=%lu\n", + *(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, + audiobytes2 ? *audiobytes2: 0, writecursor); }
ReleaseSRWLockShared(&This->lock); @@ -655,7 +657,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Unlock(IDirectSoundBuffer8 *iface, IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface), *iter; HRESULT hres = DS_OK;
- TRACE("(%p,%p,%ld,%p,%ld)\n", This,p1,x1,p2,x2); + TRACE("(%p,%p,%lu,%p,%lu)\n", This, p1, x1, p2, x2);
if (!p2) x2 = 0;
From: Matteo Bruni mbruni@codeweavers.com
--- dlls/dsound/propset.c | 6 ++++++ dlls/dsound/tests/propset.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c index 28df7887f65..4283618196e 100644 --- a/dlls/dsound/propset.c +++ b/dlls/dsound/propset.c @@ -202,6 +202,9 @@ static HRESULT DSPROPERTY_DescriptionW( TRACE("pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n", pPropData,cbPropData,pcbReturned);
+ if (cbPropData < sizeof(*ppd)) + return E_INVALIDARG; + TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId)); if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) { /* default device of type specified by ppd->DataFlow */ @@ -316,6 +319,9 @@ static HRESULT DSPROPERTY_EnumerateW( return E_PROP_ID_UNSUPPORTED; }
+ if (cbPropData < sizeof(*ppd)) + return E_INVALIDARG; + hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids, enum_callback, ppd);
diff --git a/dlls/dsound/tests/propset.c b/dlls/dsound/tests/propset.c index 88c5132bc6c..bd36973d2ef 100644 --- a/dlls/dsound/tests/propset.c +++ b/dlls/dsound/tests/propset.c @@ -429,9 +429,14 @@ static void propset_private_tests(void) 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); + DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE, + NULL, 0, &data, 1, &bytes); + ok(rc == E_INVALIDARG, "Unexpected rc 0x%lx\n", rc); + + 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 */
From: Matteo Bruni mbruni@codeweavers.com
Fixes: 8856ea79f3468d6f532f5f20e9b28c295d6e1db1 --- dlls/dsound/propset.c | 64 +++++++++++++++++++++---------------- dlls/dsound/tests/propset.c | 5 ++- 2 files changed, 40 insertions(+), 29 deletions(-)
diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c index 4283618196e..7c87f6ab40b 100644 --- a/dlls/dsound/propset.c +++ b/dlls/dsound/propset.c @@ -264,11 +264,16 @@ static HRESULT DSPROPERTY_DescriptionW( return S_OK; }
-static -BOOL CALLBACK enum_callback(GUID *guid, const WCHAR *desc, const WCHAR *module, - void *user) +struct enum_callback_ctx { - PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = user; + DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA *pd; + EDataFlow flow; + unsigned int id; +}; + +static BOOL CALLBACK enum_callback(GUID *guid, const WCHAR *desc, const WCHAR *module, void *user) +{ + struct enum_callback_ctx *ctx = user; DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data; DWORD len; BOOL ret; @@ -279,19 +284,19 @@ BOOL CALLBACK enum_callback(GUID *guid, const WCHAR *desc, const WCHAR *module, if(!guid) return TRUE;
+ data.Type = DIRECTSOUNDDEVICE_TYPE_WDM; + data.DataFlow = ctx->flow == eRender ? DIRECTSOUNDDEVICE_DATAFLOW_RENDER : DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE; data.DeviceId = *guid; - - len = lstrlenW(module) + 1; - data.Module = malloc(len * sizeof(WCHAR)); - memcpy(data.Module, module, len * sizeof(WCHAR)); - len = lstrlenW(desc) + 1; data.Description = malloc(len * sizeof(WCHAR)); memcpy(data.Description, desc, len * sizeof(WCHAR)); - + len = lstrlenW(module) + 1; + data.Module = malloc(len * sizeof(WCHAR)); + memcpy(data.Module, module, len * sizeof(WCHAR)); data.Interface = wInterface; + data.WaveDeviceId = ctx->id++;
- ret = ppd->Callback(&data, ppd->Context); + ret = ctx->pd->Callback(&data, ctx->pd->Context);
free(data.Module); free(data.Description); @@ -299,35 +304,34 @@ BOOL CALLBACK enum_callback(GUID *guid, const WCHAR *desc, const WCHAR *module, return ret; }
-static HRESULT DSPROPERTY_EnumerateW( - LPVOID pPropData, - ULONG cbPropData, - PULONG pcbReturned ) +static HRESULT DSPROPERTY_EnumerateW(LPVOID pd, ULONG size, PULONG out_size) { - PDSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA ppd = pPropData; + struct enum_callback_ctx ctx = {pd}; HRESULT hr;
- TRACE("(pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n", - pPropData,cbPropData,pcbReturned); + TRACE("pd %p, size %lu, out_size %p\n", pd, size, out_size);
- if (pcbReturned) - *pcbReturned = 0; + if (out_size) + *out_size = sizeof(*ctx.pd);
- if (!ppd || !ppd->Callback) + if (!pd || !ctx.pd->Callback) { - WARN("Invalid ppd %p\n", ppd); + WARN("Invalid pd %p\n", pd); return E_PROP_ID_UNSUPPORTED; }
- if (cbPropData < sizeof(*ppd)) + if (size < sizeof(ctx.pd)) return E_INVALIDARG;
- hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids, - enum_callback, ppd); + ctx.flow = eRender; + hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids, enum_callback, &ctx);
- if(hr == S_OK) - hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids, - enum_callback, ppd); + if (hr == S_OK) + { + ctx.flow = eCapture; + ctx.id = 0; + hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids, enum_callback, &ctx); + }
return SUCCEEDED(hr) ? DS_OK : hr; } @@ -381,6 +385,8 @@ static BOOL CALLBACK DSPROPERTY_enumWtoA(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTIO DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA *ppd = data; BOOL ret;
+ TRACE("descW %p, data %p\n", descW, data); + ret = DSPROPERTY_descWtoA(descW, &descA); if (!ret) return FALSE; @@ -398,6 +404,8 @@ static HRESULT DSPROPERTY_EnumerateA( DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA *ppd = pPropData; DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
+ TRACE("pPropData %p, cbPropData %lu, pcbReturned %p\n", pPropData, cbPropData, pcbReturned); + if (!ppd || !ppd->Callback) { WARN("Invalid ppd %p\n", ppd); diff --git a/dlls/dsound/tests/propset.c b/dlls/dsound/tests/propset.c index bd36973d2ef..3a691c14729 100644 --- a/dlls/dsound/tests/propset.c +++ b/dlls/dsound/tests/propset.c @@ -423,7 +423,7 @@ static void propset_private_tests(void)
if (support & KSPROPERTY_SUPPORT_GET) { DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data; - ULONG bytes; + ULONG bytes = 0;
data.Callback = callback; data.Context = 0; @@ -432,11 +432,14 @@ static void propset_private_tests(void) DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE, NULL, 0, &data, 1, &bytes); ok(rc == E_INVALIDARG, "Unexpected rc 0x%lx\n", rc); + ok(bytes == sizeof(data), "Unexpected bytes %lu\n", bytes);
+ bytes = 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); + ok(bytes == sizeof(data), "Unexpected bytes %lu\n", bytes); }
/* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
From: Matteo Bruni mbruni@codeweavers.com
This is the expected behavior when dsound is implemented on top of mmdevapi (Vista+).
Fixes: 8856ea79f3468d6f532f5f20e9b28c295d6e1db1 --- dlls/dsound/dsound_main.c | 7 ++++--- dlls/dsound/dsound_private.h | 2 -- dlls/dsound/propset.c | 7 +++++-- 3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 19e94c1071d..8936b437ba2 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -79,8 +79,6 @@ CRITICAL_SECTION DSOUND_renderers_lock = { &DSOUND_renderers_lock_debug, -1, 0, GUID *DSOUND_renderer_guids; GUID *DSOUND_capture_guids;
-const WCHAR wine_vxd_drv[] = L"winemm.vxd"; - /* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */ int ds_hel_buflen = 32768 * 2;
@@ -408,6 +406,7 @@ static BOOL send_device(IMMDevice *device, GUID *guid, PROPVARIANT pv; BOOL keep_going; HRESULT hr; + WCHAR *id;
PropVariantInit(&pv);
@@ -434,8 +433,10 @@ static BOOL send_device(IMMDevice *device, GUID *guid, TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid), wine_dbgstr_w(pv.pwszVal));
- keep_going = cb(guid, pv.pwszVal, wine_vxd_drv, user); + hr = IMMDevice_GetId(device, &id); + keep_going = cb(guid, pv.pwszVal, id, user);
+ CoTaskMemFree(id); PropVariantClear(&pv); IPropertyStore_Release(ps);
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index 89053cff722..647f2273838 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -259,8 +259,6 @@ extern struct list DSOUND_renderers; extern GUID *DSOUND_renderer_guids; extern GUID *DSOUND_capture_guids;
-extern const WCHAR wine_vxd_drv[]; - void setup_dsound_options(void);
HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device); diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c index 7c87f6ab40b..7e079599ca7 100644 --- a/dlls/dsound/propset.c +++ b/dlls/dsound/propset.c @@ -198,6 +198,7 @@ static HRESULT DSPROPERTY_DescriptionW( IPropertyStore *ps; PROPVARIANT pv; HRESULT hr; + WCHAR *id;
TRACE("pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n", pPropData,cbPropData,pcbReturned); @@ -248,9 +249,11 @@ static HRESULT DSPROPERTY_DescriptionW( }
ppd->Description = wcsdup(pv.pwszVal); - ppd->Module = wcsdup(wine_vxd_drv); + hr = IMMDevice_GetId(mmdevice, &id); + ppd->Module = wcsdup(id); + CoTaskMemFree(id); ppd->Interface = wcsdup(wInterface); - ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD; + ppd->Type = DIRECTSOUNDDEVICE_TYPE_WDM;
PropVariantClear(&pv); IPropertyStore_Release(ps);
From: Matteo Bruni mbruni@codeweavers.com
--- dlls/dsound/tests/propset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/dsound/tests/propset.c b/dlls/dsound/tests/propset.c index 3a691c14729..6b39426d12f 100644 --- a/dlls/dsound/tests/propset.c +++ b/dlls/dsound/tests/propset.c @@ -312,7 +312,7 @@ static void propset_private_tests(void) rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice, DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1, NULL, 0, &data, sizeof(data), &bytes); - ok(rc==DS_OK, "Couldn't get description: 0x%lx\n",rc); + ok(rc==DS_OK || broken(rc == 0x88780078), "Couldn't get description: 0x%lx\n",rc); } /* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */ rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
This merge request was approved by Huw Davies.