led_len = json_object_array_length(frame_data_obj);
ani_info->frames[frame_id - 1].num_led = led_len;
+ if (ani_info->max_leds < led_len) ani_info->max_leds = led_len;
ani_info->frames[frame_id - 1].leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), led_len);
ERROR_CHECK(ani_info->frames[frame_id - 1].leds, goto error, "Failed to alloc for default_led_info_t\n");
_ani_info_cleanup(ani_info);
}
+default_frame_info_t *
+backend_util_alloc_frame(default_ani_info *ani_info)
+{
+ default_frame_info_t *frame;
+
+ frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
+ ERROR_CHECK(frame, return NULL, "Failed to allocate memory for frame\n");
+
+ frame->leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), ani_info->max_leds);
+ ERROR_CHECK(frame->leds, goto error, "Failed to allocate memory for led\n");
+
+ frame->num_led = ani_info->max_leds;
+
+ return frame;
+
+error:
+ free(frame);
+ return NULL;
+}
+
+void
+backend_util_cleanup_frame(default_frame_info_t *frame)
+{
+ ERROR_CHECK(frame, return, "Invalid frame to cleanup\n");
+
+ for (int i = 0; i < frame->num_led; i++)
+ {
+ frame->leds[i].color = 0x0;
+ }
+ frame->frame_duration = 0;
+}
+
+void
+backend_util_free_frame(default_frame_info_t *frame)
+{
+ if (!frame) return;
+
+ if (frame->leds) free(frame->leds);
+ free(frame);
+}
+
+
static pui_backend_module_data *
pui_default_backend_init(void)
{