reactos/reactos/base/services/audiosrv/pnp_list_lock.c
Andrew Greenwood 18b8710a37 ReactOS Audio Service. Has not been tested within ReactOS but on Windows
(XP) it now detects when new devices have been attached. This 
information is shared via a mapped file. I have also written a utility 
to read the contents of the mapped file (this is not included - further 
work is required).

Added a few missing #defines to dbt.h and also reformatted some of the 
WinMM code so it was clearer to read.


svn path=/trunk/; revision=29100
2007-09-19 04:13:24 +00:00

59 lines
1.5 KiB
C

/*
* PROJECT: ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/services/audiosrv/list_lock.c
* PURPOSE: Audio Service Plug and Play list locking mechanism
* COPYRIGHT: Copyright 2007 Andrew Greenwood
*/
#include <windows.h>
#include <assert.h>
#include <audiosrv/audiosrv.h>
static HANDLE audio_device_list_lock = NULL;
BOOL
InitializeAudioDeviceListLock()
{
/* The security stuff is to make sure the mutex can be grabbed by
other processes - is this the best idea though ??? */
SECURITY_DESCRIPTOR security_descriptor;
SECURITY_ATTRIBUTES security;
InitializeSecurityDescriptor(&security_descriptor, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&security_descriptor, TRUE, 0, FALSE);
security.nLength = sizeof(SECURITY_ATTRIBUTES);
security.lpSecurityDescriptor = &security_descriptor;
security.bInheritHandle = FALSE;
audio_device_list_lock = CreateMutex(&security,
FALSE,
AUDIO_LIST_LOCK_NAME);
return ( audio_device_list_lock != NULL );
}
VOID
KillAudioDeviceListLock()
{
CloseHandle(audio_device_list_lock);
audio_device_list_lock = NULL;
}
VOID
LockAudioDeviceList()
{
assert( audio_device_list_lock != NULL );
WaitForSingleObject(audio_device_list_lock, INFINITE);
}
VOID
UnlockAudioDeviceList()
{
assert( audio_device_list_lock != NULL );
ReleaseMutex(audio_device_list_lock);
}