Esempio n. 1
0
static void
write_metadata (GstWavEnc * wavenc)
{
  GString *info_str;
  GList *props;
  int total = 4;
  gboolean need_to_write = FALSE;

  info_str = g_string_new ("LIST    INFO");

  for (props = wavenc->metadata->properties->properties; props;
      props = props->next) {
    GstPropsEntry *entry = props->data;
    const char *name;
    guint32 id;

    name = gst_props_entry_get_name (entry);
    id = get_id_from_name (name);
    if (id != 0) {
      const char *text;
      char *tmp;
      int len, req, i;

      need_to_write = TRUE;     /* We've got at least one entry */

      gst_props_entry_get_string (entry, &text);
      len = strlen (text) + 1;  /* The length in the file includes the \0 */

      tmp = g_strdup_printf ("%" GST_FOURCC_FORMAT "%d%s", GST_FOURCC_ARGS (id),
          GUINT32_TO_LE (len), text);
      g_string_append (info_str, tmp);
      g_free (tmp);

      /* Check that we end on an even boundary */
      req = ((len + 8) + 1) & ~1;
      for (i = 0; i < req - len; i++) {
        g_string_append_printf (info_str, "%c", 0);
      }

      total += req;
    }
  }

  if (need_to_write) {
    GstBuffer *buf;

    /* Now we've got all the strings together, we can write our length in */
    info_str->str[4] = GUINT32_TO_LE (total);

    buf = gst_buffer_new ();
    gst_buffer_set_data (buf, info_str->str, info_str->len);

    gst_pad_push (wavenc->srcpad, GST_DATA (buf));
    g_string_free (info_str, FALSE);
  }
}
Esempio n. 2
0
uint8 get_command_id(char* cmd_name)
{
    return get_id_from_name(cmd_name, commands, NELEMENTS(commands));
}
Esempio n. 3
0
uint8 get_state_id(char* state_name)
{
    return get_id_from_name(state_name, states, NELEMENTS(states));
}
Esempio n. 4
0
uint8 get_move_id(char* move_name)
{
    return get_id_from_name(move_name, moves, NELEMENTS(moves));
}
Esempio n. 5
0
uint8 get_turn_id(char* turn_name)
{
    return get_id_from_name(turn_name, turns, NELEMENTS(turns));
}
static gboolean property_changed(DBusConnection *conn,
					DBusMessage *msg, void *user_data)
{
	struct accounts_data *accounts = user_data;
	const char *iface;
	DBusMessageIter iter, dict, inv_it;

	dbus_message_iter_init(msg, &iter);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) {
		ofono_error("%s: iface != TYPE_STRING!", __func__);
		goto done;
	}

	dbus_message_iter_get_basic(&iter, &iface);

	/* We can receive notifications from other AccountsService interfaces */
	if (g_str_equal(iface, ACCOUNTS_PHONE_INTERFACE) != TRUE)
		goto done;

	if (!dbus_message_iter_next(&iter)) {
		ofono_error("%s: advance iter failed!", __func__);
		goto done;
	}

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
		ofono_error("%s: type != ARRAY!", __func__);
		goto done;
	}

	dbus_message_iter_recurse(&iter, &dict);

	while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
		DBusMessageIter entry, val;
		const char *key, *str_val;
		int id;

		dbus_message_iter_recurse(&dict, &entry);

		if (dbus_message_iter_get_arg_type(&entry) !=
				DBUS_TYPE_STRING) {
			ofono_error("%s: key type != STRING!", __func__);
			goto done;
		}

		dbus_message_iter_get_basic(&entry, &key);

		dbus_message_iter_next(&entry);

		if (dbus_message_iter_get_arg_type(&entry) !=
				DBUS_TYPE_VARIANT) {
			ofono_error("%s: val != VARIANT", __func__);
			goto done;
		}

		dbus_message_iter_recurse(&entry, &val);

		if (dbus_message_iter_get_arg_type(&val) != DBUS_TYPE_STRING) {
			ofono_error("%s: *val != STRING", __func__);
			goto done;
		}

		dbus_message_iter_get_basic(&val, &str_val);

		DBG("property %s changed to %s", key, PRINTABLE_STR(str_val));

		id = get_id_from_name(key);
		if (id >= 0)
			accounts->property_values[id] = g_strdup(str_val);

		dbus_message_iter_next(&dict);
	}

	/* Check invalidated properties */
	if (!dbus_message_iter_next(&iter)) {
		ofono_error("%s: advance iter failed!", __func__);
		goto done;
	}

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
		ofono_error("%s: type != ARRAY!", __func__);
		goto done;
	}

	dbus_message_iter_recurse(&iter, &inv_it);

	while (dbus_message_iter_get_arg_type(&inv_it) == DBUS_TYPE_STRING) {
		const char *inv_name;
		int id;

		dbus_message_iter_get_basic(&inv_it, &inv_name);

		DBG("property %s invalidated", inv_name);

		id = get_id_from_name(inv_name);
		if (id >= 0)
			get_property(accounts, id);

		dbus_message_iter_next(&inv_it);
	}

done:
	return TRUE;
}