mm_resource_manager_dmn_res_request_s *increases = NULL;
GArray *cb_requests;
- MM_RM_RETVM_IF(manager == NULL,
- MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
+ MM_RM_RETVM_IF(manager == NULL, MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
"Resource manager #%"PRIu64" doesn't exist", _mm_rm_hash64(id));
MM_RM_RETVM_IF(
- (releases == NULL || releases[0].type == MM_RESOURCE_MANAGER_NO_RES)
- && (acquires == NULL || acquires[0].type == MM_RESOURCE_MANAGER_NO_RES),
+ (releases == NULL || releases[0].type == MM_RESOURCE_MANAGER_NO_RES) &&
+ (acquires == NULL || acquires[0].type == MM_RESOURCE_MANAGER_NO_RES),
MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
"Commit request is empty");
ret = __check_release_requests(manager, releases);
- if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
- return ret;
+ MM_RM_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE, ret,
+ "check_release_requests is failed [0x%x]", ret);
+
increases = __create_increase_requests(releases, acquires);
- if (increases == NULL)
- return MM_RESOURCE_MANAGER_ERROR_INVALID_OPERATION;
+ MM_RM_RETVM_IF(increases == NULL, MM_RESOURCE_MANAGER_ERROR_INVALID_OPERATION,
+ "create_increase_requests is failed");
ret = __check_increase_requests(manager, increases);
if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
return MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER;
}
} else {
- for (i = 0; i < manager->resources[type]->parts->len
- && ((mm_resource_manager_res_volume*)manager->resources[type]->parts->data)[i]
+ for (i = 0; i < manager->resources[type]->parts->len &&
+ ((mm_resource_manager_res_volume*)manager->resources[type]->parts->data)[i]
!= requests->volume; i++);
if (i == manager->resources[type]->parts->len) {
MM_RM_ERROR("Part of %s of volume %d is not acquired", type_s, requests->volume);
for (; acquires->type != MM_RESOURCE_MANAGER_NO_RES; acquires++) {
- if ((resources[acquires->type] > 0 || resources[acquires->type] == MM_RESOURCE_MANAGER_RES_VOLUME_FULL)
- && acquires->volume == MM_RESOURCE_MANAGER_RES_VOLUME_FULL) {
+ if ((resources[acquires->type] > 0 || resources[acquires->type] == MM_RESOURCE_MANAGER_RES_VOLUME_FULL) &&
+ acquires->volume == MM_RESOURCE_MANAGER_RES_VOLUME_FULL) {
MM_RM_ERROR("The client tries to acquire %s by part and fully at once",
_mm_resource_manager_get_res_str(acquires->type));
return NULL;
mm_resource_manager_res_volume remaining_volume;
mm_resource_manager_dmn_p i_man;
mm_resource_manager_conf_s *conf = mm_resource_manager_get_conf();
- gboolean resource_conflict = FALSE;
int i, j, len;
mm_resource_manager_res_type_e type = MM_RESOURCE_MANAGER_RES_TYPE_MAX;
MM_RM_RETVM_IF(conf == NULL, MM_RESOURCE_MANAGER_ERROR_NONE, "conf is null");
+ MM_RM_RETVM_IF(manager == NULL, MM_RESOURCE_MANAGER_ERROR_NONE, "manager is null");
MM_RM_RETVM_IF(requests == NULL, MM_RESOURCE_MANAGER_ERROR_NONE, "requests is null");
len = managers->len;
type = requests->type;
const char *type_s = _mm_resource_manager_get_res_str(type);
- MM_RM_RETVM_IF(type < MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER
- || type >= MM_RESOURCE_MANAGER_RES_TYPE_MAX,
+ MM_RM_RETVM_IF(type < MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER ||
+ type >= MM_RESOURCE_MANAGER_RES_TYPE_MAX,
MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
"wrong type %d", type);
MM_RM_RETVM_IF(manager->resources[type] == NULL,
for (i = 0; i < len; i++) {
i_man = (mm_resource_manager_dmn_p)managers->pdata[i];
- if (i_man != manager && conf->priority[i_man->app_class] > conf->priority[manager->app_class]
- && i_man->resources[type]->is_acquired) {
+ if (i_man != manager && conf->priority[i_man->app_class] > conf->priority[manager->app_class] &&
+ i_man->resources[type]->is_acquired) {
if (i_man->resources[type]->parts) {
if (requests->volume == MM_RESOURCE_MANAGER_RES_VOLUME_FULL) {
requests->priority_error = TRUE;
- resource_conflict = TRUE;
MM_RM_DEBUG("Resource conflict. Full volume is requested, but only part is available");
- break;
+ return MM_RESOURCE_MANAGER_ERROR_LOW_PRIORITY;
} else {
for (j = 0; j < i_man->resources[type]->parts->len; j++)
remaining_volume -= g_array_index(i_man->resources[type]->parts,
if (remaining_volume < requests->volume) {
requests->priority_error = TRUE;
- resource_conflict = TRUE;
MM_RM_DEBUG("Resource conflict. %d of %s are available, but %d required",
remaining_volume, type_s, requests->volume);
- break;
+ return MM_RESOURCE_MANAGER_ERROR_LOW_PRIORITY;
}
}
} else {
requests->priority_error = TRUE;
- resource_conflict = TRUE;
MM_RM_DEBUG("Resource conflict. %s is already acquired fully", type_s);
- break;
+ return MM_RESOURCE_MANAGER_ERROR_LOW_PRIORITY;
}
}
}
}
- if (resource_conflict) {
- MM_RM_DEBUG("There is resource conflict");
- return MM_RESOURCE_MANAGER_ERROR_LOW_PRIORITY;
- } else {
- MM_RM_DEBUG("type %d", type);
- return MM_RESOURCE_MANAGER_ERROR_NONE;
- }
+ return MM_RESOURCE_MANAGER_ERROR_NONE;
}
static void __sync_increase_acquire_requests(mm_resource_manager_dmn_res_request_s *increases,
for (i = 0; i < managers->len; i++) {
i_man = (mm_resource_manager_dmn_p)managers->pdata[i];
- if (!i_man->resources[type]->is_acquired
- ||conf->priority[i_man->app_class] >conf->priority[manager->app_class]) {
+ if (!i_man->resources[type]->is_acquired ||
+ conf->priority[i_man->app_class] >conf->priority[manager->app_class]) {
i_man->resources[type]->is_acquired = TRUE;
if (conf->max_instance[type] > 0)
res_count[type]++;
i_man = (mm_resource_manager_dmn_p)managers->pdata[i];
res = i_man->resources[type]->parts;
- if (!i_man->resources[type]->is_acquired || res
- || conf->priority[i_man->app_class] > conf->priority[manager->app_class]) {
+ if (!i_man->resources[type]->is_acquired || res ||
+ conf->priority[i_man->app_class] > conf->priority[manager->app_class]) {
if (conf->volume_would_be_checked[type] && conf->max_volume[type] >= 0 && !res) {
conf->max_volume[type] -= volume;
MM_RM_HASH64(id);
type = request->type;
volume = request->volume;
- MM_RM_DEBUG("Sending release callback to RM #%"PRIu64" for %s of volume %d",
- id, _mm_resource_manager_get_res_str(type), volume);
+ MM_RM_INFO("Sending release callback to [man %p] RM #%"PRIu64" for %s of volume %d",
+ request->manager, id, _mm_resource_manager_get_res_str(type), volume);
+
_mmrm_dmn_dbus_release_callback(id, type, volume);
- if (__wait_for_release_cb_sync(request->manager->id))
+ if (__wait_for_release_cb_sync(id))
MM_RM_DEBUG("Release callback sync success");
else
MM_RM_ERROR("Wait for release callback sync failed");
default:
read_size = read(sync.fd, &recv_id, sizeof(recv_id));
if (read_size == sizeof(recv_id)) {
- ret = id == recv_id;
+ ret = id == _mm_rm_hash64(recv_id);
if (ret == FALSE)
- MM_RM_ERROR("Sync is received from wrong client #%"PRIu64, recv_id);
+ MM_RM_ERROR("Sync is received from wrong client #%"PRIu64, id);
/*
* Wait POLLHUP to avoid situation when client sent last sync
* through the pipe, but not already closed the pipe handle and
__mm_resources_unlock(handle);
if (release_all) {
- if (_mm_resource_manager_mark_all_for_release(handle) == MM_RESOURCE_MANAGER_ERROR_NONE
- && _mm_resource_manager_commit(handle) == MM_RESOURCE_MANAGER_ERROR_NONE) {
+ if (_mm_resource_manager_mark_all_for_release(handle) == MM_RESOURCE_MANAGER_ERROR_NONE &&
+ _mm_resource_manager_commit(handle) == MM_RESOURCE_MANAGER_ERROR_NONE) {
MM_RM_DEBUG("All resources are released after release cb");
} else {
MM_RM_ERROR("Resources cannot be released after release cb");
if (volume > 0) {
for (i = 0; i < rm->resources->len; i++) {
i_res = (mm_resource_manager_res_p) rm->resources->pdata[i];
- if (i_res->type == type && i_res->state != MM_RESOURCE_MANAGER_RES_STATE_FOR_RELEASE
- && (i_res->volume == MM_RESOURCE_MANAGER_RES_VOLUME_FULL
- || (local_volume -= i_res->volume) < volume)) {
+ if (i_res->type == type && i_res->state != MM_RESOURCE_MANAGER_RES_STATE_FOR_RELEASE &&
+ (i_res->volume == MM_RESOURCE_MANAGER_RES_VOLUME_FULL ||
+ (local_volume -= i_res->volume) < volume)) {
MM_RM_ERROR("Requested volume %d exceeds remaining local volume %d",
volume, i_res->volume == MM_RESOURCE_MANAGER_RES_VOLUME_FULL ?
0 : local_volume);
{
mm_resource_manager_s *handle;
mm_resource_manager_id handle_id;
- gboolean unlock = TRUE;
int i;
__mm_resource_handles_lock();
handle = (mm_resource_manager_s*)handles->pdata[i];
handle_id = handle->id;
MM_RM_HASH64(handle_id);
+
if (handle->dbus_proxy == object && handle_id == arg_id) {
__mm_resource_manager_release_callback(handle, arg_id,
arg_resource_type, arg_volume);
- unlock = FALSE;
- break;
+ return;
}
}
- if (unlock)
- __mm_resource_handles_unlock();
+ __mm_resource_handles_unlock();
}
static void __dbus_status_callback(MMResourceManager *object, gint arg_status)
{
mm_resource_manager_s *handle;
- gboolean unlock = TRUE;
int i;
MM_RM_INFO("status callback status %d", arg_status);
__mm_resource_handles_lock();
+
for (i = 0; i < handles->len; i++) {
handle = (mm_resource_manager_s*)handles->pdata[i];
if (handle->dbus_proxy == object) {
__mm_resource_manager_status_callback(handle, arg_status);
- unlock = FALSE;
- break;
+ return;
}
}
- if (unlock)
- __mm_resource_handles_unlock();
+ __mm_resource_handles_unlock();
}
static gpointer __dispatcher_thread(gpointer user_data)