#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winioctl.h>
#include "mmioctl.h"
#include "mmddk.h"
Go to the source code of this file.
|
BOOL | NotifyClient (SessionInfo *session_info, DWORD message, DWORD_PTR parameter1, DWORD_PTR parameter2) |
|
MMRESULT | ErrorToMmResult (UINT error_code) |
|
MMRESULT | CobbleDeviceName (DeviceType device_type, UINT device_id, PWCHAR out_device_name) |
|
MMRESULT | OpenKernelDevice (DeviceType device_type, UINT device_id, DWORD access, HANDLE *handle) |
|
VOID | CloseKernelDevice (HANDLE device_handle) |
|
MMRESULT | SetDeviceData (HANDLE device_handle, DWORD ioctl, PBYTE input_buffer, DWORD buffer_size) |
|
MMRESULT | GetDeviceData (HANDLE device_handle, DWORD ioctl, PBYTE output_buffer, DWORD buffer_size) |
|
MMRESULT | CreateSession (DeviceType device_type, UINT device_id, SessionInfo **session_info) |
|
VOID | DestroySession (SessionInfo *session) |
|
SessionInfo * | GetSession (DeviceType device_type, UINT device_id) |
|
MMRESULT | StartSessionThread (SessionInfo *session_info) |
|
MMRESULT | CallSessionThread (SessionInfo *session_info, ThreadFunction function, PVOID thread_parameter) |
|
DWORD | HandleBySessionThread (DWORD_PTR private_handle, DWORD_PTR message, DWORD_PTR parameter) |
|
DWORD | GetDeviceCount (DeviceType device_type) |
|
DWORD | GetDeviceCapabilities (DeviceType device_type, UINT device_id, DWORD_PTR capabilities, DWORD capabilities_size) |
|
DWORD | OpenDevice (DeviceType device_type, UINT device_id, PVOID open_descriptor, DWORD flags, DWORD_PTR private_handle) |
|
DWORD | CloseDevice (DWORD_PTR private_handle) |
|
DWORD | PauseDevice (DWORD private_handle) |
|
DWORD | RestartDevice (DWORD private_handle) |
|
DWORD | ResetDevice (DWORD private_handle) |
|
DWORD | GetPosition (DWORD private_handle, PMMTIME time, DWORD time_size) |
|
DWORD | BreakLoop (DWORD private_handle) |
|
DWORD | QueryWaveFormat (DeviceType device_type, PVOID lpFormat) |
|
DWORD | WriteWaveBuffer (DWORD_PTR private_handle, PWAVEHDR wave_header, DWORD wave_header_size) |
|
DWORD | WaveThread (LPVOID parameter) |
|
VOID | PerformWaveIO (SessionInfo *session_info) |
|
◆ ASSERT
◆ DRVM_INVALID
#define DRVM_INVALID 0xFFFFFFFF |
◆ DRVM_TERMINATE
#define DRVM_TERMINATE 0xFFFFFFFE |
◆ IsAuxDevice
◆ IsMidiDevice
◆ IsWaveDevice
◆ MAX_BUFFER_SIZE
#define MAX_BUFFER_SIZE 1048576 |
◆ MAX_DEVICE_NAME_LENGTH
#define MAX_DEVICE_NAME_LENGTH 256 |
◆ MAX_DEVICES
◆ MAX_WAVE_BYTES
#define MAX_WAVE_BYTES 1048576 |
◆ WHDR_COMPLETE
#define WHDR_COMPLETE 0x80000000 |
◆ WIN32_NO_STATUS
◆ LoopInfo
◆ SessionInfo
◆ ThreadFunction
◆ ThreadInfo
◆ DeviceType
Initial value:{
_In_ PWDFDEVICE_INIT DeviceInit
PWDF_DRIVER_GLOBALS WdfDriverGlobals
@ WdfDeviceInitSetDeviceTypeTableIndex
Enumerator |
---|
WaveOutDevice | |
WaveInDevice | |
MidiOutDevice | |
MidiInDevice | |
AuxDevice | |
Definition at line 41 of file mmdrv.h.
◆ WaveState
Enumerator |
---|
WavePlaying | |
WaveStopped | |
WaveReset | |
WaveRestart | |
Definition at line 89 of file mmdrv.h.
◆ BreakLoop()
◆ CallSessionThread()
◆ CloseDevice()
Definition at line 239 of file common.c.
241{
244
245
247
249
251 {
252
253
255
257 }
258
260}
void CloseKernelDevice(HANDLE device_handle)
MMRESULT CallSessionThread(SessionInfo *session_info, ThreadFunction function, PVOID thread_parameter)
VOID DestroySession(SessionInfo *session)
HANDLE kernel_device_handle
◆ CloseKernelDevice()
◆ CobbleDeviceName()
Definition at line 28 of file kernel.c.
32{
34
35
36
38 {
41 break;
42
45 break;
46
49 break;
50
53 break;
54
57 break;
58
59 default :
61 };
62
63
64
67 base_device_name +
strlen(
"\\Device"),
68 device_id);
69
71}
ACPI_SIZE strlen(const char *String)
#define WAVE_OUT_DEVICE_NAME
#define MIDI_IN_DEVICE_NAME
#define MIDI_OUT_DEVICE_NAME
#define WAVE_IN_DEVICE_NAME
#define MAX_DEVICE_NAME_LENGTH
#define MMSYSERR_BADDEVICEID
Referenced by OpenKernelDevice().
◆ CreateSession()
Definition at line 63 of file session.c.
67{
69
71
73
74
75
77 {
78 DPRINT(
"Already allocated session\n");
81 }
82
84
85 if ( ! *session_info )
86 {
87 DPRINT(
"Failed to allocate mem for session info\n");
90 }
91
93 (*session_info)->device_id = device_id;
94
95
96
99
101
103}
SessionInfo * GetSession(DeviceType device_type, UINT device_id)
SessionInfo * session_list
CRITICAL_SECTION session_lock
#define MMSYSERR_ALLOCATED
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Referenced by CsrSbCreateSession(), OpenDevice(), and SmpLoadSubSystem().
◆ DestroySession()
Definition at line 113 of file session.c.
114{
118
119
120
121
122
124
127
128 while ( session_node )
129 {
131 {
132
134 break;
135 }
136
137
138 session_prev = session_node;
139 session_node = session_node->
next;
140 }
141
143
145}
#define HeapFree(x, y, z)
struct _SessionInfo * next
Referenced by CloseDevice(), and OpenDevice().
◆ ErrorToMmResult()
Definition at line 22 of file common.c.
23{
25 {
29
32
36
39
42
45 };
46
47
48
50}
#define ERROR_NOT_ENOUGH_MEMORY
#define ERROR_INSUFFICIENT_BUFFER
#define ERROR_INVALID_FUNCTION
#define ERROR_NOT_SUPPORTED
#define ERROR_ACCESS_DENIED
#define MMSYSERR_NOTSUPPORTED
#define MMSYSERR_INVALPARAM
Referenced by GetDeviceCapabilities(), GetDeviceData(), and OpenKernelDevice().
◆ GetDeviceCapabilities()
Definition at line 84 of file common.c.
89{
94 BOOL device_io_result;
95
97
98
99
106 else
108
110 device_id,
113
115 {
116 DPRINT(
"Failed to open kernel device\n");
118 }
119
123 0,
125 capabilities_size,
126 &bytes_returned,
128
129
130
131 if ( device_io_result )
133 else
135
136
137
139
141}
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
MMRESULT ErrorToMmResult(UINT error_code)
MMRESULT OpenKernelDevice(DeviceType device_type, UINT device_id, DWORD access, HANDLE *handle)
#define IOCTL_WAVE_GET_CAPABILITIES
#define IOCTL_MIDI_GET_CAPABILITIES
#define IsMidiDevice(devicetype)
#define IsWaveDevice(devicetype)
#define IsAuxDevice(devicetype)
DWORD WINAPI GetLastError(void)
◆ GetDeviceCount()
◆ GetDeviceData()
Definition at line 152 of file kernel.c.
157{
159 DWORD bytes_returned;
162
163 DPRINT(
"GetDeviceData\n");
164
165 memset(&overlap, 0,
sizeof(overlap));
166
168
171
175 0,
178 &bytes_returned,
179 &overlap);
180
182 {
184 {
186 {
189 }
190 }
191 else
192 {
195 }
196 }
197
199 {
201
203 {
204 break;
205 }
206 }
207
209
211}
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
#define success(from, fromstr, to, tostr)
#define WAIT_IO_COMPLETION
◆ GetPosition()
◆ GetSession()
Definition at line 30 of file session.c.
33{
35
38
39 while ( session_info )
40 {
42 ( session_info->
device_id == device_id ) )
43 {
45 return session_info;
46 }
47
48 session_info = session_info->
next;
49 }
50
53}
Referenced by CreateSession().
◆ HandleBySessionThread()
Definition at line 240 of file session.c.
244{
248}
MMRESULT CallSessionThread(SessionInfo *session_info, ThreadFunction function, PVOID thread_parameter)
Referenced by wodMessage().
◆ NotifyClient()
Definition at line 25 of file mme.c.
30{
36 parameter1,
37 parameter2);
38}
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
Referenced by OpenDevice(), and ReturnCompletedBuffers().
◆ OpenDevice()
Definition at line 153 of file common.c.
159{
163
164
166
168 {
169 DPRINT(
"Couldn't allocate session info\n");
171 }
172
174 device_id,
177
179 {
180 DPRINT(
"Failed to open kernel device\n");
183 }
184
185
186
188
189
190
192 {
197 }
198 else
199 {
200 DPRINT(
"Only wave devices are supported at present!\n");
203 }
204
205
206
208
210 {
213 }
214
215
216
218
219
220
225
227
229}
struct WAVEOPENDESC * LPWAVEOPENDESC
MMRESULT CreateSession(DeviceType device_type, UINT device_id, SessionInfo **session_info)
MMRESULT StartSessionThread(SessionInfo *session_info)
BOOL NotifyClient(SessionInfo *session_info, DWORD message, DWORD_PTR parameter1, DWORD_PTR parameter2)
◆ OpenKernelDevice()
Definition at line 84 of file kernel.c.
89{
93
95
96
97
99
101
104
105
106
109
110
111
117 open_flags,
119
122
124}
#define INVALID_HANDLE_VALUE
MMRESULT CobbleDeviceName(DeviceType device_type, UINT device_id, PWCHAR out_device_name)
static const WCHAR device_name[]
GLuint GLint GLboolean GLint GLenum access
#define FILE_FLAG_OVERLAPPED
Referenced by GetDeviceCapabilities(), GetDeviceCount(), and OpenDevice().
◆ PauseDevice()
◆ PerformWaveIO()
◆ QueryWaveFormat()
◆ ResetDevice()
◆ RestartDevice()
◆ SetDeviceData()
◆ StartSessionThread()
Definition at line 154 of file session.c.
155{
158
160
161
162
164
166 {
167 DPRINT(
"Couldn't create thread_ready event\n");
169 }
170
171
172
174
176 {
177 DPRINT(
"Couldn't create thread_go event\n");
180 }
181
182
185
187
188
189
193
195 {
196 DPRINT(
"Task creation failed\n");
200 }
201
202
203
205
207}
TASKCALLBACK FAR * LPTASKCALLBACK
UINT APIENTRY mmTaskCreate(LPTASKCALLBACK lpfn, HANDLE FAR *lph, DWORD dwInst)
DWORD WaveThread(LPVOID parameter)
Referenced by OpenDevice().
◆ WaveThread()
Definition at line 266 of file wave.c.
267{
271
272
274
275 DPRINT(
"Wave processing thread setting ready state\n");
276
278
280 {
281
285 {
286
288 }
289
290 DPRINT(
"Wave processing thread woken up\n");
291
292
294
295
296 DPRINT(
"Processing thread request\n");
298
299
301
302
303 DPRINT(
"Performing wave I/O\n");
305
306
307 DPRINT(
"Wave processing thread sleeping\n");
309 }
310
311 return 0;
312}
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
DWORD ProcessSessionThreadRequest(SessionInfo *session_info)
VOID ReturnCompletedBuffers(SessionInfo *session_info)
void MSVCRT() terminate()
VOID PerformWaveIO(SessionInfo *session_info)
HANDLE WINAPI GetCurrentThread(void)
#define THREAD_PRIORITY_TIME_CRITICAL
Referenced by StartSessionThread().
◆ WriteWaveBuffer()
◆ critical_section