ReactOS  0.4.12-dev-43-g63b00d8
pnp_list_lock.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: base/services/audiosrv/pnp_list_lock.c
5  * PURPOSE: Audio Service Plug and Play list locking mechanism
6  * COPYRIGHT: Copyright 2007 Andrew Greenwood
7  */
8 
9 #include "audiosrv.h"
10 
11 #include <assert.h>
12 
14 
15 BOOL
17 {
18  /* The security stuff is to make sure the mutex can be grabbed by
19  other processes - is this the best idea though ??? */
20 
21  SECURITY_DESCRIPTOR security_descriptor;
23 
25  SetSecurityDescriptorDacl(&security_descriptor, TRUE, 0, FALSE);
26 
27  security.nLength = sizeof(SECURITY_ATTRIBUTES);
28  security.lpSecurityDescriptor = &security_descriptor;
29  security.bInheritHandle = FALSE;
30 
31  audio_device_list_lock = CreateMutex(&security,
32  FALSE,
34 
35  return ( audio_device_list_lock != NULL );
36 }
37 
38 VOID
40 {
41  CloseHandle(audio_device_list_lock);
42  audio_device_list_lock = NULL;
43 }
44 
45 VOID
47 {
48  assert( audio_device_list_lock != NULL );
49  WaitForSingleObject(audio_device_list_lock, INFINITE);
50 }
51 
52 VOID
54 {
55  assert( audio_device_list_lock != NULL );
56  ReleaseMutex(audio_device_list_lock);
57 }
58 
VOID UnlockAudioDeviceList()
Definition: pnp_list_lock.c:53
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:804
#define assert(x)
Definition: debug.h:53
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static HANDLE audio_device_list_lock
Definition: pnp_list_lock.c:13
VOID KillAudioDeviceListLock()
Definition: pnp_list_lock.c:39
smooth NULL
Definition: ftsmooth.c:416
VOID LockAudioDeviceList()
Definition: pnp_list_lock.c:46
#define AUDIO_LIST_LOCK_NAME
Definition: audiosrv.h:19
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CreateMutex
Definition: winbase.h:3570
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:564
LPVOID lpSecurityDescriptor
Definition: compat.h:181
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
BOOL InitializeAudioDeviceListLock()
Definition: pnp_list_lock.c:16
#define INFINITE
Definition: serial.h:102
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES