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

winealsa.drv: Allocate the MIDI device array dynamically.

This commit is contained in:
Alexandre Julliard 2023-11-09 11:00:20 +01:00
parent 818385e176
commit 533823ed2a
2 changed files with 7 additions and 19 deletions

View File

@ -80,8 +80,8 @@ static pthread_mutex_t seq_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t in_buffer_mutex = PTHREAD_MUTEX_INITIALIZER;
static unsigned int num_dests, num_srcs;
static struct midi_dest dests[MAX_MIDIOUTDRV];
static struct midi_src srcs[MAX_MIDIINDRV];
static struct midi_dest *dests;
static struct midi_src *srcs;
static snd_seq_t *midi_seq;
static unsigned int seq_refs;
static int port_in = -1;
@ -298,12 +298,12 @@ static void port_add(snd_seq_client_info_t* cinfo, snd_seq_port_info_t* pinfo, u
snd_seq_port_info_get_name(pinfo),
type);
if (num_dests >= MAX_MIDIOUTDRV)
return;
if (!type)
return;
dests = realloc( dests, (num_dests + 1) * sizeof(*dests) );
dest = dests + num_dests;
memset( dest, 0, sizeof(*dest) );
dest->addr = *snd_seq_port_info_get_addr(pinfo);
/* Manufac ID. We do not have access to this with soundcard.h
@ -373,12 +373,12 @@ static void port_add(snd_seq_client_info_t* cinfo, snd_seq_port_info_t* pinfo, u
snd_seq_port_info_get_name(pinfo),
type);
if (num_srcs >= MAX_MIDIINDRV)
return;
if (!type)
return;
srcs = realloc( srcs, (num_srcs + 1) * sizeof(*srcs) );
src = srcs + num_srcs;
memset( src, 0, sizeof(*src) );
src->addr = *snd_seq_port_info_get_addr(pinfo);
/* Manufac ID. We do not have access to this with soundcard.h
@ -505,11 +505,7 @@ static UINT midi_out_open(WORD dev_id, MIDIOPENDESC *midi_desc, UINT flags, stru
WARN("Invalid Parameter !\n");
return MMSYSERR_INVALPARAM;
}
if (dev_id >= num_dests)
{
TRACE("MAX_MIDIOUTDRV reached !\n");
return MMSYSERR_BADDEVICEID;
}
if (dev_id >= num_dests) return MMSYSERR_BADDEVICEID;
dest = dests + dev_id;
if (dest->midiDesc.hMidi != 0)
{

View File

@ -30,14 +30,6 @@
extern "C" {
#endif
#define MAX_MIDIINDRV (16)
/* For now I'm making 16 the maximum number of midi devices one can
* have. This should be more than enough for everybody. But as a purist,
* I intend to make it unbounded in the future, as soon as I figure
* a good way to do so.
*/
#define MAX_MIDIOUTDRV (16)
/* ==================================
* Multimedia DDK compatible part
* ================================== */