diff -r 128eb6a32b84 -r 8dfd592727cb khronosfws/openmax_al/src/engine/xathreadsyncitf.c --- a/khronosfws/openmax_al/src/engine/xathreadsyncitf.c Thu May 27 13:20:50 2010 +0300 +++ b/khronosfws/openmax_al/src/engine/xathreadsyncitf.c Wed Jun 23 18:47:10 2010 +0300 @@ -1,19 +1,19 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: ThreadSync Itf Implementation + * + */ #include #include @@ -25,110 +25,113 @@ * Base interface XAThreadSyncItf Implementation */ XAresult XAThreadSyncItfImpl_EnterCriticalSection(XAThreadSyncItf self) -{ + { XAresult ret = XA_RESULT_SUCCESS; XAThreadSyncItfImpl* impl = NULL; DEBUG_API("->XAThreadSyncItfImpl_EnterCriticalSection"); - impl = (XAThreadSyncItfImpl*)(*self); - if( !impl || impl != impl->self ) - { + impl = (XAThreadSyncItfImpl*) (*self); + if (!impl || impl != impl->self) + { DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); DEBUG_API("<-XAThreadSyncItfImpl_EnterCriticalSection"); return XA_RESULT_PARAMETER_INVALID; - } + } - if( impl->engInCritical ) - { + if (impl->engInCritical) + { /* The calling context must not already be in - critical section state. */ + critical section state. */ DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED"); ret = XA_RESULT_PRECONDITIONS_VIOLATED; - } + } else - { - ret = XAImpl_LockMutex( impl->engCriticalSection ); - if(ret == XA_RESULT_SUCCESS) { + ret = XAImpl_LockMutex(impl->engCriticalSection); + if (ret == XA_RESULT_SUCCESS) + { impl->engInCritical = XA_BOOLEAN_TRUE; - } + } + }DEBUG_API("<-XAThreadSyncItfImpl_EnterCriticalSection"); + return ret; } - DEBUG_API("<-XAThreadSyncItfImpl_EnterCriticalSection"); - return ret; -} XAresult XAThreadSyncItfImpl_ExitCriticalSection(XAThreadSyncItf self) -{ + { XAThreadSyncItfImpl* impl = NULL; XAresult ret = XA_RESULT_SUCCESS; - impl = (XAThreadSyncItfImpl*)(*self); + impl = (XAThreadSyncItfImpl*) (*self); DEBUG_API("->XAThreadSyncItfImpl_ExitCriticalSection"); - if( !impl || impl != impl->self ) - { + if (!impl || impl != impl->self) + { DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); DEBUG_API("<-XAThreadSyncItfImpl_ExitCriticalSection"); return XA_RESULT_PARAMETER_INVALID; - } + } - if( impl->engInCritical ) - { - ret = XAImpl_UnlockMutex( impl->engCriticalSection ); - if(ret == XA_RESULT_SUCCESS) + if (impl->engInCritical) { + ret = XAImpl_UnlockMutex(impl->engCriticalSection); + if (ret == XA_RESULT_SUCCESS) + { impl->engInCritical = XA_BOOLEAN_FALSE; + } } - } else - { + { /* The engine must be in critical section state */ DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED"); ret = XA_RESULT_PRECONDITIONS_VIOLATED; + }DEBUG_API("<-XAThreadSyncItfImpl_ExitCriticalSection"); + return ret; } - DEBUG_API("<-XAThreadSyncItfImpl_ExitCriticalSection"); - return ret; -} /** * XAThreadSyncItfImpl -specific methods **/ XAThreadSyncItfImpl* XAThreadSyncItfImpl_Create() -{ + { XAThreadSyncItfImpl *self = NULL; DEBUG_API("->XAThreadSyncItfImpl_Create"); - self = (XAThreadSyncItfImpl*)calloc(1,sizeof(XAThreadSyncItfImpl)); + self = (XAThreadSyncItfImpl*) calloc(1, sizeof(XAThreadSyncItfImpl)); - if( self ) - { + if (self) + { /* init itf default implementation */ - self->itf.EnterCriticalSection = XAThreadSyncItfImpl_EnterCriticalSection; - self->itf.ExitCriticalSection = XAThreadSyncItfImpl_ExitCriticalSection; + self->itf.EnterCriticalSection + = XAThreadSyncItfImpl_EnterCriticalSection; + self->itf.ExitCriticalSection + = XAThreadSyncItfImpl_ExitCriticalSection; - if( XAImpl_CreateMutex( &(self->engCriticalSection) ) - != XA_RESULT_SUCCESS ) - { + if (XAImpl_CreateMutex(&(self->engCriticalSection)) + != XA_RESULT_SUCCESS) + { DEBUG_ERR("Mutex creation failed, abort"); free(self); DEBUG_API("<-XAThreadSyncItfImpl_Create"); return NULL; - } + } self->self = self; - } + } DEBUG_API("<-XAThreadSyncItfImpl_Create"); return self; -} + } void XAThreadSyncItfImpl_Free(XAThreadSyncItfImpl* self) -{ + { DEBUG_API("->XAThreadSyncItfImpl_Free"); assert(self==self->self); - XAImpl_DeleteMutex(self->engCriticalSection); - free(self); + if(self) + { + XAImpl_DeleteMutex(self->engCriticalSection); + free(self); + } DEBUG_API("<-XAThreadSyncItfImpl_Free"); -} + }