+2008-03-21 Sebastian Dröge <slomo@circular-chaos.org>
+
+ * 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 <jan.schmidt@sun.com>
* configure.ac:
{
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;
}
* 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;
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) {
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;
}
gsize size;
GError *err = NULL;
gboolean res = FALSE;
+ gint check_magic_result;
/* make sure these types exist */
GST_TYPE_ELEMENT_FACTORY;
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;
}
#include <gst/gstpad.h>
#include <gst/gstregistry.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
/*
* GST_MAGIC_BINARY_REGISTRY_STR:
*
* 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:
*