Esempio n. 1
0
bool create_preload_list(void)
{
    ComponentHandlePtr component_handle;
    int index;
    bool ret = true;

    for (index=0;omx_components[index][0];index++) {
        struct list *entry;
        component_handle = (ComponentHandlePtr) malloc(sizeof(ComponentHandle));

        strncpy(component_handle->comp_name, omx_components[index][0], OMX_MAX_STRINGNAME_SIZE);
        component_handle->comp_handle = NULL;
        component_handle->parser_handle = NULL;

        /* skip libraries starting with # */
        if (component_handle->comp_name[0] == '#')
           continue;

        entry = list_alloc(component_handle);
        if (!entry) {
           ret=false;
           goto unload_comphandle;
        }
        preload_list = __list_add_tail(preload_list, entry);

        omx_infoLog("Added component %s to list", component_handle->comp_name);
        continue;

unload_comphandle:
        dlclose(component_handle->comp_handle);
    }
    return ret;
}
Esempio n. 2
0
static struct list *construct_components(void)
{
    struct list *head = NULL, *preload_entry;
    ComponentHandlePtr component_handle;

    /* In Chromium OS, the OMX IL Client will call preload_components()
     * so that the preload_list is already populated. In non-chrome case,
     * we need to create the list here */
    if (!preload_list) {
       if (!create_preload_list()) {
          omx_verboseLog("error: Preload list cannot be populated");
       }
    }

    list_foreach(preload_list, preload_entry) {
        CModule *cmodule;
        struct list *entry;
        OMX_ERRORTYPE ret;

        component_handle = (ComponentHandlePtr) preload_entry->data;

        /* skip libraries starting with # */
        if (component_handle->comp_name[0] == '#')
            continue;

        cmodule = new CModule(component_handle->comp_name);
        if (!cmodule)
            continue;

        omx_verboseLog("found component library %s", component_handle->comp_name);

        ret = cmodule->Load(MODULE_NOW, component_handle->comp_handle);
        if (ret != OMX_ErrorNone)
            goto delete_cmodule;

        ret = cmodule->SetParser(component_handle->parser_handle);
        if (ret != OMX_ErrorNone)
            goto delete_cmodule;

        ret = cmodule->QueryComponentNameAndRoles();
        if (ret != OMX_ErrorNone)
            goto unload_cmodule;

        entry = list_alloc(cmodule);
        if (!entry)
            goto unload_cmodule;
        head = __list_add_tail(head, entry);

        omx_verboseLog("module %s:%s added to component list",
             cmodule->GetLibraryName(), cmodule->GetComponentName());

        continue;

    unload_cmodule:
        cmodule->Unload();
    delete_cmodule:
        delete cmodule;
    }
Esempio n. 3
0
extern "C" bool preload_components(void)
{
    /* this function is called by openMAX-IL client when libraries are to be
     * loaded at initial stages.  Security features of the operating system require
     * to load libraries upfront */
    ComponentHandlePtr component_handle;
    int index;
    bool ret = true;

    for (index=0;omx_components[index][0];index++) {
        struct list *entry;
        component_handle = (ComponentHandlePtr) malloc(sizeof(ComponentHandle));

        strncpy(component_handle->comp_name, omx_components[index][0], OMX_MAX_STRINGNAME_SIZE);
        /* parser is not always needed */
        if (omx_components[index][1])
            strncpy(component_handle->parser_name, omx_components[index][1], OMX_MAX_STRINGNAME_SIZE);

        /* skip libraries starting with # */
        if (component_handle->comp_name[0] == '#')
            continue;

        component_handle->comp_handle = dlopen(component_handle->comp_name, RTLD_NOW);
        if (!component_handle->comp_handle) {
            ret=false;
            goto delete_comphandle;
        }


        if (component_handle->parser_name) {
            /* some components don't need a parser */
            component_handle->parser_handle = dlopen(component_handle->parser_name, RTLD_NOW);
            if (!component_handle->parser_handle) {
                ret=false;
                goto delete_comphandle;
            }
        }

        entry = list_alloc(component_handle);
        if (!entry) {
            ret=false;
            goto unload_comphandle;
        }
        preload_list = __list_add_tail(preload_list, entry);

	omx_infoLog("open component %s and parser %s", component_handle->comp_name,
			component_handle->parser_name == NULL ?
			"No parser provided":component_handle->parser_name );
	continue;

unload_comphandle:
        dlclose(component_handle->comp_handle);
delete_comphandle:
        free(component_handle);
    }
    return ret;
}
Esempio n. 4
0
int queue_push_tail(struct queue *queue, void *data)
{
	struct list *entry = list_alloc(data);

	if (!entry)
		return -1;
	else
		queue->tail = __list_add_tail(queue->tail, entry);

	if (queue->tail->next)
		queue->tail = queue->tail->next;
	else
		queue->head = queue->tail;

	queue->length++;
        return 0;
}
static struct list *construct_components(const char *config_file_name)
{
    FILE *config_file;
    char library_name[OMX_MAX_STRINGNAME_SIZE];
    char config_file_path[256];
    struct list *head = NULL;

    strncpy(config_file_path, "/etc/", 256);
    strncat(config_file_path, config_file_name, 256);
    config_file = fopen(config_file_path, "r");
    if (!config_file) {
        strncpy(config_file_path, "./", 256);
        strncat(config_file_path, config_file_name, 256);
        config_file = fopen(config_file_path, "r");
        if (!config_file) {
            ALOGE("not found file %s\n", config_file_name);
            return NULL;
        }
    }

    while (fscanf(config_file, "%s", library_name) > 0) {
        CModule *cmodule;
        struct list *entry;
        OMX_ERRORTYPE ret;

        library_name[OMX_MAX_STRINGNAME_SIZE-1] = '\0';

        /* skip libraries starting with # */
        if (library_name[0] == '#')
            continue;

        cmodule = new CModule(&library_name[0]);
        if (!cmodule)
            continue;

        ALOGI("found component library %s\n", library_name);

        ret = cmodule->Load(MODULE_LAZY);
        if (ret != OMX_ErrorNone)
            goto delete_cmodule;

        ret = cmodule->QueryComponentNameAndRoles();
        if (ret != OMX_ErrorNone)
            goto unload_cmodule;

        entry = list_alloc(cmodule);
        if (!entry)
            goto unload_cmodule;
        head = __list_add_tail(head, entry);

        cmodule->Unload();
        ALOGI("module %s:%s added to component list\n",
             cmodule->GetLibraryName(), cmodule->GetComponentName());

        continue;

    unload_cmodule:
        cmodule->Unload();
    delete_cmodule:
        delete cmodule;
    }

    fclose(config_file);
    return head;
}