output_info->mm_height = 0;
}
+static eom_output_id *
+_eom_get_eom_output_ids(int *count)
+{
+ GArray *ret_array = NULL;
+ eom_output_id *output_ids = NULL;
+ int i;
+
+ ret_array = eom_wayland_client_get_output_ids();
+
+ if (!ret_array)
+ return NULL;
+
+ if (ret_array->len == 0)
+ goto done;
+
+ output_ids = calloc(ret_array->len, sizeof(eom_output_id));
+ if (output_ids == NULL) {
+ ERR("alloc fail");
+ goto done;
+ }
+
+ *count = ret_array->len;
+ for (i = 0; i < ret_array->len; i++) {
+ GValue *v = &g_array_index(ret_array, GValue, i);
+
+ output_ids[i] = g_value_get_int(v);
+ INFO("output_ids: %d", output_ids[i]);
+ }
+
+ return output_ids;
+
+done:
+ g_array_free(ret_array, FALSE);
+ return NULL;
+}
+
+static void
+_eom_update_output_info_list()
+{
+ GArray *ret_array = NULL;
+ eom_output_id *output_ids = NULL;
+ int i, count;
+
+ output_ids = _eom_get_eom_output_ids(&count);
+ RET_IF_FAIL(output_ids != NULL);
+
+ /* TODO: redesign the life-cycle of output_infos */
+ for (i = 0; i < count; i++) {
+ /* add output_info to output_info_list */
+ eom_output_info *output_info;
+ eom_output_id output_id = output_ids[i];
+
+ output_info = _eom_find_output_info(output_id);
+ if (output_info)
+ continue;
+
+ ret_array = eom_wayland_client_get_output_info(output_id);
+ if (ret_array) {
+ /*
+ * 0:output_id, 1:output_type, 2:output_mode,
+ * 3:w, 4:h, 5:w_mm, 6:h_mm, 7:attribute
+ */
+ output_info = _eom_alloc_output_info(
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 0)),
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 1)));
+ if (output_info) {
+ output_info_list = g_list_append(
+ output_info_list, output_info);
+ _eom_set_output_info_mode(output_info,
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 2)));
+ _eom_set_output_info_size(output_info,
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 3)),
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 4)));
+ _eom_set_output_info_phy_size(output_info,
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 5)),
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 6)));
+ _eom_set_output_attribute(output_info,
+ g_value_get_int(&g_array_index(
+ ret_array, GValue, 7)));
+ INFO("GetOutputInfo: %s(%d)",
+ TYPE(output_info->type),
+ output_info->id);
+ }
+
+ g_array_free(ret_array, FALSE);
+ ret_array = NULL;
+ } else
+ ERR("fail: get id(%d)'s information", output_id);
+ }
+
+ free(output_ids);
+}
+
static void
_eom_output_call_notify_cb(eom_output_notify_s *notify)
{
_eom_mutex_lock();
output_info = _eom_find_output_info(output_id);
- GOTO_IF_FAIL(output_info != NULL, exit);
+ if (output_info == NULL) {
+ if (notify_type == EOM_OUTPUT_NOTIFY_ADD) {
+ _eom_update_output_info_list();
+ output_info = _eom_find_output_info(output_id);
+ }
+
+ GOTO_IF_FAIL(output_info != NULL, exit);
+ }
switch (notify_type) {
case EOM_OUTPUT_NOTIFY_ADD:
API eom_output_id*
eom_get_eom_output_ids(int *count)
{
- GArray *ret_array = NULL;
eom_output_id *output_ids = NULL;
- int i;
if (!count) {
set_last_result(EOM_ERROR_INVALID_PARAMETER);
_eom_mutex_lock();
- ret_array = eom_wayland_client_get_output_ids();
-
- if (!ret_array) {
- *count = 0;
- _eom_mutex_unlock();
- set_last_result(EOM_ERROR_NONE);
- return NULL;
- }
-/*LCOV_EXCL_START*/
- if (ret_array->len == 0) {
- g_array_free(ret_array, FALSE);
- *count = 0;
- _eom_mutex_unlock();
- set_last_result(EOM_ERROR_NONE);
- return NULL;
- }
-
- output_ids = calloc(ret_array->len, sizeof(eom_output_id));
- GOTO_IF_FAIL(output_ids != NULL, fail);
-
- *count = ret_array->len;
- for (i = 0; i < ret_array->len; i++) {
- GValue *v = &g_array_index(ret_array, GValue, i);
-
- output_ids[i] = g_value_get_int(v);
- INFO("output_ids: %d", output_ids[i]);
- }
-
- g_array_free(ret_array, FALSE);
- ret_array = NULL;
-
- /* TODO: redesign the life-cycle of output_infos */
- for (i = 0; i < *count; i++) {
- /* add output_info to output_info_list */
- eom_output_info *output_info;
- eom_output_id output_id = output_ids[i];
-
- output_info = _eom_find_output_info(output_id);
- if (output_info)
- continue;
-
- ret_array = eom_wayland_client_get_output_info(output_id);
- if (ret_array) {
- /*
- * 0:output_id, 1:output_type, 2:output_mode,
- * 3:w, 4:h, 5:w_mm, 6:h_mm, 7:attribute
- */
- output_info = _eom_alloc_output_info(
- g_value_get_int(&g_array_index(
- ret_array, GValue, 0)),
- g_value_get_int(&g_array_index(
- ret_array, GValue, 1)));
- if (output_info) {
- output_info_list = g_list_append(
- output_info_list, output_info);
- _eom_set_output_info_mode(output_info,
- g_value_get_int(&g_array_index(
- ret_array, GValue, 2)));
- _eom_set_output_info_size(output_info,
- g_value_get_int(&g_array_index(
- ret_array, GValue, 3)),
- g_value_get_int(&g_array_index(
- ret_array, GValue, 4)));
- _eom_set_output_info_phy_size(output_info,
- g_value_get_int(&g_array_index(
- ret_array, GValue, 5)),
- g_value_get_int(&g_array_index(
- ret_array, GValue, 6)));
- _eom_set_output_attribute(output_info,
- g_value_get_int(&g_array_index(
- ret_array, GValue, 7)));
- INFO("GetOutputInfo: %s(%d)",
- TYPE(output_info->type),
- output_info->id);
- }
-
- g_array_free(ret_array, FALSE);
- ret_array = NULL;
- } else
- ERR("fail: get id(%d)'s information", output_id);
- }
+ output_ids = _eom_get_eom_output_ids(count);
+ _eom_update_output_info_list();
_eom_mutex_unlock();
set_last_result(EOM_ERROR_NONE);
return output_ids;
-
-fail:
- if (ret_array)
- g_array_free(ret_array, FALSE);
-
- *count = 0;
-
- _eom_mutex_unlock();
-
- set_last_result(EOM_ERROR_OUT_OF_MEMORY);
-
- return NULL;
-/*LCOV_EXCL_STOP*/
}
API int