This removes the arbitrary limit on the number of renderers and capturers while satisfying applications that expect the GUIDs to remain valid after DirectSoundCaptureEnumerate returns.
From: Alex Henrie alexhenrie24@gmail.com
This reverts commit e1f0318ec4fe83fdc86407303d55f4ee5ba3d2e7.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55608 --- dlls/dsound/dsound_main.c | 31 ++++++++++++++++++++----------- dlls/dsound/dsound_private.h | 6 +++++- dlls/dsound/propset.c | 12 ++++++++---- 3 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 810ae616308..84a118f43aa 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -73,6 +73,9 @@ static CRITICAL_SECTION_DEBUG DSOUND_renderers_lock_debug = }; CRITICAL_SECTION DSOUND_renderers_lock = { &DSOUND_renderers_lock_debug, -1, 0, 0, 0, 0 };
+GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]; +GUID DSOUND_capture_guids[MAXWAVEDRIVERS]; + const WCHAR wine_vxd_drv[] = L"winemm.vxd";
/* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */ @@ -385,13 +388,13 @@ HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device) return DSERR_INVALIDPARAM; }
-static BOOL send_device(IMMDevice *device, LPDSENUMCALLBACKW cb, void *user) +static BOOL send_device(IMMDevice *device, GUID *guid, + LPDSENUMCALLBACKW cb, void *user) { IPropertyStore *ps; PROPVARIANT pv; BOOL keep_going; HRESULT hr; - GUID guid;
PropVariantInit(&pv);
@@ -401,7 +404,7 @@ static BOOL send_device(IMMDevice *device, LPDSENUMCALLBACKW cb, void *user) return TRUE; }
- hr = get_mmdevice_guid(device, ps, &guid); + hr = get_mmdevice_guid(device, ps, guid); if(FAILED(hr)){ IPropertyStore_Release(ps); return TRUE; @@ -415,10 +418,10 @@ static BOOL send_device(IMMDevice *device, LPDSENUMCALLBACKW cb, void *user) return TRUE; }
- TRACE("Calling back with %s (%s)\n", wine_dbgstr_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); + keep_going = cb(guid, pv.pwszVal, wine_vxd_drv, user);
PropVariantClear(&pv); IPropertyStore_Release(ps); @@ -428,12 +431,13 @@ static BOOL send_device(IMMDevice *device, LPDSENUMCALLBACKW cb, void *user)
/* S_FALSE means the callback returned FALSE at some point * S_OK means the callback always returned TRUE */ -HRESULT enumerate_mmdevices(EDataFlow flow, LPDSENUMCALLBACKW cb, void *user) +HRESULT enumerate_mmdevices(EDataFlow flow, GUID *guids, + LPDSENUMCALLBACKW cb, void *user) { IMMDeviceEnumerator *devenum; IMMDeviceCollection *coll; IMMDevice *defdev = NULL; - UINT count, i; + UINT count, i, n; BOOL keep_going; HRESULT hr, init_hr;
@@ -472,8 +476,10 @@ HRESULT enumerate_mmdevices(EDataFlow flow, LPDSENUMCALLBACKW cb, void *user) eMultimedia, &defdev); if(FAILED(hr)){ defdev = NULL; + n = 0; }else{ - keep_going = send_device(defdev, cb, user); + keep_going = send_device(defdev, &guids[0], cb, user); + n = 1; } }
@@ -487,7 +493,8 @@ HRESULT enumerate_mmdevices(EDataFlow flow, LPDSENUMCALLBACKW cb, void *user) }
if(device != defdev){ - keep_going = send_device(device, cb, user); + keep_going = send_device(device, &guids[n], cb, user); + ++n; }
IMMDevice_Release(device); @@ -530,7 +537,8 @@ HRESULT WINAPI DirectSoundEnumerateW(
setup_dsound_options();
- hr = enumerate_mmdevices(eRender, lpDSEnumCallback, lpContext); + hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids, + lpDSEnumCallback, lpContext); return SUCCEEDED(hr) ? DS_OK : hr; }
@@ -593,7 +601,8 @@ DirectSoundCaptureEnumerateW(
setup_dsound_options();
- hr = enumerate_mmdevices(eCapture, lpDSEnumCallback, lpContext); + hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids, + lpDSEnumCallback, lpContext); return SUCCEEDED(hr) ? DS_OK : hr; }
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index 6c3eb672f31..46c150fc9fc 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -255,6 +255,9 @@ HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void ** extern CRITICAL_SECTION DSOUND_renderers_lock; extern struct list DSOUND_renderers;
+extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]; +extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS]; + extern const WCHAR wine_vxd_drv[];
void setup_dsound_options(void); @@ -263,4 +266,5 @@ HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device);
BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate, DWORD depth, WORD channels); -HRESULT enumerate_mmdevices(EDataFlow flow, LPDSENUMCALLBACKW cb, void *user); +HRESULT enumerate_mmdevices(EDataFlow flow, GUID *guids, + LPDSENUMCALLBACKW cb, void *user); diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c index 5d9ad45b01b..be284a6dda5 100644 --- a/dlls/dsound/propset.c +++ b/dlls/dsound/propset.c @@ -134,9 +134,11 @@ static HRESULT DSPROPERTY_WaveDeviceMappingW( search.found_guid = &ppd->DeviceId;
if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) - hr = enumerate_mmdevices(eRender, search_callback, &search); + hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids, + search_callback, &search); else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) - hr = enumerate_mmdevices(eCapture, search_callback, &search); + hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids, + search_callback, &search); else return DSERR_INVALIDPARAM;
@@ -314,10 +316,12 @@ static HRESULT DSPROPERTY_EnumerateW( return E_PROP_ID_UNSUPPORTED; }
- hr = enumerate_mmdevices(eRender, enum_callback, ppd); + hr = enumerate_mmdevices(eRender, DSOUND_renderer_guids, + enum_callback, ppd);
if(hr == S_OK) - hr = enumerate_mmdevices(eCapture, enum_callback, ppd); + hr = enumerate_mmdevices(eCapture, DSOUND_capture_guids, + enum_callback, ppd);
return SUCCEEDED(hr) ? DS_OK : hr; }
From: Alex Henrie alexhenrie24@gmail.com
This removes the arbitrary limit on the number of renderers and capturers while satisfying applications that expect the GUIDs to remain valid after DirectSoundCaptureEnumerate returns. --- dlls/dsound/dsound_main.c | 15 +++++++++++++-- dlls/dsound/dsound_private.h | 4 ++-- include/mmsystem.h | 6 ------ 3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 84a118f43aa..77e87a0185b 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -73,8 +73,11 @@ static CRITICAL_SECTION_DEBUG DSOUND_renderers_lock_debug = }; CRITICAL_SECTION DSOUND_renderers_lock = { &DSOUND_renderers_lock_debug, -1, 0, 0, 0, 0 };
-GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]; -GUID DSOUND_capture_guids[MAXWAVEDRIVERS]; +/* Some applications expect the GUID pointers emitted from DirectSoundCaptureEnumerate to remain + * valid at least until the next time DirectSoundCaptureEnumerate is called, so we store them in + * these dynamically allocated arrays. */ +GUID *DSOUND_renderer_guids; +GUID *DSOUND_capture_guids;
const WCHAR wine_vxd_drv[] = L"winemm.vxd";
@@ -461,11 +464,19 @@ HRESULT enumerate_mmdevices(EDataFlow flow, GUID *guids, return DS_OK; }
+ free(guids); if(count == 0){ IMMDeviceCollection_Release(coll); release_mmdevenum(devenum, init_hr); + guids = NULL; return DS_OK; } + guids = malloc(count * sizeof(GUID)); + if(!guids){ + IMMDeviceCollection_Release(coll); + release_mmdevenum(devenum, init_hr); + return E_OUTOFMEMORY; + }
TRACE("Calling back with NULL (Primary Sound Driver)\n"); keep_going = cb(NULL, L"Primary Sound Driver", L"", user); diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index 46c150fc9fc..34498125317 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -255,8 +255,8 @@ HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void ** extern CRITICAL_SECTION DSOUND_renderers_lock; extern struct list DSOUND_renderers;
-extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]; -extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS]; +extern GUID *DSOUND_renderer_guids; +extern GUID *DSOUND_capture_guids;
extern const WCHAR wine_vxd_drv[];
diff --git a/include/mmsystem.h b/include/mmsystem.h index 5684ff20683..04864cf5f63 100644 --- a/include/mmsystem.h +++ b/include/mmsystem.h @@ -54,12 +54,6 @@ typedef HWAVEOUT *LPHWAVEOUT;
typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD_PTR,HDRVR,UINT,LPARAM,LPARAM);
-#define MAXWAVEDRIVERS 10 -#define MAXMIDIDRIVERS 10 -#define MAXAUXDRIVERS 10 -#define MAXMCIDRIVERS 32 -#define MAXMIXERDRIVERS 10 - #define MAXPNAMELEN 32 /* max product name length (including NULL) */ #define MAXERRORLENGTH 256 /* max error text length (including NULL) */ #define MAX_JOYSTICKOEMVXDNAME 260
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=138942
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/dsound/dsound_main.c:73 error: patch failed: dlls/dsound/dsound_private.h:255 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dsound/dsound_main.c:73 error: patch failed: dlls/dsound/dsound_private.h:255 Task: Patch failed to apply
=== debian11b (build log) ===
error: patch failed: dlls/dsound/dsound_main.c:73 error: patch failed: dlls/dsound/dsound_private.h:255 Task: Patch failed to apply