From 63c01eeacb6c61ae35f025d3e5ce1e390217e253 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 21 Mar 2008 15:52:14 +0000 Subject: [PATCH] gst/gstregistrybinary.*: Don't use GST_MAJORMINOR for the binary registry version. Instead hardcode a value that must... Original commit message from CVS: * gst/gstregistrybinary.c: (gst_registry_binary_initialize_magic), (gst_registry_binary_check_magic), (gst_registry_binary_read_cache): * gst/gstregistrybinary.h: Don't use GST_MAJORMINOR for the binary registry version. Instead hardcode a value that must be changed whenever the format changes in an incompatible way. Also don't GST_ERROR when there is a version mismatch, just regenerate the registry silently. --- ChangeLog | 12 ++++++++++++ common | 2 +- gst/gstregistrybinary.c | 33 ++++++++++++++++++++------------- gst/gstregistrybinary.h | 14 ++++++++++++++ 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf3105a..b5d5254 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-03-21 Sebastian Dröge + + * gst/gstregistrybinary.c: (gst_registry_binary_initialize_magic), + (gst_registry_binary_check_magic), + (gst_registry_binary_read_cache): + * gst/gstregistrybinary.h: + Don't use GST_MAJORMINOR for the binary registry version. Instead + hardcode a value that must be changed whenever the format changes + in an incompatible way. + Also don't GST_ERROR when there is a version mismatch, just + regenerate the registry silently. + 2008-03-21 Jan Schmidt * configure.ac: diff --git a/common b/common index 170f8e9..9a358e5 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 170f8e91adc7157f6e708ffa58ca22d10e4e45da +Subproject commit 9a358e5cc3977fd6121f12dd25a358081fd77041 diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index 676de23..bb8b6ee 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -145,7 +145,8 @@ gst_registry_binary_initialize_magic (GstBinaryRegistryMagic * m) { if (!strncpy (m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) - || !strncpy (m->version, GST_MAJORMINOR, GST_MAGIC_BINARY_VERSION_LEN)) { + || !strncpy (m->version, GST_MAGIC_BINARY_VERSION_STRING, + GST_MAGIC_BINARY_VERSION_LEN)) { GST_ERROR ("Failed to write magic to the registry magic structure"); return FALSE; } @@ -596,9 +597,11 @@ rename_failed: * gst_registry_binary_check_magic: * * Check GstBinaryRegistryMagic validity. - * Return FALSE if something is wrong + * Return < 0 if something is wrong, -2 means + * that just the version of the registry is out of + * date, -1 is a general failure. */ -static gboolean +static gint gst_registry_binary_check_magic (gchar ** in) { GstBinaryRegistryMagic *m; @@ -609,7 +612,7 @@ gst_registry_binary_check_magic (gchar ** in) if (m == NULL || m->magic == NULL || m->version == NULL) { GST_WARNING ("Binary registry magic structure is broken"); - return FALSE; + return -1; } if (strncmp (m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0) { @@ -620,14 +623,15 @@ gst_registry_binary_check_magic (gchar ** in) GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff, m->magic[0] & 0xff, m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff); - return FALSE; + return -1; } - if (strncmp (m->version, GST_MAJORMINOR, GST_MAGIC_BINARY_VERSION_LEN)) { + if (strncmp (m->version, GST_MAGIC_BINARY_VERSION_STRING, + GST_MAGIC_BINARY_VERSION_LEN)) { GST_WARNING ("Binary registry magic version is different : %s != %s", - GST_MAJORMINOR, m->version); - return FALSE; + GST_MAGIC_BINARY_VERSION_STRING, m->version); + return -2; } - return TRUE; + return 0; } @@ -898,6 +902,7 @@ gst_registry_binary_read_cache (GstRegistry * registry, const char *location) gsize size; GError *err = NULL; gboolean res = FALSE; + gint check_magic_result; /* make sure these types exist */ GST_TYPE_ELEMENT_FACTORY; @@ -937,10 +942,12 @@ gst_registry_binary_read_cache (GstRegistry * registry, const char *location) goto Error; } /* check if header is valid */ - if (!gst_registry_binary_check_magic (&in)) { - GST_ERROR - ("Binary registry type not recognized (invalid magic) for file at %s", - location); + if ((check_magic_result = gst_registry_binary_check_magic (&in)) < 0) { + + if (check_magic_result == -1) + GST_ERROR + ("Binary registry type not recognized (invalid magic) for file at %s", + location); goto Error; } diff --git a/gst/gstregistrybinary.h b/gst/gstregistrybinary.h index 5bee537..6b30877 100644 --- a/gst/gstregistrybinary.h +++ b/gst/gstregistrybinary.h @@ -33,6 +33,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + /* * GST_MAGIC_BINARY_REGISTRY_STR: * @@ -45,6 +49,16 @@ * length of the header tag. */ #define GST_MAGIC_BINARY_REGISTRY_LEN (4) + +/* + * GST_MAGIC_BINARY_VERSION_STRING: + * + * The current version of the binary registry format. + * This _must_ be updated whenever the registry format changes, + * we currently use the core version where this change happened. + */ +#define GST_MAGIC_BINARY_VERSION_STRING ("0.10.18") + /* * GST_MAGIC_BINARY_VERSION_LEN: * -- 2.7.4