static BtPersistence * bt_wave_persistence_load (const GType type, const BtPersistence * const persistence, xmlNodePtr node, GError ** err, va_list var_args) { BtWave *self; BtPersistence *result; BtSongIONative *song_io; gchar *uri = NULL; GST_DEBUG ("PERSISTENCE::wave"); g_assert (node); xmlChar *const index_str = xmlGetProp (node, XML_CHAR_PTR ("index")); const gulong index = index_str ? atol ((char *) index_str) : 0; xmlChar *const name = xmlGetProp (node, XML_CHAR_PTR ("name")); xmlChar *const uri_str = xmlGetProp (node, XML_CHAR_PTR ("uri")); xmlChar *const volume_str = xmlGetProp (node, XML_CHAR_PTR ("volume")); const gdouble volume = volume_str ? g_ascii_strtod ((char *) volume_str, NULL) : 0.0; xmlChar *const loop_mode_str = xmlGetProp (node, XML_CHAR_PTR ("loop-mode")); gint loop_mode = bt_str_parse_enum (BT_TYPE_WAVE_LOOP_MODE, (char *) loop_mode_str); if (loop_mode == -1) loop_mode = BT_WAVE_LOOP_MODE_OFF; if (!persistence) { BtSong *song = NULL; gchar *param_name; // we need to get parameters from var_args (need to handle all baseclass params param_name = va_arg (var_args, gchar *); while (param_name) { if (!strcmp (param_name, "song")) { song = va_arg (var_args, gpointer); } else { GST_WARNING ("unhandled argument: %s", param_name); break; } param_name = va_arg (var_args, gchar *); } /* TODO(ensonic): ugly hack, don't pass uri_str yet, this would trigger loading * which we do below (see also: bt_wave_constructed) */ self = bt_wave_new (song, (gchar *) name, NULL, index, volume, loop_mode, 0); result = BT_PERSISTENCE (self); g_object_set (self, "uri", uri_str, NULL); } else {
static void test_bt_str_parse_enum (BT_TEST_ARGS) { BT_TEST_START; GST_INFO ("-- arrange --"); GST_INFO ("-- act --"); gint v = bt_str_parse_enum (BT_TYPE_MACHINE_STATE, "normal"); GST_INFO ("-- assert --"); ck_assert_int_eq (v, BT_MACHINE_STATE_NORMAL); GST_INFO ("-- cleanup --"); BT_TEST_END; }