Beispiel #1
0
/*
 *  ======== WMD_MSG_Create ========
 *      Create an object to manage message queues. Only one of these objects
 *      can exist per device object.
 */
DSP_STATUS WMD_MSG_Create(OUT struct MSG_MGR **phMsgMgr,
                          struct DEV_OBJECT *hDevObject, MSG_ONEXIT msgCallback)
{
    struct MSG_MGR *pMsgMgr;
    struct IO_MGR *hIOMgr;
    DSP_STATUS status = DSP_SOK;

    if (!phMsgMgr || !msgCallback || !hDevObject) {
        status = DSP_EPOINTER;
        goto func_end;
    }
    DEV_GetIOMgr(hDevObject, &hIOMgr);
    if (!hIOMgr) {
        status = DSP_EPOINTER;
        goto func_end;
    }
    *phMsgMgr = NULL;
    /* Allocate MSG manager object */
    MEM_AllocObject(pMsgMgr, struct MSG_MGR, MSGMGR_SIGNATURE);

    if (pMsgMgr) {
        pMsgMgr->onExit = msgCallback;
        pMsgMgr->hIOMgr = hIOMgr;
        /* List of MSG_QUEUEs */
        pMsgMgr->queueList = LST_Create();
        /*  Queues of message frames for messages to the DSP. Message
         * frames will only be added to the free queue when a
         * MSG_QUEUE object is created.  */
        pMsgMgr->msgFreeList = LST_Create();
        pMsgMgr->msgUsedList = LST_Create();
        if (pMsgMgr->queueList == NULL ||
                pMsgMgr->msgFreeList == NULL ||
                pMsgMgr->msgUsedList == NULL)
            status = DSP_EMEMORY;
        if (DSP_SUCCEEDED(status))
            status = SYNC_InitializeDPCCS(&pMsgMgr->hSyncCS);

        /*  Create an event to be used by WMD_MSG_Put() in waiting
        *  for an available free frame from the message manager.  */
        if (DSP_SUCCEEDED(status))
            status = SYNC_OpenEvent(&pMsgMgr->hSyncEvent, NULL);

        if (DSP_SUCCEEDED(status))
            *phMsgMgr = pMsgMgr;
        else
            DeleteMsgMgr(pMsgMgr);

    } else {
        status = DSP_EMEMORY;
    }
func_end:
    return status;
}
Beispiel #2
0
/*
 *  ======== WMD_MSG_Delete ========
 *      Delete a MSG manager allocated in WMD_MSG_Create().
 */
void WMD_MSG_Delete(struct MSG_MGR *hMsgMgr)
{
	DBC_Require(MEM_IsValidHandle(hMsgMgr, MSGMGR_SIGNATURE));

	DeleteMsgMgr(hMsgMgr);
}
Beispiel #3
0
/*
 *  ======== WMD_MSG_Delete ========
 *      Delete a MSG manager allocated in WMD_MSG_Create().
 */
void WMD_MSG_Delete(struct MSG_MGR *hMsgMgr)
{
    if (MEM_IsValidHandle(hMsgMgr, MSGMGR_SIGNATURE))
        DeleteMsgMgr(hMsgMgr);
}