2 * MIDI driver for ALSA (PE-side)
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1998 Luiz Otavio L. Zorzella
6 * Copyright 1998, 1999 Eric POUECH
7 * Copyright 2003 Christian Costa
8 * Copyright 2022 Huw Davies
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "mmdeviceapi.h"
34 #include "wine/debug.h"
35 #include "wine/unixlib.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(midi
);
41 static void notify_client(struct notify_context
*notify
)
43 TRACE("dev_id = %d msg = %d param1 = %04IX param2 = %04IX\n", notify
->dev_id
, notify
->msg
, notify
->param_1
, notify
->param_2
);
45 DriverCallback(notify
->callback
, notify
->flags
, notify
->device
, notify
->msg
,
46 notify
->instance
, notify
->param_1
, notify
->param_2
);
49 /*======================================================================*
51 *======================================================================*/
53 /**************************************************************************
54 * midMessage (WINEALSA.@)
56 DWORD WINAPI
ALSA_midMessage(UINT wDevID
, UINT wMsg
, DWORD_PTR dwUser
,
57 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
59 struct midi_in_message_params params
;
60 struct notify_context notify
;
63 TRACE("(%04X, %04X, %08IX, %08IX, %08IX);\n",
64 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
66 params
.dev_id
= wDevID
;
69 params
.param_1
= dwParam1
;
70 params
.param_2
= dwParam2
;
72 params
.notify
= ¬ify
;
76 ALSA_CALL(midi_in_message
, ¶ms
);
77 if ((!err
|| err
== ERROR_RETRY
) && notify
.send_notify
) notify_client(¬ify
);
78 } while (err
== ERROR_RETRY
);
83 /**************************************************************************
84 * modMessage (WINEALSA.@)
86 DWORD WINAPI
ALSA_modMessage(UINT wDevID
, UINT wMsg
, DWORD_PTR dwUser
,
87 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
89 struct midi_out_message_params params
;
90 struct notify_context notify
;
93 TRACE("(%04X, %04X, %08IX, %08IX, %08IX);\n",
94 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
96 params
.dev_id
= wDevID
;
99 params
.param_1
= dwParam1
;
100 params
.param_2
= dwParam2
;
102 params
.notify
= ¬ify
;
104 ALSA_CALL(midi_out_message
, ¶ms
);
106 if (!err
&& notify
.send_notify
) notify_client(¬ify
);
111 static DWORD WINAPI
notify_thread(void *p
)
113 struct midi_notify_wait_params params
;
114 struct notify_context notify
;
117 SetThreadDescription(GetCurrentThread(), L
"winealsa_midi_notify");
119 params
.notify
= ¬ify
;
124 ALSA_CALL(midi_notify_wait
, ¶ms
);
126 if (notify
.send_notify
) notify_client(¬ify
);
131 /**************************************************************************
132 * DriverProc (WINEALSA.@)
134 LRESULT CALLBACK
ALSA_DriverProc(DWORD_PTR dwDevID
, HDRVR hDriv
, UINT wMsg
,
135 LPARAM dwParam1
, LPARAM dwParam2
)
139 CloseHandle(CreateThread(NULL
, 0, notify_thread
, NULL
, 0, NULL
));
142 ALSA_CALL(midi_release
, NULL
);
148 case DRV_QUERYCONFIGURE
: