brasero r938 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r938 - in trunk: . src
- Date: Tue, 1 Jul 2008 10:13:33 +0000 (UTC)
Author: philippr
Date: Tue Jul 1 10:13:33 2008
New Revision: 938
URL: http://svn.gnome.org/viewvc/brasero?rev=938&view=rev
Log:
Fix #540993 â Brasero displays (and uses) incorrect track durations
* src/brasero-audio-disc.c (brasero_audio_disc_reset_real),
(brasero_audio_disc_add_uri_real),
(brasero_audio_disc_inotify_modify_result),
(brasero_audio_disc_inotify_move),
(brasero_audio_disc_inotify_monitor_cb):
* src/brasero-io.c (brasero_io_metadata_lookup_buffer),
(brasero_io_metadata_cached_free), (brasero_io_get_metadata_info),
(brasero_io_get_file_info_thread_real), (brasero_io_finalize):
* src/brasero-metadata.h:
Modified:
trunk/ChangeLog
trunk/src/brasero-audio-disc.c
trunk/src/brasero-io.c
trunk/src/brasero-metadata.h
Modified: trunk/src/brasero-audio-disc.c
==============================================================================
--- trunk/src/brasero-audio-disc.c (original)
+++ trunk/src/brasero-audio-disc.c Tue Jul 1 10:13:33 2008
@@ -265,6 +265,8 @@
#ifdef BUILD_INOTIFY
+ BraseroIOJobBase *reload_uri;
+
int notify_id;
GIOChannel *notify;
GHashTable *monitored;
@@ -834,6 +836,9 @@
disc->priv->monitored = NULL;
}
+ if (disc->priv->reload_uri && disc->priv->io)
+ brasero_io_cancel_by_base (disc->priv->io, disc->priv->reload_uri);
+
#endif
disc->priv->sectors = 0;
@@ -1786,6 +1791,7 @@
disc->priv->add_uri,
BRASERO_IO_INFO_PERM|
BRASERO_IO_INFO_MIME|
+ BRASERO_IO_INFO_URGENT|
BRASERO_IO_INFO_METADATA|
BRASERO_IO_INFO_METADATA_MISSING_CODEC,
ref);
@@ -3785,26 +3791,20 @@
}
static void
-brasero_audio_disc_inotify_modify (BraseroAudioDisc *disc,
- const gchar *uri,
- BraseroMetadataInfo *metadata)
+brasero_audio_disc_inotify_modify_result (GObject *object,
+ GError *error,
+ const gchar *uri,
+ GFileInfo *info,
+ gpointer callback_data)
{
+ BraseroAudioDisc *disc = BRASERO_AUDIO_DISC (object);
GSList *list, *list_iter;
GtkTreeModel *model;
- GFileInfo *info;
list = brasero_audio_disc_inotify_find_rows (disc, uri);
if (!list)
return;
- info = g_file_info_new ();
- g_file_info_set_attribute_uint64 (info, BRASERO_IO_LEN, metadata->len);
- g_file_info_set_attribute_string (info, BRASERO_IO_ARTIST, metadata->artist);
- g_file_info_set_attribute_string (info, BRASERO_IO_TITLE, metadata->title);
- g_file_info_set_attribute_int32 (info, BRASERO_IO_ISRC, metadata->isrc);
- g_file_info_set_attribute_string (info, BRASERO_IO_COMPOSER, metadata->composer);
- g_file_info_set_attribute_boolean (info, BRASERO_IO_HAS_AUDIO, metadata->has_audio);
-
model = gtk_tree_view_get_model (GTK_TREE_VIEW (disc->priv->tree));
for (list_iter = list; list_iter; list_iter = list_iter->next) {
GtkTreePath *treepath;
@@ -3813,14 +3813,14 @@
treepath = list_iter->data;
gtk_tree_model_get_iter (model, &iter, treepath);
- brasero_audio_disc_set_row_from_metadata (disc,
- model,
- &iter,
- info);
+ if (error)
+ brasero_audio_disc_remove (disc, treepath);
+ else
+ brasero_audio_disc_set_row_from_metadata (disc,
+ model,
+ &iter,
+ info);
}
-
- g_object_unref (info);
-
g_slist_foreach (list, (GFunc) gtk_tree_path_free, NULL);
g_slist_free (list);
}
@@ -3876,57 +3876,40 @@
data = iter->data;
if (data->cookie == event->cookie)
break;
+
+ data = NULL;
}
if (data) {
- GSList *paths, *list_iter;
- GtkTreeModel *model;
- gchar *old_name;
- gchar *new_name;
+ GSList *paths;
/* we've got one match:
* - remove from the list
* - remove the timeout
* - change all the uris with the new one */
- disc->priv->moved_list = g_slist_remove (disc->priv->moved_list,
- data);
-
+ disc->priv->moved_list = g_slist_remove (disc->priv->moved_list, data);
paths = brasero_audio_disc_inotify_find_rows (disc, data->uri);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (disc->priv->tree));
- old_name = g_path_get_basename (data->uri);
- new_name = g_path_get_basename (uri);
+ /* we are only interested if the destination is in our tree
+ * then that means the file was modified */
+ if (!disc->priv->io)
+ disc->priv->io = brasero_io_get_default ();
+
+ if (!disc->priv->reload_uri)
+ disc->priv->reload_uri = brasero_io_register (G_OBJECT (disc),
+ brasero_audio_disc_inotify_modify_result,
+ NULL,
+ NULL);
- for (list_iter = paths; list_iter; list_iter = list_iter->next) {
- GtkTreePath *treepath;
- GtkTreeIter iter;
- gchar *name;
-
- treepath = list_iter->data;
- gtk_tree_model_get_iter (model, &iter, treepath);
- gtk_tree_model_get (model, &iter,
- NAME_COL, &name,
- -1);
-
- /* see if the user changed the name or if it is
- * displaying song name metadata. Basically if
- * the name is the same as the old one we change
- * it to the new one. */
- if (!strcmp (name, old_name)) {
- gchar *markup;
-
- markup = g_markup_escape_text (new_name, -1);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- NAME_COL, markup,
- -1);
- g_free (markup);
- }
- g_free (name);
-
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- URI_COL, uri,
- -1);
- }
+ brasero_io_get_file_info (disc->priv->io,
+ uri,
+ disc->priv->reload_uri,
+ BRASERO_IO_INFO_PERM|
+ BRASERO_IO_INFO_MIME|
+ BRASERO_IO_INFO_URGENT|
+ BRASERO_IO_INFO_METADATA|
+ BRASERO_IO_INFO_METADATA_MISSING_CODEC,
+ NULL);
/* clean up the mess */
g_slist_foreach (paths, (GFunc) gtk_tree_path_free, NULL);
@@ -3935,9 +3918,6 @@
g_source_remove (data->id);
g_free (data->uri);
g_free (data);
-
- g_free (old_name);
- g_free (new_name);
}
}
}
@@ -4077,7 +4057,11 @@
}
if (dir->uri && name) {
+ gchar *escaped_name;
+
+ escaped_name = g_uri_escape_string (name, NULL, TRUE);
monitored = g_strconcat (dir->uri, "/", name, NULL);
+ g_free (escaped_name);
g_free (name);
}
else
@@ -4110,33 +4094,25 @@
brasero_audio_disc_inotify_attributes_changed (disc, monitored);
}
else if (event.mask & IN_MODIFY
- && brasero_audio_disc_inotify_is_in_selection (disc, monitored)) {
- BraseroMetadata *metadata;
- BraseroMetadataInfo info;
- GError *error = NULL;
-
- /* a file was modified */
- metadata = brasero_metadata_new ();
-
- if (!metadata
- || !brasero_metadata_get_info_sync (metadata, monitored, BRASERO_METADATA_FLAG_NONE, &error)) {
- if (error) {
- g_warning ("ERROR : %s\n", error->message);
- g_error_free (error);
- g_object_unref (metadata);
- }
-
- brasero_audio_disc_inotify_remove (disc, monitored);
- continue;
- }
-
- /* FIXME: we should remove the row if it hasn't audio */
- brasero_metadata_set_info (metadata, &info);
- brasero_audio_disc_inotify_modify (disc,
- monitored,
- &info);
- brasero_metadata_info_clear (&info);
- g_object_unref (metadata);
+ && brasero_audio_disc_inotify_is_in_selection (disc, monitored)) {
+ if (!disc->priv->io)
+ disc->priv->io = brasero_io_get_default ();
+
+ if (!disc->priv->reload_uri)
+ disc->priv->reload_uri = brasero_io_register (G_OBJECT (disc),
+ brasero_audio_disc_inotify_modify_result,
+ NULL,
+ NULL);
+
+ brasero_io_get_file_info (disc->priv->io,
+ monitored,
+ disc->priv->reload_uri,
+ BRASERO_IO_INFO_PERM|
+ BRASERO_IO_INFO_MIME|
+ BRASERO_IO_INFO_URGENT|
+ BRASERO_IO_INFO_METADATA|
+ BRASERO_IO_INFO_METADATA_MISSING_CODEC,
+ NULL);
}
if (monitored) {
Modified: trunk/src/brasero-io.c
==============================================================================
--- trunk/src/brasero-io.c (original)
+++ trunk/src/brasero-io.c Tue Jul 1 10:13:33 2008
@@ -41,6 +41,7 @@
#endif
#include "burn-basics.h"
+#include "burn-debug.h"
#include "brasero-utils.h"
#include "brasero-io.h"
@@ -579,13 +580,26 @@
};
typedef struct _BraseroIOMetadataTask BraseroIOMetadataTask;
+struct _BraseroIOMetadataCached {
+ guint64 last_modified;
+ BraseroMetadataInfo *info;
+};
+typedef struct _BraseroIOMetadataCached BraseroIOMetadataCached;
+
static gint
brasero_io_metadata_lookup_buffer (gconstpointer a, gconstpointer b)
{
- const BraseroMetadataInfo *metadata = a;
+ const BraseroIOMetadataCached *cached = a;
const gchar *uri = b;
- return strcmp (uri, metadata->uri);
+ return strcmp (uri, cached->info->uri);
+}
+
+static void
+brasero_io_metadata_cached_free (BraseroIOMetadataCached *cached)
+{
+ brasero_metadata_info_free (cached->info);
+ g_free (cached);
}
static void
@@ -642,13 +656,23 @@
|| !strcmp (mime, "application/octet-stream")))
return FALSE;
- /* seek in the buffer if we have already explored these metadata */
+ /* Seek in the buffer if we have already explored these metadata. Check
+ * the info last modified time in case a result should be updated. */
node = g_queue_find_custom (priv->meta_buffer,
uri,
brasero_io_metadata_lookup_buffer);
if (node) {
- brasero_metadata_info_copy (meta_info, node->data);
- return TRUE;
+ guint64 last_modified;
+ BraseroIOMetadataCached *cached;
+
+ cached = node->data;
+ last_modified = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
+ if (last_modified == cached->last_modified) {
+ brasero_metadata_info_copy (meta_info, cached->info);
+ return TRUE;
+ }
+
+ BRASERO_BURN_LOG ("Updating cache information for %s", uri);
}
/* grab an available metadata (NOTE: there should always be at least one
@@ -674,15 +698,18 @@
if (result) {
/* see if we should add it to the buffer */
if (meta_info->has_audio || meta_info->has_video) {
- BraseroMetadataInfo *copy;
+ BraseroIOMetadataCached *cached;
- copy = g_new0 (BraseroMetadataInfo, 1);
- brasero_metadata_set_info (metadata, copy);
+ cached = g_new0 (BraseroIOMetadataCached, 1);
+ cached->last_modified = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
- g_queue_push_head (priv->meta_buffer, copy);
+ cached->info = g_new0 (BraseroMetadataInfo, 1);
+ brasero_metadata_set_info (metadata, cached->info);
+
+ g_queue_push_head (priv->meta_buffer, cached);
if (g_queue_get_length (priv->meta_buffer) > MAX_BUFFERED_META) {
- meta_info = g_queue_pop_tail (priv->meta_buffer);
- brasero_metadata_info_free (meta_info);
+ cached = g_queue_pop_tail (priv->meta_buffer);
+ brasero_io_metadata_cached_free (cached);
}
}
}
@@ -723,6 +750,11 @@
if (options & BRASERO_IO_INFO_ICON)
strcat (attributes, "," G_FILE_ATTRIBUTE_STANDARD_ICON);
+ /* if retrieving metadata we need this one to check if a possible result
+ * in cache should be updated or used */
+ if (options & BRASERO_IO_INFO_METADATA)
+ strcat (attributes, "," G_FILE_ATTRIBUTE_STANDARD_SIZE);
+
file = g_file_new_for_uri (uri);
info = g_file_query_info (file,
attributes,
@@ -2276,10 +2308,10 @@
priv->metadatas = NULL;
if (priv->meta_buffer) {
- BraseroMetadataInfo *metadata;
+ BraseroIOMetadataCached *cached;
- while ((metadata = g_queue_pop_head (priv->meta_buffer)) != NULL)
- brasero_metadata_info_free (metadata);
+ while ((cached = g_queue_pop_head (priv->meta_buffer)) != NULL)
+ brasero_io_metadata_cached_free (cached);
g_queue_free (priv->meta_buffer);
priv->meta_buffer = NULL;
Modified: trunk/src/brasero-metadata.h
==============================================================================
--- trunk/src/brasero-metadata.h (original)
+++ trunk/src/brasero-metadata.h Tue Jul 1 10:13:33 2008
@@ -66,9 +66,9 @@
GSList *silences;
- gboolean is_seekable;
- gboolean has_audio;
- gboolean has_video;
+ guint is_seekable:1;
+ guint has_audio:1;
+ guint has_video:1;
} BraseroMetadataInfo;
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]