Commit 048a8c33 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winealsa: Allocate the pollfd array at the start.

parent be6004f8
...@@ -158,33 +158,21 @@ static int midiCloseSeq(void) ...@@ -158,33 +158,21 @@ static int midiCloseSeq(void)
static DWORD WINAPI midRecThread(void *arg) static DWORD WINAPI midRecThread(void *arg)
{ {
snd_seq_t *midi_seq = arg; snd_seq_t *midi_seq = arg;
int npfd; int num_fds;
struct pollfd *pfd; struct pollfd *pollfd;
int ret; int ret;
TRACE("Thread startup\n"); num_fds = snd_seq_poll_descriptors_count(midi_seq, POLLIN);
pollfd = malloc(num_fds * sizeof(struct pollfd));
while(!end_thread) { while(!end_thread) {
TRACE("Thread loop\n");
seq_lock(); seq_lock();
npfd = snd_seq_poll_descriptors_count(midi_seq, POLLIN); snd_seq_poll_descriptors(midi_seq, pollfd, num_fds, POLLIN);
pfd = HeapAlloc(GetProcessHeap(), 0, npfd * sizeof(struct pollfd));
snd_seq_poll_descriptors(midi_seq, pfd, npfd, POLLIN);
seq_unlock(); seq_unlock();
/* Check if an event is present */ /* Check if an event is present */
if (poll(pfd, npfd, 250) <= 0) { if (poll(pollfd, num_fds, 250) <= 0)
HeapFree(GetProcessHeap(), 0, pfd); continue;
continue;
}
/* Note: This definitely does not work.
* while(snd_seq_event_input_pending(midi_seq, 0) > 0) {
snd_seq_event_t* ev;
snd_seq_event_input(midi_seq, &ev);
....................
snd_seq_free_event(ev);
}*/
do { do {
snd_seq_event_t *ev; snd_seq_event_t *ev;
...@@ -202,9 +190,9 @@ static DWORD WINAPI midRecThread(void *arg) ...@@ -202,9 +190,9 @@ static DWORD WINAPI midRecThread(void *arg)
ret = snd_seq_event_input_pending(midi_seq, 0); ret = snd_seq_event_input_pending(midi_seq, 0);
seq_unlock(); seq_unlock();
} while(ret > 0); } while(ret > 0);
HeapFree(GetProcessHeap(), 0, pfd);
} }
free(pollfd);
return 0; return 0;
} }
......
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