From: Huw Davies huw@codeweavers.com
Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Andrew Eikum aeikum@codeweavers.com --- dlls/wineoss.drv/midi.c | 51 ++++++++------------------------------ dlls/wineoss.drv/oss.c | 2 ++ dlls/wineoss.drv/ossmidi.c | 12 +++++++++ dlls/wineoss.drv/unixlib.h | 9 +++++++ 4 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/dlls/wineoss.drv/midi.c b/dlls/wineoss.drv/midi.c index 10e5ba854b1..58047380639 100644 --- a/dlls/wineoss.drv/midi.c +++ b/dlls/wineoss.drv/midi.c @@ -75,7 +75,6 @@ static int MODM_NumFMSynthDevs = 0; /* this is the total number of MIDI out devices found */ static int MIDM_NumDevs = 0;
-static int numOpenMidiSeq = 0; static int numStartedMidiIn = 0;
static CRITICAL_SECTION crit_sect; /* protects all MidiIn buffers queues */ @@ -199,49 +198,18 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2); }
-static int midi_warn = 1; /************************************************************************** * midiOpenSeq [internal] */ static int midiOpenSeq(void) { - static int midiSeqFD = -1; + struct midi_seq_open_params params;
- if (numOpenMidiSeq == 0) { - const char* device; - device=getenv("MIDIDEV"); - if (!device) device="/dev/sequencer"; - midiSeqFD = open(device, O_RDWR, 0); - if (midiSeqFD == -1) { - if (midi_warn) - { - WARN("Can't open MIDI device '%s' ! (%s). If your " - "program needs this (probably not): %s\n", - device, strerror(errno), - errno == ENOENT ? - "create it ! ("man MAKEDEV" ?)" : - errno == ENODEV ? - "load MIDI sequencer kernel driver !" : - errno == EACCES ? - "grant access ! ("man chmod")" : "" - ); - } - midi_warn = 0; - return -1; - } -#if 0 - if (fcntl(midiSeqFD, F_SETFL, O_NONBLOCK) < 0) { - WARN("can't set sequencer fd to non-blocking, errno %d (%s)\n", errno, strerror(errno)); - close(midiSeqFD); - midiSeqFD = -1; - return -1; - } -#endif - fcntl(midiSeqFD, F_SETFD, 1); /* set close on exec flag */ - ioctl(midiSeqFD, SNDCTL_SEQ_RESET); - } - numOpenMidiSeq++; - return midiSeqFD; + params.close = 0; + params.fd = -1; + OSS_CALL(midi_seq_open, ¶ms); + + return params.fd; }
/************************************************************************** @@ -249,8 +217,11 @@ static int midiOpenSeq(void) */ static int midiCloseSeq(int fd) { - if (--numOpenMidiSeq == 0) - close(fd); + struct midi_seq_open_params params; + + params.close = 1; + params.fd = fd; + OSS_CALL(midi_seq_open, ¶ms);
return 0; } diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index 4f3c0bcb2cf..ac8847920b0 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -1406,4 +1406,6 @@ unixlib_entry_t __wine_unix_call_funcs[] = set_event_handle, is_started, midi_init, + + midi_seq_open, }; diff --git a/dlls/wineoss.drv/ossmidi.c b/dlls/wineoss.drv/ossmidi.c index 75fbf6d7bee..a0a0b1caad2 100644 --- a/dlls/wineoss.drv/ossmidi.c +++ b/dlls/wineoss.drv/ossmidi.c @@ -119,6 +119,18 @@ static int seq_close(int fd) return 0; }
+NTSTATUS midi_seq_open(void *args) +{ + struct midi_seq_open_params *params = args; + + if (!params->close) + params->fd = seq_open(); + else + seq_close(params->fd); + + return STATUS_SUCCESS; +} + NTSTATUS midi_init(void *args) { struct midi_init_params *params = args; diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h index 8c131037b76..68d41e41f74 100644 --- a/dlls/wineoss.drv/unixlib.h +++ b/dlls/wineoss.drv/unixlib.h @@ -246,6 +246,12 @@ struct midi_init_params struct midi_src *srcs; };
+struct midi_seq_open_params +{ + int close; + int fd; +}; + enum oss_funcs { oss_test_connect, @@ -272,9 +278,12 @@ enum oss_funcs oss_set_event_handle, oss_is_started, oss_midi_init, + + oss_midi_seq_open, /* temporary */ };
NTSTATUS midi_init(void *args) DECLSPEC_HIDDEN; +NTSTATUS midi_seq_open(void *args) DECLSPEC_HIDDEN;
extern unixlib_handle_t oss_handle;