ReactOS 0.4.15-dev-7906-g1b85a5f
kernel.c File Reference
#include "precomp.h"
Include dependency graph for kernel.c:

Go to the source code of this file.

Functions

MMRESULT OpenKernelSoundDeviceByName (IN PWSTR DevicePath, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
 
MMRESULT CloseKernelSoundDevice (IN HANDLE Handle)
 
MMRESULT SyncOverlappedDeviceIoControl (IN HANDLE Handle, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
 

Function Documentation

◆ CloseKernelSoundDevice()

MMRESULT CloseKernelSoundDevice ( IN HANDLE  Handle)

Definition at line 58 of file kernel.c.

60{
62
64
65 return MMSYSERR_NOERROR;
66}
#define CloseHandle
Definition: compat.h:739
ULONG Handle
Definition: gdb_input.c:15
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96

Referenced by CloseNt4SoundDevice(), GetNt4SoundDeviceCapabilities(), and QueryNt4WaveDeviceFormatSupport().

◆ OpenKernelSoundDeviceByName()

MMRESULT OpenKernelSoundDeviceByName ( IN PWSTR  DevicePath,
IN BOOLEAN  ReadOnly,
OUT PHANDLE  Handle 
)

Definition at line 23 of file kernel.c.

27{
28 DWORD AccessRights;
29
30 VALIDATE_MMSYS_PARAMETER( DevicePath );
32
34
35 SND_TRACE(L"OpenKernelSoundDeviceByName: %wS\n", DevicePath);
36 *Handle = CreateFile(DevicePath,
37 AccessRights,
38 FILE_SHARE_WRITE, /* FIXME? Should be read also? */
39 NULL,
42 NULL);
43
45 {
46 SND_ERR(L"CreateFile filed - winerror %d\n", GetLastError());
48 }
49
50 return MMSYSERR_NOERROR;
51}
#define NULL
Definition: types.h:112
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
unsigned long DWORD
Definition: ntddk_ex.h:95
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
Definition: utility.c:87
#define SND_TRACE(...)
#define SND_ERR(...)
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
@ ReadOnly
Definition: arc.h:80
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateFile
Definition: winbase.h:3749

Referenced by DetectNt4SoundDevices(), and OpenNt4KernelSoundDevice().

◆ SyncOverlappedDeviceIoControl()

MMRESULT SyncOverlappedDeviceIoControl ( IN HANDLE  Handle,
IN DWORD  IoControlCode,
IN LPVOID  InBuffer,
IN DWORD  InBufferSize,
OUT LPVOID  OutBuffer,
IN DWORD  OutBufferSize,
OUT LPDWORD BytesTransferred  OPTIONAL 
)

Definition at line 74 of file kernel.c.

82{
83 OVERLAPPED Overlapped;
84 BOOLEAN IoResult;
85 DWORD Transferred;
86
87 /* Overlapped I/O is done here - this is used for waiting for completion */
88 ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
89 Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
90
91 if ( ! Overlapped.hEvent )
93
94 /* Talk to the device */
95 IoResult = DeviceIoControl(Handle,
97 InBuffer,
101 NULL,
102 &Overlapped);
103
104 /* If failure occurs, make sure it's not just due to the overlapped I/O */
105 if ( ! IoResult )
106 {
108 {
109 CloseHandle(Overlapped.hEvent);
111 }
112 }
113
114 /* Wait for the I/O to complete */
115 IoResult = GetOverlappedResult(Handle,
116 &Overlapped,
117 &Transferred,
118 TRUE);
119
120 /* Don't need this any more */
121 CloseHandle(Overlapped.hEvent);
122
123 if ( ! IoResult )
125
126 SND_TRACE(L"Transferred %d bytes in Sync overlapped I/O\n", Transferred);
127
128 if ( BytesTransferred )
129 *BytesTransferred = Transferred;
130
131 return MMSYSERR_NOERROR;
132}
unsigned char BOOLEAN
#define ERROR_IO_PENDING
Definition: dderror.h:15
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)
Definition: deviceio.c:136
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
HANDLE hEvent
Definition: winbase.h:820
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1342
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
#define ZeroMemory
Definition: winbase.h:1712
#define CreateEvent
Definition: winbase.h:3748