3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * @file Exynos_OSAL_Mutex.c
21 * @author SeungBeom Kim (sbcrux.kim@samsung.com)
32 #include "Exynos_OSAL_Memory.h"
33 #include "Exynos_OSAL_Mutex.h"
35 OMX_ERRORTYPE Exynos_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle)
37 pthread_mutex_t *mutex;
39 mutex = (pthread_mutex_t *)Exynos_OSAL_Malloc(sizeof(pthread_mutex_t));
41 return OMX_ErrorInsufficientResources;
43 if (pthread_mutex_init(mutex, NULL) != 0) {
44 Exynos_OSAL_Free(mutex);
45 return OMX_ErrorUndefined;
48 *mutexHandle = (OMX_HANDLETYPE)mutex;
52 OMX_ERRORTYPE Exynos_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle)
54 pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
57 return OMX_ErrorBadParameter;
59 if (pthread_mutex_destroy(mutex) != 0)
60 return OMX_ErrorUndefined;
62 Exynos_OSAL_Free(mutex);
66 OMX_ERRORTYPE Exynos_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle)
68 pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
71 return OMX_ErrorBadParameter;
73 if (pthread_mutex_lock(mutex) != 0)
74 return OMX_ErrorUndefined;
79 OMX_ERRORTYPE Exynos_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle)
81 pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
84 return OMX_ErrorBadParameter;
86 if (pthread_mutex_unlock(mutex) != 0)
87 return OMX_ErrorUndefined;