Commit 5a81b6ac authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

dsound: Dynamically allocate the global device GUID arrays.

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.
parent 73654470
......@@ -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 + 1) * 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);
......
......@@ -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[];
......
......@@ -60,12 +60,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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment