Esempio n. 1
0
t_bool cm_unregisterSingletonBinding(
        t_component_instance*                   component,
        t_interface_require_description*        itfRequire,
        t_interface_provide_description*        itfProvide,
        t_nmf_client_id                         clientId)
{
    if(component->Template->classe == SINGLETON)
    {
        struct t_client_of_singleton* cl = cm_getClientOfSingleton(component, FALSE, clientId);
        if(cl != NULL)
            cl->numberOfBind--;

        if(itfProvide->server == (t_component_instance *)NMF_VOID_COMPONENT)
            LOG_INTERNAL(1, "  -> Singleton[%d] : Unregister binding %s/%x.%s -> ARM/VOID\n",
                    clientId,
                    itfRequire->client->pathname, itfRequire->client, itfRequire->origName, 0, 0);
        else if(itfProvide->server == NULL)
            LOG_INTERNAL(1, "  -> Singleton[%d] : Unregister binding %s/%x.%s -> ?? <already unbound>\n",
                    clientId,
                    itfRequire->client->pathname, itfRequire->client, itfRequire->origName, 0, 0);
        else
            LOG_INTERNAL(1, "  -> Singleton[%d] : Unregister binding %s/%x.%s -> %s/%x\n",
                    clientId,
                    itfRequire->client->pathname, itfRequire->client, itfRequire->origName,
                    itfProvide->server->pathname, itfProvide->server);

        if(getNumberOfBind(component) == 0)
        {
            LOG_INTERNAL(1, "  -> Singleton[%d] : All required of %s/%x logically unbound, perform physical unbind\n",
                    clientId, itfRequire->client->pathname, itfRequire->client, 0, 0, 0);

            (void)cm_EEM_ForceWakeup(component->Template->dspId);

            // This is the last binding unbind all !!!
            cm_destroyRequireInterface(component, clientId);

            cm_EEM_AllowSleep(component->Template->dspId);
        }
        else if(itfProvide->server != NULL)
        {
            t_interface_require* itfReq;
            itfReq = &itfRequire->client->Template->requires[itfRequire->requireIndex];
            if((itfReq->requireTypes & OPTIONAL_REQUIRE) != 0x0)
                return TRUE;
        }

        return FALSE;
    }

    return TRUE;
}
Esempio n. 2
0
void cm_registerSingletonBinding(
        t_component_instance*                   component,
        t_interface_require_description*        itfRequire,
        t_interface_provide_description*        itfProvide,
        t_nmf_client_id                         clientId)
{
    if(component->Template->classe == SINGLETON)
    {
        struct t_client_of_singleton* cl = cm_getClientOfSingleton(component, FALSE, clientId);
        if(cl != NULL)
            cl->numberOfBind++;

        if(itfProvide != NULL)
            LOG_INTERNAL(1, "  -> Singleton[%d] : Register binding %s/%x.%s -> %s/%x\n",
                    clientId,
                    itfRequire->client->pathname, itfRequire->client, itfRequire->origName,
                    itfProvide->server->pathname, itfProvide->server);
        else
            LOG_INTERNAL(1, "  -> Singleton[%d] : Register binding %s/%x.%s -> ARM/VOID\n",
                    clientId,
                    itfRequire->client->pathname, itfRequire->client, itfRequire->origName, 0, 0);
    }
}
PUBLIC EXPORT_SHARED t_cm_error CM_ENGINE_FlushComponents(t_nmf_client_id clientId)
{
    t_cm_error error = CM_OK;
    t_component_instance *instance;
    t_uint32 i;

    if (clientId == 0)
    	return CM_INVALID_PARAMETER;

    OSAL_LOCK_API();

    // We don't know exactly where components will be, wake up everybody !!
    (void)cm_EEM_ForceWakeup(SVA_CORE_ID);
    (void)cm_EEM_ForceWakeup(SIA_CORE_ID);

    /* Destroy all host2mpc bindings */
    OSAL_LOCK_COM();
    for (i=0; i<Host2MpcBindingTable.idxMax; i++)
    {
	    t_host2mpc_bf_info* bfInfo;
	    bfInfo = Host2MpcBindingTable.entries[i];
	    if ((bfInfo != NULL) && (bfInfo->clientId == clientId)) {
		    cm_delEntry(&Host2MpcBindingTable, i);
		    OSAL_UNLOCK_COM();
		    cm_unbindComponentFromCMCore(bfInfo);
                    OSAL_LOCK_COM();
	    }
    }
    OSAL_UNLOCK_COM();

    /* First, stop all remaining components for this client */
    for (i=0; i<ComponentTable.idxMax; i++)
    {
	if ((instance = componentEntry(i)) == NULL)
		continue;
        if (/* skip EE */
                (instance->Template->classe == FIRMWARE) ||
                /* Skip all binding components */
                (cm_StringCompare(instance->Template->name, "_ev.", 4) == 0) ||
                (cm_StringCompare(instance->Template->name, "_st.", 4) == 0) ||
                (cm_StringCompare(instance->Template->name, "_sk.", 4) == 0) ||
                (cm_StringCompare(instance->Template->name, "_tr.", 4) == 0))
            continue;

        /*
         * Special code for SINGLETON handling
         */
        if(instance->Template->classe == SINGLETON)
        {
            struct t_client_of_singleton* cl = cm_getClientOfSingleton(instance, FALSE, clientId);
            if(cl == NULL)
                continue;

            cl->numberOfStart = 1; // == 1 since it will go to 0 in cm_stopComponent
            cl->numberOfInstance = 1; // == 1 since it will go to 0 in cm_destroyInstanceForClient
            cl->numberOfBind = 0; // == 0 since we don't want anymore binding for this component
        }
        else if(domainDesc[instance->domainId].client != clientId)
            /* Skip all components not belonging to our client */
            continue;

        // Stop the component
        error = cm_stopComponent(instance, clientId);
        if (error != CM_OK && error != CM_COMPONENT_NOT_STARTED)
            LOG_INTERNAL(0, "Error stopping component %s/%x (%s, error=%d, client=%u)\n", instance->pathname, instance, instance->Template->name, error, clientId, 0);

        // Destroy dependencies
        cm_destroyRequireInterface(instance, clientId);
    }

    /* Destroy all remaining components for this client */
    for (i=0; i<ComponentTable.idxMax; i++)
    {
	if ((instance = componentEntry(i)) == NULL)
		continue;
        if (/* skip EE */
                (instance->Template->classe == FIRMWARE) ||
                /* Skip all binding components */
                (cm_StringCompare(instance->Template->name, "_ev.", 4) == 0) ||
                (cm_StringCompare(instance->Template->name, "_st.", 4) == 0) ||
                (cm_StringCompare(instance->Template->name, "_sk.", 4) == 0) ||
                (cm_StringCompare(instance->Template->name, "_tr.", 4) == 0)) {
		continue;
        }


       /*
        * Special code for SINGLETON handling
        */
       if(instance->Template->classe == SINGLETON)
       {
           struct t_client_of_singleton* cl = cm_getClientOfSingleton(instance, FALSE, clientId);
           if(cl == NULL)
               continue;
       }
       else if(domainDesc[instance->domainId].client != clientId)
           /* Skip all components not belonging to our client */
           continue;


        // Destroy the component
        error = cm_destroyInstanceForClient(instance, DESTROY_WITHOUT_CHECK, clientId);

        if (error != CM_OK)
        {
            /* FIXME : add component name instance in log message but need to make a copy before cm_flushComponent()
             *         because it's no more available after.
             */
            LOG_INTERNAL(0, "Error flushing component (error=%d, client=%u)\n", error, clientId, 0, 0, 0, 0);
        }
    }

    cm_CFG_ReleaseMpc(SVA_CORE_ID);
    cm_CFG_ReleaseMpc(SIA_CORE_ID);

    cm_EEM_AllowSleep(SVA_CORE_ID);
    cm_EEM_AllowSleep(SIA_CORE_ID);

    OSAL_UNLOCK_API();

    return error;
}