Version
menu_open
link

include/AK/Tools/PS4/AkLock.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
00003 released in source code form as part of the SDK installer package.
00004 
00005 Commercial License Usage
00006 
00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
00008 may use this file in accordance with the end user license agreement provided 
00009 with the software or, alternatively, in accordance with the terms contained in a
00010 written agreement between you and Audiokinetic Inc.
00011 
00012 Apache License Usage
00013 
00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 
00015 "Apache License"); you may not use this file except in compliance with the 
00016 Apache License. You may obtain a copy of the Apache License at 
00017 http://www.apache.org/licenses/LICENSE-2.0.
00018 
00019 Unless required by applicable law or agreed to in writing, software distributed
00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
00022 the specific language governing permissions and limitations under the License.
00023 
00024   Version: <VERSION>  Build: <BUILDNUMBER>
00025   Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00026 *******************************************************************************/
00027 
00028 #pragma once
00029 
00030 #include <AK/SoundEngine/Common/AkTypes.h>
00031 #include <AK/Tools/Common/AkAssert.h>
00032 
00033 //-----------------------------------------------------------------------------
00034 // CAkLock class
00035 //-----------------------------------------------------------------------------
00036 class CAkLock
00037 {
00038 public:
00039     /// Constructor
00040     CAkLock() :
00041         m_mutex(NULL)
00042     {
00043         /// Todo: use sceKernelCreateLwMutex when sdk is available for it
00044         
00045         ScePthreadMutexattr mutex_attr;
00046         AKVERIFY(!scePthreadMutexattrInit( &mutex_attr ));  
00047         AKVERIFY(!scePthreadMutexattrSettype( &mutex_attr, SCE_PTHREAD_MUTEX_RECURSIVE ));
00048         AKVERIFY(!scePthreadMutexattrSetprotocol(&mutex_attr, SCE_PTHREAD_PRIO_INHERIT));
00049         AKVERIFY(!scePthreadMutexInit( &m_mutex, &mutex_attr, NULL));
00050         AKVERIFY(!scePthreadMutexattrDestroy( &mutex_attr ));
00051     }
00052 
00053     /// Destructor
00054     ~CAkLock()
00055     {
00056         AKVERIFY(!scePthreadMutexDestroy( &m_mutex ));
00057     }
00058 
00059     /// Lock 
00060     inline AKRESULT Lock( void )
00061     {
00062         if( scePthreadMutexLock(&m_mutex) == SCE_OK )
00063         {
00064             return AK_Success;
00065         }
00066         return AK_Fail;
00067     }
00068 
00069     /// Unlock
00070     inline AKRESULT Unlock( void )
00071     {
00072         if( scePthreadMutexUnlock(&m_mutex) == SCE_OK )
00073         {
00074             return AK_Success;
00075         }
00076         return AK_Fail;
00077     }
00078 
00079 private:
00080     ScePthreadMutex m_mutex;
00081 };

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise