2 * MIDI driver for OSS (PE-side)
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1998 Luiz Otavio L. Zorzella (init procedures)
6 * Copyright 1998, 1999 Eric POUECH
7 * Copyright 2022 Huw Davies
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 * + use better instrument definition for OPL/2 (midiPatch.c) or
26 * use existing instrument definition (from playmidi or kmid)
27 * with a .winerc option
28 * + have a look at OPL/3 ?
29 * + implement asynchronous playback of MidiHdr
30 * + implement STREAM'ed MidiHdr (question: how shall we share the
31 * code between the midiStream functions in MMSYSTEM/WINMM and
32 * the code for the low level driver)
33 * + use a more accurate read mechanism than the one of snooping on
34 * timers (like select on fd)
45 #include "audioclient.h"
47 #include "wine/debug.h"
48 #include "wine/unixlib.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(midi
);
54 /*======================================================================*
55 * Low level MIDI implementation *
56 *======================================================================*/
58 static void notify_client(struct notify_context
*notify
)
60 TRACE("dev_id = %d msg = %d param1 = %04IX param2 = %04IX\n",
61 notify
->dev_id
, notify
->msg
, notify
->param_1
, notify
->param_2
);
63 DriverCallback(notify
->callback
, notify
->flags
, notify
->device
, notify
->msg
,
64 notify
->instance
, notify
->param_1
, notify
->param_2
);
67 /*======================================================================*
69 *======================================================================*/
71 /**************************************************************************
72 * midMessage (WINEOSS.@)
74 DWORD WINAPI
OSS_midMessage(UINT wDevID
, UINT wMsg
, DWORD_PTR dwUser
,
75 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
77 struct midi_in_message_params params
;
78 struct notify_context notify
;
81 TRACE("(%04X, %04X, %08IX, %08IX, %08IX);\n",
82 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
84 params
.dev_id
= wDevID
;
87 params
.param_1
= dwParam1
;
88 params
.param_2
= dwParam2
;
90 params
.notify
= ¬ify
;
94 OSS_CALL(midi_in_message
, ¶ms
);
95 if ((!err
|| err
== ERROR_RETRY
) && notify
.send_notify
) notify_client(¬ify
);
96 } while (err
== ERROR_RETRY
);
101 /**************************************************************************
102 * modMessage (WINEOSS.@)
104 DWORD WINAPI
OSS_modMessage(UINT wDevID
, UINT wMsg
, DWORD_PTR dwUser
,
105 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
107 struct midi_out_message_params params
;
108 struct notify_context notify
;
111 TRACE("(%04X, %04X, %08IX, %08IX, %08IX);\n",
112 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
114 params
.dev_id
= wDevID
;
116 params
.user
= dwUser
;
117 params
.param_1
= dwParam1
;
118 params
.param_2
= dwParam2
;
120 params
.notify
= ¬ify
;
122 OSS_CALL(midi_out_message
, ¶ms
);
124 if (!err
&& notify
.send_notify
) notify_client(¬ify
);
129 static DWORD WINAPI
notify_thread(void *p
)
131 struct midi_notify_wait_params params
;
132 struct notify_context notify
;
135 params
.notify
= ¬ify
;
140 OSS_CALL(midi_notify_wait
, ¶ms
);
142 if (notify
.send_notify
) notify_client(¬ify
);
147 /**************************************************************************
148 * DriverProc (WINEOSS.1)
150 LRESULT CALLBACK
OSS_DriverProc(DWORD_PTR dwDevID
, HDRVR hDriv
, UINT wMsg
,
151 LPARAM dwParam1
, LPARAM dwParam2
)
153 TRACE("(%08IX, %p, %08X, %08IX, %08IX)\n",
154 dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
158 CloseHandle(CreateThread(NULL
, 0, notify_thread
, NULL
, 0, NULL
));
161 OSS_CALL(midi_release
, NULL
);
167 case DRV_QUERYCONFIGURE
: