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