예제 #1
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;
}
예제 #2
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;
}
예제 #3
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;
}
예제 #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);
}
예제 #7
0
OMX_ERRORTYPE HantroOmx_port_unlock_buffers(PORT* p)
{
    assert(p);
    return OSAL_MutexUnlock(p->buffermutex);
}
void Img_EnsQueue::Reset()
{ /** Reset all entries */
	OSAL_MutexLock(mutex);
	head = tail = 0;
	OSAL_MutexUnlock(mutex);
}