1
0
mirror of https://github.com/wine-mirror/wine synced 2024-06-29 06:14:34 +00:00

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.
This commit is contained in:
Alex Henrie 2023-10-19 22:39:07 -06:00 committed by Alexandre Julliard
parent 73654470ab
commit 5a81b6ac43
3 changed files with 15 additions and 10 deletions

View File

@ -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);

View File

@ -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[];

View File

@ -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