ReactOS  0.4.14-dev-342-gdc047f9
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:406
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
_In_ HANDLE Handle
Definition: extypes.h:390
#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 
33  AccessRights = ReadOnly ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE;
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 
44  if ( *Handle == INVALID_HANDLE_VALUE )
45  {
46  SND_ERR(L"CreateFile filed - winerror %d\n", GetLastError());
48  }
49 
50  return MMSYSERR_NOERROR;
51 }
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
Definition: utility.c:87
Definition: arc.h:80
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
_In_ HANDLE Handle
Definition: extypes.h:390
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SND_ERR(...)
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define SND_TRACE(...)

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,
99  OutBuffer,
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  {
107  if ( GetLastError() != ERROR_IO_PENDING )
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 }
#define CreateEvent
Definition: winbase.h:3572
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
Definition: utility.c:87
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
#define ERROR_IO_PENDING
Definition: dderror.h:15
HANDLE hEvent
Definition: winbase.h:792
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG InBufferSize
Definition: classpnp.h:429
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
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 SND_TRACE(...)