wineoss: Add a temporary syscall to open and close the seq fd.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2022-04-20 09:03:26 -05:00 committed by Alexandre Julliard
parent 53eeb1162d
commit e37bf4e991
4 changed files with 34 additions and 40 deletions

View File

@ -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, &params);
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, &params);
return 0;
}

View File

@ -1406,4 +1406,6 @@ unixlib_entry_t __wine_unix_call_funcs[] =
set_event_handle,
is_started,
midi_init,
midi_seq_open,
};

View File

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

View File

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