include: Use proper dllimports for propsys functions.
[wine.git] / dlls / winealsa.drv / midi.c
blob1c441161d7e8834cf1a9130519b2bbf76b59b18c
1 /*
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
25 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winternl.h"
31 #include "mmddk.h"
32 #include "mmdeviceapi.h"
34 #include "wine/debug.h"
35 #include "wine/unixlib.h"
37 #include "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 /*======================================================================*
50 * MIDI entry points *
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;
61 UINT err;
63 TRACE("(%04X, %04X, %08IX, %08IX, %08IX);\n",
64 wDevID, wMsg, dwUser, dwParam1, dwParam2);
66 params.dev_id = wDevID;
67 params.msg = wMsg;
68 params.user = dwUser;
69 params.param_1 = dwParam1;
70 params.param_2 = dwParam2;
71 params.err = &err;
72 params.notify = &notify;
76 ALSA_CALL(midi_in_message, &params);
77 if ((!err || err == ERROR_RETRY) && notify.send_notify) notify_client(&notify);
78 } while (err == ERROR_RETRY);
80 return err;
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;
91 UINT err;
93 TRACE("(%04X, %04X, %08IX, %08IX, %08IX);\n",
94 wDevID, wMsg, dwUser, dwParam1, dwParam2);
96 params.dev_id = wDevID;
97 params.msg = wMsg;
98 params.user = dwUser;
99 params.param_1 = dwParam1;
100 params.param_2 = dwParam2;
101 params.err = &err;
102 params.notify = &notify;
104 ALSA_CALL(midi_out_message, &params);
106 if (!err && notify.send_notify) notify_client(&notify);
108 return err;
111 static DWORD WINAPI notify_thread(void *p)
113 struct midi_notify_wait_params params;
114 struct notify_context notify;
115 BOOL quit;
117 SetThreadDescription(GetCurrentThread(), L"winealsa_midi_notify");
119 params.notify = &notify;
120 params.quit = &quit;
122 while (1)
124 ALSA_CALL(midi_notify_wait, &params);
125 if (quit) break;
126 if (notify.send_notify) notify_client(&notify);
128 return 0;
131 /**************************************************************************
132 * DriverProc (WINEALSA.@)
134 LRESULT CALLBACK ALSA_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
135 LPARAM dwParam1, LPARAM dwParam2)
137 switch(wMsg) {
138 case DRV_LOAD:
139 CloseHandle(CreateThread(NULL, 0, notify_thread, NULL, 0, NULL));
140 return 1;
141 case DRV_FREE:
142 ALSA_CALL(midi_release, NULL);
143 return 1;
144 case DRV_OPEN:
145 case DRV_CLOSE:
146 case DRV_ENABLE:
147 case DRV_DISABLE:
148 case DRV_QUERYCONFIGURE:
149 case DRV_CONFIGURE:
150 return 1;
151 case DRV_INSTALL:
152 case DRV_REMOVE:
153 return DRV_SUCCESS;
154 default:
155 return 0;