Example #1
0
OMX_ERRORTYPE HantroOmx_msgque_get_size(OMX_IN msgque* q, OMX_OUT OMX_U32* size)
{
    assert(q);
    assert(size);
    
    OMX_ERRORTYPE err = OMX_ErrorNone;
    err = OSAL_MutexLock(q->mutex);
    if (err != OMX_ErrorNone)
        return err;
    
    *size = q->size;
    err = OSAL_MutexUnlock(q->mutex);
    assert(err == OMX_ErrorNone);

    return OMX_ErrorNone;
}
void * Img_EnsQueue::Pop()
{
	void * Elem;
	OSAL_MutexLock(mutex);
	if(head == tail)
	{
		Elem = NULL;
	}
	else
	{
		Elem = queue[tail];
		tail = INCREMENT(tail, size);
	}
	OSAL_MutexUnlock(mutex);
	return Elem;
}
int Img_EnsQueue::Push(void * elem)
{
	int result = 0;
	OSAL_MutexLock(mutex);
	if(INCREMENT(head, size) == tail)
	{	// queue full !!!!
		result = 1;
	}
	else
	{
		queue[head] = elem;
		head        = INCREMENT(head, size);
	}
	OSAL_MutexUnlock(mutex);
	return result;
}
Example #4
0
OMX_ERRORTYPE HantroOmx_msgque_push_back(OMX_IN msgque* q, OMX_IN OMX_PTR ptr)
{ 
    assert(q);
    assert(ptr);
    
    msg_node* tail = (msg_node*)OSAL_Malloc(sizeof(msg_node));
    if(!tail)
        return OMX_ErrorInsufficientResources;
    
    tail->next = q->tail;
    tail->prev = 0;
    tail->data = ptr;
    
    // get mutex now
    OMX_ERRORTYPE err = OMX_ErrorNone;
    err = OSAL_MutexLock(q->mutex);
    if (err != OMX_ErrorNone)
    {
        OSAL_Free(tail);
        return err;
    }

    // first set the signal if needed and once that is allright
    // only then change the queue, cause that cant fail
    
    if (q->size == 0)
    {
        err = OSAL_EventSet(q->event);
        if (err != OMX_ErrorNone)
        {
            OSAL_MutexUnlock(q->mutex);
            return err;
        }
    }
    
    q->size += 1;
    if (q->tail)
        q->tail->prev = tail;
    q->tail  = tail;
    if (!q->head)
        q->head = q->tail;

    err = OSAL_MutexUnlock(q->mutex); 
    assert(err == OMX_ErrorNone);
    return OMX_ErrorNone;
}
Example #5
0
OMX_ERRORTYPE HantroOmx_msgque_get_front(OMX_IN msgque* q, OMX_OUT OMX_PTR* ptr)
{
    assert(q);
    assert(ptr);

    // get mutex now
    OMX_ERRORTYPE err = OMX_ErrorNone;
    err = OSAL_MutexLock(q->mutex);
    if (err != OMX_ErrorNone)
        return err;

    if (q->size - 1 == 0)
    {
        // reset the signal to not set
        err = OSAL_EventReset(q->event);
        if (err != OMX_ErrorNone)
        {
            OSAL_MutexUnlock(q->mutex);
            return err;
        }
    }
    if (q->size == 0)
    {
        assert(q->head == 0);
        assert(q->tail == 0);
        *ptr = 0;
    }
    else
    {
        msg_node* head = q->head;
        assert(head->next == 0);
        *ptr = head->data;
        q->head  = head->prev;
        q->size -= 1;
        if (q->head)
            q->head->next = 0;
        else
            q->tail = 0;

        OSAL_Free(head);
    }
    err =  OSAL_MutexUnlock(q->mutex); assert(err == OMX_ErrorNone);
    return OMX_ErrorNone;
}
Example #6
0
void HantroOmx_msgque_destroy(OMX_IN msgque* q)
{
    assert(q);
    OMX_ERRORTYPE err = OMX_ErrorNone;

    err = OSAL_MutexLock(q->mutex);
    assert(err == OMX_ErrorNone);

    while (q->tail)
    {
        msg_node* next = q->tail->next;
        OSAL_Free(q->tail);
        q->tail = next;
    }

    err = OSAL_MutexUnlock(q->mutex);  assert(err == OMX_ErrorNone);
    err = OSAL_MutexDestroy(q->mutex); assert(err == OMX_ErrorNone);
    err = OSAL_EventDestroy(q->event); assert(err == OMX_ErrorNone);
}
Example #7
0
OMX_ERRORTYPE HantroOmx_port_lock_buffers(PORT* p)
{
    assert(p);
    return OSAL_MutexLock(p->buffermutex);
}
void Img_EnsQueue::Reset()
{ /** Reset all entries */
	OSAL_MutexLock(mutex);
	head = tail = 0;
	OSAL_MutexUnlock(mutex);
}