AJA NTV2 SDK
17.1.3.1410
NTV2 SDK 17.1.3.1410
lockimpl.cpp
Go to the documentation of this file.
1
/* SPDX-License-Identifier: MIT */
8
#include "
ajabase/system/windows/lockimpl.h
"
9
#include "
ajabase/system/debug.h
"
10
11
12
// class AJALockImpl
13
14
AJALockImpl::AJALockImpl
(
const
char
* pName)
15
{
16
// initialize the windows lock
17
mMutex = CreateMutex(
NULL
, FALSE, pName);
18
}
19
20
21
AJALockImpl::~AJALockImpl
()
22
{
23
// delete the windows lock
24
if
(mMutex !=
NULL
)
25
{
26
CloseHandle(mMutex);
27
}
28
}
29
30
31
AJAStatus
32
AJALockImpl::Lock
(uint32_t timeout)
33
{
34
if
(mMutex ==
NULL
)
35
{
36
return
AJA_STATUS_INITIALIZE
;
37
}
38
39
// check for infinite timeout
40
if
(timeout == 0xffffffff)
41
{
42
timeout = INFINITE;
43
}
44
45
// obtain the lock
46
DWORD retCode = WaitForSingleObject(mMutex, (DWORD)timeout);
47
48
// we got the lock
49
if
(retCode == WAIT_OBJECT_0)
50
{
51
return
AJA_STATUS_SUCCESS
;
52
}
53
// the wait timed out
54
else
if
(retCode == WAIT_TIMEOUT)
55
{
56
return
AJA_STATUS_TIMEOUT
;
57
}
58
59
// some type of error occurred
60
AJA_REPORT
(0,
AJA_DebugSeverity_Error
,
"AJALock::Lock WaitForSingleObject() returns error %08x"
, retCode);
61
62
return
AJA_STATUS_FAIL
;
63
}
64
65
66
AJAStatus
67
AJALockImpl::Unlock
()
68
{
69
if
(mMutex ==
NULL
)
70
{
71
return
AJA_STATUS_INITIALIZE
;
72
}
73
74
// release the lock
75
DWORD retCode = ReleaseMutex(mMutex);
76
77
return
AJA_STATUS_SUCCESS
;
78
}
lockimpl.h
Declares the AJALockImpl class.
NULL
#define NULL
Definition:
ntv2caption608types.h:19
AJALockImpl::~AJALockImpl
virtual ~AJALockImpl()
Definition:
lockimpl.cpp:72
AJA_STATUS_SUCCESS
@ AJA_STATUS_SUCCESS
Definition:
types.h:381
AJALockImpl::Unlock
AJAStatus Unlock()
Definition:
lockimpl.cpp:143
AJA_DebugSeverity_Error
@ AJA_DebugSeverity_Error
Definition:
debugshare.h:28
AJAStatus
AJAStatus
Definition:
types.h:378
AJA_STATUS_FAIL
@ AJA_STATUS_FAIL
Definition:
types.h:382
AJA_REPORT
#define AJA_REPORT(_index_, _severity_, _format_,...)
Definition:
debug.h:117
AJALockImpl::Lock
AJAStatus Lock(uint32_t uTimeout=0xffffffff)
Definition:
lockimpl.cpp:87
AJA_STATUS_TIMEOUT
@ AJA_STATUS_TIMEOUT
Definition:
types.h:384
AJA_STATUS_INITIALIZE
@ AJA_STATUS_INITIALIZE
Definition:
types.h:386
AJALockImpl::AJALockImpl
AJALockImpl(const char *pName)
Definition:
lockimpl.cpp:20
debug.h
Declares the AJADebug class.
libajantv2
ajabase
system
windows
lockimpl.cpp
Generated on Tue Dec 3 2024 10:25:59 for AJA NTV2 SDK by
1.8.17