Exemple #1
0
static xmlNodePtr
bt_wave_persistence_save (const BtPersistence * const persistence,
    const xmlNodePtr const parent_node)
{
  const BtWave *const self = BT_WAVE (persistence);
  xmlNodePtr node = NULL;
  xmlNodePtr child_node;

  GST_DEBUG ("PERSISTENCE::wave");

  if ((node = xmlNewChild (parent_node, NULL, XML_CHAR_PTR ("wave"), NULL))) {
    BtSongIONative *song_io;

    // we need to have a uri
    if (!self->priv->uri)
      self->priv->uri = g_strdup (self->priv->name);

    xmlNewProp (node, XML_CHAR_PTR ("index"),
        XML_CHAR_PTR (bt_str_format_ulong (self->priv->index)));
    xmlNewProp (node, XML_CHAR_PTR ("name"), XML_CHAR_PTR (self->priv->name));
    xmlNewProp (node, XML_CHAR_PTR ("uri"), XML_CHAR_PTR (self->priv->uri));
    xmlNewProp (node, XML_CHAR_PTR ("volume"),
        XML_CHAR_PTR (bt_str_format_double (self->priv->volume)));
    xmlNewProp (node, XML_CHAR_PTR ("loop-mode"),
        XML_CHAR_PTR (bt_str_format_enum (BT_TYPE_WAVE_LOOP_MODE,
                self->priv->loop_mode)));

    // check if we need to save external data
    g_object_get (self->priv->song, "song-io", &song_io, NULL);
    if (song_io) {
      if (BT_IS_SONG_IO_NATIVE_BZT (song_io)) {
        gchar *uri = NULL;

        if (self->priv->ext_fd == -1) {
          // need to write in memory data to a wav
          bt_wave_save_to_fd (self);
        }
        uri = g_strdup_printf ("fd://%d", self->priv->ext_fd);
        bt_wave_save_from_fd (self, song_io, uri);
        g_free (uri);
      }
      g_object_unref (song_io);
    }
    // save wavelevels
    if ((child_node =
            xmlNewChild (node, NULL, XML_CHAR_PTR ("wavelevels"), NULL))) {
      bt_persistence_save_list (self->priv->wavelevels, child_node);
    }
  }
  return node;
}
Exemple #2
0
static xmlNodePtr
bt_wavetable_persistence_save (const BtPersistence * const persistence,
    xmlNodePtr const parent_node)
{
  const BtWavetable *const self = BT_WAVETABLE (persistence);
  xmlNodePtr node = NULL;

  GST_DEBUG ("PERSISTENCE::wavetable");

  if ((node =
          xmlNewChild (parent_node, NULL, XML_CHAR_PTR ("wavetable"), NULL))) {
    bt_persistence_save_list (self->priv->waves, node);
  }
  return node;
}