ReactOS  0.4.14-dev-376-gaedba84
reentrancy.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Sound System "MME Buddy" Library
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: lib/sound/mmebuddy/reentrancy.c
5  *
6  * PURPOSE: Provides entry-point mutex guards.
7  *
8  * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
9 */
10 
11 #include "precomp.h"
12 
14 
15 /*
16  Creates a set of mutexes which are used for the purpose of guarding the
17  device-type specific module entry-points. If any of these fail creation,
18  all of them will be destroyed and the failure reported.
19 */
22 {
23  UCHAR i;
25 
26  /* Blank all entries ni the table first */
27  for ( i = 0; i < SOUND_DEVICE_TYPES; ++ i )
28  {
30  }
31 
32  /* Now create the mutexes */
33  for ( i = 0; i < SOUND_DEVICE_TYPES; ++ i )
34  {
36 
37  if ( ! EntrypointMutexes[i] )
38  {
40 
41  /* Clean up any mutexes we successfully created */
43  break;
44  }
45  }
46 
47  return Result;
48 }
49 
50 /*
51  Cleans up any of the entry-point guard mutexes. This will only close the
52  handles of mutexes which have been created, making it safe for use as a
53  cleanup routine even within the InitEntrypointMutexes routine above.
54 */
55 VOID
57 {
58  UCHAR i;
59 
60  /* Only clean up a mutex if it actually exists */
61  for ( i = 0; i < SOUND_DEVICE_TYPES; ++ i )
62  {
63  if ( EntrypointMutexes[i] )
64  {
67  }
68  }
69 }
70 
71 /*
72  Grabs an entry-point mutex.
73 */
74 VOID
77 {
78  UCHAR i;
79 
82 
84 
86 }
87 
88 /*
89  Releases an entry-point mutex.
90 */
91 VOID
94 {
95  UCHAR i;
96 
99 
101 
103 }
#define IN
Definition: typedefs.h:38
#define CloseHandle
Definition: compat.h:406
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
Definition: utility.c:87
DeviceType
Definition: mmdrv.h:41
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE EntrypointMutexes[SOUND_DEVICE_TYPES]
Definition: reentrancy.c:13
UINT MMRESULT
Definition: mmsystem.h:962
VOID ReleaseEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
Definition: reentrancy.c:92
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define SND_ASSERT(condition)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define CreateMutex
Definition: winbase.h:3580
VOID CleanupEntrypointMutexes()
Definition: reentrancy.c:56
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID AcquireEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
Definition: reentrancy.c:75
MMRESULT InitEntrypointMutexes()
Definition: reentrancy.c:21
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define INFINITE
Definition: serial.h:102