resource-c: fix a bug with the autorelease flag handling.
authorIsmo Puustinen <ismo.puustinen@intel.com>
Fri, 14 Jun 2013 08:34:20 +0000 (11:34 +0300)
committerIsmo Puustinen <ismo.puustinen@intel.com>
Fri, 14 Jun 2013 08:34:20 +0000 (11:34 +0300)
src/plugins/resource-native/libmurphy-resource/api_test.c
src/plugins/resource-native/libmurphy-resource/message.c
src/plugins/resource-native/libmurphy-resource/rset.c

index b029dd4..9c20331 100644 (file)
@@ -74,6 +74,11 @@ void acquire_resources(my_app_data *app_data)
         return;
     }
 
+    if (!mrp_res_set_autorelease(app_data->cx, TRUE, app_data->rs)) {
+        printf("Could not set autorelease flag!\n");
+        return;
+    }
+
     resource = mrp_res_create_resource(app_data->cx,
                       app_data->rs,
                       "audio_playback",
index 15129aa..e542f70 100644 (file)
@@ -510,7 +510,7 @@ int create_resource_set_request(mrp_res_context_t *cx,
 {
     mrp_msg_t *msg = NULL;
     uint32_t i;
-    uint32_t flags = 0;
+    uint32_t rset_flags = 0;
 
     if (!cx || !rset)
         return -1;
@@ -519,13 +519,13 @@ int create_resource_set_request(mrp_res_context_t *cx,
         return -1;
 
     if (rset->priv->autorelease)
-        flags |= RESPROTO_RSETFLAG_AUTORELEASE;
+        rset_flags |= RESPROTO_RSETFLAG_AUTORELEASE;
 
     msg = mrp_msg_create(
             RESPROTO_SEQUENCE_NO, MRP_MSG_FIELD_UINT32, cx->priv->next_seqno,
             RESPROTO_REQUEST_TYPE, MRP_MSG_FIELD_UINT16,
                     RESPROTO_CREATE_RESOURCE_SET,
-            RESPROTO_RESOURCE_FLAGS, MRP_MSG_FIELD_UINT32, flags,
+            RESPROTO_RESOURCE_FLAGS, MRP_MSG_FIELD_UINT32, rset_flags,
             RESPROTO_RESOURCE_PRIORITY, MRP_MSG_FIELD_UINT32, 0,
             RESPROTO_CLASS_NAME, MRP_MSG_FIELD_STRING, rset->application_class,
             RESPROTO_ZONE_NAME, MRP_MSG_FIELD_STRING, cx->zone,
@@ -539,22 +539,22 @@ int create_resource_set_request(mrp_res_context_t *cx,
 
     for (i = 0; i < rset->priv->num_resources; i++) {
         int j;
-        uint32_t flags = 0;
+        uint32_t res_flags = 0;
         mrp_res_resource_t *res = rset->priv->resources[i];
 
         if (!res)
             goto error;
 
         if (res->priv->shared)
-            flags |= RESPROTO_RESFLAG_SHARED;
+            res_flags |= RESPROTO_RESFLAG_SHARED;
 
         if (res->priv->mandatory)
-            flags |= RESPROTO_RESFLAG_MANDATORY;
+            res_flags |= RESPROTO_RESFLAG_MANDATORY;
 
         mrp_msg_append(msg, RESPROTO_RESOURCE_NAME, MRP_MSG_FIELD_STRING,
                 res->name);
         mrp_msg_append(msg, RESPROTO_RESOURCE_FLAGS, MRP_MSG_FIELD_UINT32,
-                flags);
+                res_flags);
 
         for (j = 0; j < res->priv->num_attributes; j++) {
             mrp_res_attribute_t *elem = &res->priv->attrs[j];
index bbf8628..104e5f6 100644 (file)
@@ -398,17 +398,22 @@ static int update_library_resource_set(mrp_res_context_t *cx,
      * can be many. */
 
      application_class = mrp_strdup(original->application_class);
-     if (!application_class)
+     if (!application_class) {
+        mrp_log_error("error with memory allocation");
         goto error;
+    }
 
      resources = mrp_allocz_array(mrp_res_resource_t *,
             original->priv->num_resources);
-     if (!resources)
+     if (!resources) {
+        mrp_log_error("error allocating %d resources", original->priv->num_resources);
         goto error;
+    }
 
     for (i = 0; i < original->priv->num_resources; i++) {
         resources[i] = resource_copy(original->priv->resources[i], rset);
         if (!resources[i]) {
+            mrp_log_error("error copying resources to library resource set");
             goto error;
         }
         num_resources++;
@@ -423,6 +428,7 @@ static int update_library_resource_set(mrp_res_context_t *cx,
     rset->application_class = application_class;
     rset->priv->resources = resources;
     rset->priv->num_resources = num_resources;
+    rset->priv->autorelease = original->priv->autorelease;
 
     return 0;