Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM] Change to the common resource manager #567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (get_option('enable-tizen'))

nns_capi_deps += dependency('mm-camcorder')
if (tizenVmajor >= 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (tizenVmajor >= 5)
if (tizenVmajor >= 9)

nns_capi_deps += dependency('mm-resource-manager')
nns_capi_deps += dependency('resource-manager resource-center-api')
endif
endif

Expand Down
12 changes: 1 addition & 11 deletions c/src/ml-api-inference-pipeline-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ extern "C" {
#elif (TIZENVERSION < 5)
#define get_tizen_resource(...) (0)
#define release_tizen_resource(...) do { } while (0)
typedef void * mm_resource_manager_h;
typedef enum { MM_RESOURCE_MANAGER_RES_TYPE_MAX } mm_resource_manager_res_type_e;

#else /* TIZENVERSION */
#error Tizen version is not defined.
Expand Down Expand Up @@ -108,14 +106,6 @@ typedef struct {
void *user_data; /**< The user data passed when calling the state change callback */
} pipeline_state_cb_s;

/**
* @brief Internal data structure for the resource.
*/
typedef struct {
gchar *type; /**< resource type */
gpointer handle; /**< pointer to resource handle */
} pipeline_resource_s;

/**
* @brief Internal private representation of pipeline handle.
* @details This should not be exposed to applications
Expand All @@ -128,7 +118,7 @@ typedef struct _ml_pipeline {
gboolean isEOS; /**< The pipeline is EOS state */
ml_pipeline_state_e pipe_state; /**< The state of pipeline */
GHashTable *namednodes; /**< hash table of "element"s. */
GHashTable *resources; /**< hash table of resources to construct the pipeline */
gpointer resources; /**< The resources pointer to construct the pipeline */
GHashTable *pipe_elm_type; /**< hash table for type of pipeline element */
pipeline_state_cb_s state_cb; /**< Callback to notify the change of pipeline state */
} ml_pipeline;
Expand Down
43 changes: 1 addition & 42 deletions c/src/ml-api-inference-pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,23 +593,6 @@ cleanup_node (gpointer data)
g_free (e);
}

/**
* @brief Private function to release the pipeline resources
*/
static void
cleanup_resource (gpointer data)
{
pipeline_resource_s *res = data;

/* check resource type and free data */
if (g_str_has_prefix (res->type, "tizen")) {
release_tizen_resource (res->handle, res->type);
}

g_free (res->type);
g_free (res);
}

/**
* @brief Converts predefined element in pipeline description.
*/
Expand Down Expand Up @@ -951,8 +934,6 @@ create_internal_hash (ml_pipeline * pipe_h)
{
pipe_h->namednodes =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, cleanup_node);
pipe_h->resources =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, cleanup_resource);

pipe_h->pipe_elm_type =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
Expand Down Expand Up @@ -1147,9 +1128,8 @@ ml_pipeline_destroy (ml_pipeline_h pipe)

/* Destroy registered callback handles and resources */
g_hash_table_destroy (p->namednodes);
g_hash_table_destroy (p->resources);
g_hash_table_destroy (p->pipe_elm_type);
p->namednodes = p->resources = p->pipe_elm_type = NULL;
p->namednodes = p->pipe_elm_type = NULL;

if (p->element) {
/* Pause the pipeline if it's playing */
Expand Down Expand Up @@ -1254,34 +1234,13 @@ ml_pipeline_start (ml_pipeline_h pipe)

g_mutex_lock (&p->lock);

/* check the resources when starting the pipeline */
if (g_hash_table_size (p->resources)) {
GHashTableIter iter;
gpointer key, value;

/* iterate all handle and acquire res if released */
g_hash_table_iter_init (&iter, p->resources);
while (g_hash_table_iter_next (&iter, &key, &value)) {
if (g_str_has_prefix (key, "tizen")) {
status = get_tizen_resource (pipe, key);
if (status != ML_ERROR_NONE) {
_ml_error_report_continue
("Internal API _ml_tizen_get_resource () has failed: Tizen mm resource manager has failed to acquire the resource of '%s'",
(gchar *) key);
goto done;
}
}
}
}

scret = gst_element_set_state (p->element, GST_STATE_PLAYING);
if (scret == GST_STATE_CHANGE_FAILURE) {
_ml_error_report
("Failed to set the state of the pipeline to PLAYING. For the detail, please check the GStreamer log messages.");
status = ML_ERROR_STREAMS_PIPE;
}

done:
g_mutex_unlock (&p->lock);
return status;
}
Expand Down
Loading
Loading