mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-27 01:28:34 +00:00
Fix enum serialization, deserialization, comparison in caps, add a test to ensure that this continues working in the ...
Original commit message from CVS: * configure.ac: * gst/gstvalue.c: (gst_value_compare_enum), (gst_value_serialize_enum), (gst_value_deserialize_enum), (gst_value_can_compare), (gst_value_compare): * testsuite/Makefile.am: Fix enum serialization, deserialization, comparison in caps, add a test to ensure that this continues working in the future.
This commit is contained in:
parent
1c8590f341
commit
938884918c
5 changed files with 36 additions and 14 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2004-07-07 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
|
* configure.ac:
|
||||||
|
* gst/gstvalue.c: (gst_value_compare_enum),
|
||||||
|
(gst_value_serialize_enum), (gst_value_deserialize_enum),
|
||||||
|
(gst_value_can_compare), (gst_value_compare):
|
||||||
|
* testsuite/Makefile.am:
|
||||||
|
Fix enum serialization, deserialization, comparison in caps, add
|
||||||
|
a test to ensure that this continues working in the future.
|
||||||
|
|
||||||
2004-07-06 David Schleef <ds@schleef.org>
|
2004-07-06 David Schleef <ds@schleef.org>
|
||||||
|
|
||||||
* gst/gstcaps.c: (gst_caps_save_thyself), (gst_caps_load_thyself):
|
* gst/gstcaps.c: (gst_caps_save_thyself), (gst_caps_load_thyself):
|
||||||
|
|
|
@ -670,6 +670,7 @@ testsuite/debug/Makefile
|
||||||
testsuite/dlopen/Makefile
|
testsuite/dlopen/Makefile
|
||||||
testsuite/dynparams/Makefile
|
testsuite/dynparams/Makefile
|
||||||
testsuite/elements/Makefile
|
testsuite/elements/Makefile
|
||||||
|
testsuite/enumcaps/Makefile
|
||||||
testsuite/ghostpads/Makefile
|
testsuite/ghostpads/Makefile
|
||||||
testsuite/indexers/Makefile
|
testsuite/indexers/Makefile
|
||||||
testsuite/negotiation/Makefile
|
testsuite/negotiation/Makefile
|
||||||
|
|
|
@ -1290,13 +1290,15 @@ static int
|
||||||
gst_value_compare_enum (const GValue * value1, const GValue * value2)
|
gst_value_compare_enum (const GValue * value1, const GValue * value2)
|
||||||
{
|
{
|
||||||
GEnumValue *en1, *en2;
|
GEnumValue *en1, *en2;
|
||||||
GEnumClass *klass1 = (GEnumClass *) g_type_class_peek (G_VALUE_TYPE (value1));
|
GEnumClass *klass1 = (GEnumClass *) g_type_class_ref (G_VALUE_TYPE (value1));
|
||||||
GEnumClass *klass2 = (GEnumClass *) g_type_class_peek (G_VALUE_TYPE (value2));
|
GEnumClass *klass2 = (GEnumClass *) g_type_class_ref (G_VALUE_TYPE (value2));
|
||||||
|
|
||||||
g_return_val_if_fail (klass1, GST_VALUE_UNORDERED);
|
g_return_val_if_fail (klass1, GST_VALUE_UNORDERED);
|
||||||
g_return_val_if_fail (klass2, GST_VALUE_UNORDERED);
|
g_return_val_if_fail (klass2, GST_VALUE_UNORDERED);
|
||||||
en1 = g_enum_get_value (klass1, g_value_get_enum (value1));
|
en1 = g_enum_get_value (klass1, g_value_get_enum (value1));
|
||||||
en2 = g_enum_get_value (klass2, g_value_get_enum (value2));
|
en2 = g_enum_get_value (klass2, g_value_get_enum (value2));
|
||||||
|
g_type_class_unref (klass1);
|
||||||
|
g_type_class_unref (klass2);
|
||||||
g_return_val_if_fail (en1, GST_VALUE_UNORDERED);
|
g_return_val_if_fail (en1, GST_VALUE_UNORDERED);
|
||||||
g_return_val_if_fail (en2, GST_VALUE_UNORDERED);
|
g_return_val_if_fail (en2, GST_VALUE_UNORDERED);
|
||||||
if (en1->value < en2->value)
|
if (en1->value < en2->value)
|
||||||
|
@ -1311,10 +1313,11 @@ static char *
|
||||||
gst_value_serialize_enum (const GValue * value)
|
gst_value_serialize_enum (const GValue * value)
|
||||||
{
|
{
|
||||||
GEnumValue *en;
|
GEnumValue *en;
|
||||||
GEnumClass *klass = (GEnumClass *) g_type_class_peek (G_VALUE_TYPE (value));
|
GEnumClass *klass = (GEnumClass *) g_type_class_ref (G_VALUE_TYPE (value));
|
||||||
|
|
||||||
g_return_val_if_fail (klass, NULL);
|
g_return_val_if_fail (klass, NULL);
|
||||||
en = g_enum_get_value (klass, g_value_get_enum (value));
|
en = g_enum_get_value (klass, g_value_get_enum (value));
|
||||||
|
g_type_class_unref (klass);
|
||||||
g_return_val_if_fail (en, NULL);
|
g_return_val_if_fail (en, NULL);
|
||||||
return g_strdup (en->value_name);
|
return g_strdup (en->value_name);
|
||||||
}
|
}
|
||||||
|
@ -1324,7 +1327,7 @@ gst_value_deserialize_enum (GValue * dest, const char *s)
|
||||||
{
|
{
|
||||||
GEnumValue *en;
|
GEnumValue *en;
|
||||||
gchar *endptr = NULL;
|
gchar *endptr = NULL;
|
||||||
GEnumClass *klass = (GEnumClass *) g_type_class_peek (G_VALUE_TYPE (dest));
|
GEnumClass *klass = (GEnumClass *) g_type_class_ref (G_VALUE_TYPE (dest));
|
||||||
|
|
||||||
g_return_val_if_fail (klass, FALSE);
|
g_return_val_if_fail (klass, FALSE);
|
||||||
if (!(en = g_enum_get_value_by_name (klass, s))) {
|
if (!(en = g_enum_get_value_by_name (klass, s))) {
|
||||||
|
@ -1336,6 +1339,7 @@ gst_value_deserialize_enum (GValue * dest, const char *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_type_class_unref (klass);
|
||||||
g_return_val_if_fail (en, FALSE);
|
g_return_val_if_fail (en, FALSE);
|
||||||
g_value_set_enum (dest, en->value);
|
g_value_set_enum (dest, en->value);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1781,7 +1785,7 @@ gst_value_can_compare (const GValue * value1, const GValue * value2)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for (i = 0; i < gst_value_table->len; i++) {
|
for (i = 0; i < gst_value_table->len; i++) {
|
||||||
table = &g_array_index (gst_value_table, GstValueTable, i);
|
table = &g_array_index (gst_value_table, GstValueTable, i);
|
||||||
if (table->type == G_VALUE_TYPE (value1) && table->compare)
|
if (g_type_is_a (G_VALUE_TYPE (value1), table->type) && table->compare)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1804,7 +1808,7 @@ gst_value_can_compare (const GValue * value1, const GValue * value2)
|
||||||
int
|
int
|
||||||
gst_value_compare (const GValue * value1, const GValue * value2)
|
gst_value_compare (const GValue * value1, const GValue * value2)
|
||||||
{
|
{
|
||||||
GstValueTable *table;
|
GstValueTable *table, *best = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
|
if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
|
||||||
|
@ -1812,10 +1816,17 @@ gst_value_compare (const GValue * value1, const GValue * value2)
|
||||||
|
|
||||||
for (i = 0; i < gst_value_table->len; i++) {
|
for (i = 0; i < gst_value_table->len; i++) {
|
||||||
table = &g_array_index (gst_value_table, GstValueTable, i);
|
table = &g_array_index (gst_value_table, GstValueTable, i);
|
||||||
if (table->type != G_VALUE_TYPE (value1) || table->compare == NULL)
|
if (table->type == G_VALUE_TYPE (value1) && table->compare != NULL) {
|
||||||
continue;
|
best = table;
|
||||||
|
break;
|
||||||
return table->compare (value1, value2);
|
}
|
||||||
|
if (g_type_is_a (G_VALUE_TYPE (value1), table->type)) {
|
||||||
|
if (!best || g_type_is_a (table->type, best->type))
|
||||||
|
best = table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (best) {
|
||||||
|
return best->compare (value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_critical ("unable to compare values of type %s\n",
|
g_critical ("unable to compare values of type %s\n",
|
||||||
|
|
|
@ -17,7 +17,7 @@ SUBDIRS = \
|
||||||
bins bytestream caps cleanup clock \
|
bins bytestream caps cleanup clock \
|
||||||
$(GST_DEBUG_DIRS) \
|
$(GST_DEBUG_DIRS) \
|
||||||
dlopen dynparams \
|
dlopen dynparams \
|
||||||
elements ghostpads indexers negotiation \
|
elements enumcaps ghostpads indexers negotiation \
|
||||||
$(GST_PARSE_DIRS) \
|
$(GST_PARSE_DIRS) \
|
||||||
plugin refcounting schedulers tags threads
|
plugin refcounting schedulers tags threads
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ DIST_SUBDIRS = \
|
||||||
bins bytestream caps cleanup clock \
|
bins bytestream caps cleanup clock \
|
||||||
debug \
|
debug \
|
||||||
dlopen dynparams \
|
dlopen dynparams \
|
||||||
elements ghostpads indexers negotiation \
|
elements enumcaps ghostpads indexers negotiation \
|
||||||
parse \
|
parse \
|
||||||
plugin refcounting schedulers tags threads
|
plugin refcounting schedulers tags threads
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ SUBDIRS = \
|
||||||
bins bytestream caps cleanup clock \
|
bins bytestream caps cleanup clock \
|
||||||
$(GST_DEBUG_DIRS) \
|
$(GST_DEBUG_DIRS) \
|
||||||
dlopen dynparams \
|
dlopen dynparams \
|
||||||
elements ghostpads indexers negotiation \
|
elements enumcaps ghostpads indexers negotiation \
|
||||||
$(GST_PARSE_DIRS) \
|
$(GST_PARSE_DIRS) \
|
||||||
plugin refcounting schedulers tags threads
|
plugin refcounting schedulers tags threads
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ DIST_SUBDIRS = \
|
||||||
bins bytestream caps cleanup clock \
|
bins bytestream caps cleanup clock \
|
||||||
debug \
|
debug \
|
||||||
dlopen dynparams \
|
dlopen dynparams \
|
||||||
elements ghostpads indexers negotiation \
|
elements enumcaps ghostpads indexers negotiation \
|
||||||
parse \
|
parse \
|
||||||
plugin refcounting schedulers tags threads
|
plugin refcounting schedulers tags threads
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue