rhythmbox r5720 - in trunk: . backends backends/gstreamer bindings/python lib plugins/ipod plugins/mtpdevice shell sources



Author: jmatthew
Date: Sat Jun  7 02:35:50 2008
New Revision: 5720
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5720&view=rev

Log:
2008-06-07  Jonathan Matthew  <jonathan d14n org>

	* backends/gstreamer/rb-encoder-gst.c: (rb_encoder_gst_finalize),
	(rb_encoder_gst_emit_completed), (rb_encoder_gst_encode):
	* backends/rb-encoder.c: (rb_encoder_interface_init),
	(_rb_encoder_emit_completed):
	* backends/rb-encoder.h:
	* bindings/python/rb.defs:
	* lib/rb-marshal.list:
	* shell/rb-removable-media-manager.c: (completed_cb):
	* shell/rb-removable-media-manager.h:
	* sources/rb-library-source.c: (completed_cb):
	* sources/rb-removable-media-source.h:
	* sources/rb-removable-media-source.c: (_track_added_cb),
	(rb_removable_media_source_track_added):
	* plugins/ipod/rb-ipod-source.c: (impl_track_added):
	Add a file size argument to the encoder's 'completed' signal.

	* plugins/mtpdevice/rb-mtp-source.c: (transfer_track),
	(impl_track_added):
	Use it for libmtp transfers, rather than the size of the original
	file.  Fixes #502771, hopefully.


Modified:
   trunk/ChangeLog
   trunk/backends/gstreamer/rb-encoder-gst.c
   trunk/backends/rb-encoder.c
   trunk/backends/rb-encoder.h
   trunk/bindings/python/rb.defs
   trunk/lib/rb-marshal.list
   trunk/plugins/ipod/rb-ipod-source.c
   trunk/plugins/mtpdevice/rb-mtp-source.c
   trunk/shell/rb-removable-media-manager.c
   trunk/shell/rb-removable-media-manager.h
   trunk/sources/rb-library-source.c
   trunk/sources/rb-removable-media-source.c
   trunk/sources/rb-removable-media-source.h

Modified: trunk/backends/gstreamer/rb-encoder-gst.c
==============================================================================
--- trunk/backends/gstreamer/rb-encoder-gst.c	(original)
+++ trunk/backends/gstreamer/rb-encoder-gst.c	Sat Jun  7 02:35:50 2008
@@ -70,6 +70,7 @@
 	GstFormat position_format;
 	gint64 total_length;
 	guint progress_id;
+	char *dest_uri;
 };
 
 G_DEFINE_TYPE_WITH_CODE(RBEncoderGst, rb_encoder_gst, G_TYPE_OBJECT,
@@ -158,6 +159,8 @@
 		encoder->priv->pipeline = NULL;
 	}
 
+	g_free (encoder->priv->dest_uri);
+
         G_OBJECT_CLASS (rb_encoder_gst_parent_class)->finalize (object);
 }
 
@@ -178,6 +181,9 @@
 rb_encoder_gst_emit_completed (RBEncoderGst *encoder)
 {
 	GError *error = NULL;
+	guint64 dest_size;
+	GnomeVFSFileInfo *file_info;
+	GnomeVFSResult result;
 
 	g_return_if_fail (encoder->priv->completion_emitted == FALSE);
 
@@ -199,8 +205,22 @@
 		g_error_free (error);
 	}
 
+	/* find the size of the output file, assuming we can get at it with gnome-vfs */
+	dest_size = 0;
+	file_info = gnome_vfs_file_info_new ();
+	result = gnome_vfs_get_file_info (encoder->priv->dest_uri, file_info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+	if (result == GNOME_VFS_OK && (file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE)) {
+		dest_size = file_info->size;
+		rb_debug ("destination file size: %" G_GUINT64_FORMAT, dest_size);
+	} else {
+		rb_debug ("couldn't get size of destination %s: %s",
+			  encoder->priv->dest_uri,
+			  gnome_vfs_result_to_string (result));
+	}
+	gnome_vfs_file_info_unref (file_info);
+
 	encoder->priv->completion_emitted = TRUE;
-	_rb_encoder_emit_completed (RB_ENCODER (encoder));
+	_rb_encoder_emit_completed (RB_ENCODER (encoder), dest_size);
 }
 
 static gboolean
@@ -1004,7 +1024,7 @@
 					     gnome_vfs_result_to_string (vfsresult));
 
 		_rb_encoder_emit_error (encoder, error);
-		_rb_encoder_emit_completed (encoder);
+		_rb_encoder_emit_completed (encoder, 0);
 		g_error_free (error);
 		return FALSE;
 	}
@@ -1028,6 +1048,7 @@
 		}
 	}
 
+	priv->dest_uri = g_strdup (dest);
 	if (copy) {
 		priv->total_length = rhythmdb_entry_get_uint64 (entry, RHYTHMDB_PROP_FILE_SIZE);
 		priv->position_format = GST_FORMAT_BYTES;
@@ -1049,12 +1070,13 @@
 
 		rb_encoder_gst_emit_error (enc, error);
 		g_error_free (error);
-		if (enc->priv->pipeline == NULL)
+		if (enc->priv->pipeline == NULL) {
 			rb_encoder_gst_emit_completed (enc);
-		else
+		} else {
 			/* this will unref the pipeline and call emit_completed
 			 */
 			rb_encoder_gst_cancel (encoder);
+		}
 	}
 
 	return result;

Modified: trunk/backends/rb-encoder.c
==============================================================================
--- trunk/backends/rb-encoder.c	(original)
+++ trunk/backends/rb-encoder.c	Sat Jun  7 02:35:50 2008
@@ -30,6 +30,7 @@
 
 #include "rb-encoder.h"
 #include "rb-encoder-gst.h"
+#include "rb-marshal.h"
 
 /**
  * SECTION:rb-encoder
@@ -87,9 +88,9 @@
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (RBEncoderIface, completed),
 			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
+			      rb_marshal_VOID__UINT64,
 			      G_TYPE_NONE,
-			      0);
+			      1, G_TYPE_UINT64);
 	/**
 	 * RBEncoder::error:
 	 * @encoder: the #RBEncoder instance
@@ -220,9 +221,9 @@
 }
 
 void
-_rb_encoder_emit_completed (RBEncoder *encoder)
+_rb_encoder_emit_completed (RBEncoder *encoder, guint64 dest_size)
 {
-	g_signal_emit (encoder, signals[COMPLETED], 0);
+	g_signal_emit (encoder, signals[COMPLETED], 0, dest_size);
 }
 
 void

Modified: trunk/backends/rb-encoder.h
==============================================================================
--- trunk/backends/rb-encoder.h	(original)
+++ trunk/backends/rb-encoder.h	Sat Jun  7 02:35:50 2008
@@ -72,7 +72,7 @@
 
 	/* signals */
 	void (*progress) (RBEncoder *encoder,  double fraction);
-	void (*completed) (RBEncoder *encoder);
+	void (*completed) (RBEncoder *encoder, guint64 dest_size);
 	void (*error) (RBEncoder *encoder, GError *error);
 } RBEncoderIface;
 
@@ -92,7 +92,7 @@
 
 /* only to be used by subclasses */
 void	_rb_encoder_emit_progress (RBEncoder *encoder, double fraction);
-void	_rb_encoder_emit_completed (RBEncoder *encoder);
+void	_rb_encoder_emit_completed (RBEncoder *encoder, guint64 dest_size);
 void	_rb_encoder_emit_error (RBEncoder *encoder, GError *error);
 
 G_END_DECLS

Modified: trunk/bindings/python/rb.defs
==============================================================================
--- trunk/bindings/python/rb.defs	(original)
+++ trunk/bindings/python/rb.defs	Sat Jun  7 02:35:50 2008
@@ -1789,6 +1789,7 @@
   (parameters
     '("RhythmDBEntry*" "entry")
     '("const-char*" "uri")
+    '("guint64" "filesize")
     '("const-char*" "mimetype")
   )
 )
@@ -1815,6 +1816,7 @@
   (parameters
     '("RhythmDBEntry*" "entry")
     '("const-char*" "uri")
+    '("guint64" "track_added")
     '("const-char*" "mimetype")
   )
 )

Modified: trunk/lib/rb-marshal.list
==============================================================================
--- trunk/lib/rb-marshal.list	(original)
+++ trunk/lib/rb-marshal.list	Sat Jun  7 02:35:50 2008
@@ -15,6 +15,7 @@
 VOID:BOXED,STRING,BOXED
 VOID:BOXED,ULONG
 VOID:DOUBLE,LONG
+VOID:UINT64
 VOID:INT,INT
 VOID:INT,INT,DOUBLE
 VOID:OBJECT,INT,INT

Modified: trunk/plugins/ipod/rb-ipod-source.c
==============================================================================
--- trunk/plugins/ipod/rb-ipod-source.c	(original)
+++ trunk/plugins/ipod/rb-ipod-source.c	Sat Jun  7 02:35:50 2008
@@ -81,6 +81,7 @@
 static gboolean impl_track_added (RBRemovableMediaSource *source,
 				  RhythmDBEntry *entry,
 				  const char *dest,
+				  guint64 filesize,
 				  const char *mimetype);
 static char* impl_build_dest_uri (RBRemovableMediaSource *source,
 				  RhythmDBEntry *entry,
@@ -1346,6 +1347,7 @@
 impl_track_added (RBRemovableMediaSource *source,
 		  RhythmDBEntry *entry,
 		  const char *dest,
+		  guint64 filesize,
 		  const char *mimetype)
 {
 	RBiPodSource *isource = RB_IPOD_SOURCE (source);

Modified: trunk/plugins/mtpdevice/rb-mtp-source.c
==============================================================================
--- trunk/plugins/mtpdevice/rb-mtp-source.c	(original)
+++ trunk/plugins/mtpdevice/rb-mtp-source.c	Sat Jun  7 02:35:50 2008
@@ -78,6 +78,7 @@
 static gboolean impl_track_added (RBRemovableMediaSource *source,
 				  RhythmDBEntry *entry,
 				  const char *dest,
+				  guint64 filesize,
 				  const char *mimetype);
 static char* impl_build_dest_uri (RBRemovableMediaSource *source,
 				  RhythmDBEntry *entry,
@@ -688,6 +689,7 @@
 		LIBMTP_mtpdevice_t *device,
 		RhythmDBEntry *entry,
 		const char *filename,
+		guint64 filesize,
 		const char *mimetype)
 {
 	LIBMTP_track_t *trackmeta = LIBMTP_new_track_t ();
@@ -705,7 +707,7 @@
 	}
 	trackmeta->tracknumber = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_TRACK_NUMBER);
 	trackmeta->duration = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_DURATION) * 1000;
-	trackmeta->filesize = rhythmdb_entry_get_uint64 (entry, RHYTHMDB_PROP_FILE_SIZE);
+	trackmeta->filesize = filesize;
 	if (mimetype == NULL) {
 		trackmeta->filetype = mimetype_to_filetype (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MIMETYPE));
 	} else {
@@ -749,6 +751,7 @@
 impl_track_added (RBRemovableMediaSource *isource,
 		  RhythmDBEntry *entry,
 		  const char *dest,
+		  guint64 filesize,
 		  const char *mimetype)
 {
 	RBMtpSource *source = RB_MTP_SOURCE (isource);
@@ -757,7 +760,7 @@
 	LIBMTP_track_t *track = NULL;
 
 	filename = g_filename_from_uri (dest, NULL, NULL);
-	track = transfer_track (source, priv->device, entry, filename, mimetype);
+	track = transfer_track (source, priv->device, entry, filename, filesize, mimetype);
 	gnome_vfs_unlink (filename);
 	g_free (filename);
 

Modified: trunk/shell/rb-removable-media-manager.c
==============================================================================
--- trunk/shell/rb-removable-media-manager.c	(original)
+++ trunk/shell/rb-removable-media-manager.c	Sat Jun  7 02:35:50 2008
@@ -628,6 +628,7 @@
 	RBRemovableMediaManager *manager;
 	RhythmDBEntry *entry;
 	char *dest;
+	guint64 dest_size;
 	GList *mime_types;
 	gboolean failed;
 	RBTranferCompleteCallback callback;
@@ -666,13 +667,13 @@
 }
 
 static void
-completed_cb (RBEncoder *encoder, TransferData *data)
+completed_cb (RBEncoder *encoder, guint64 dest_size, TransferData *data)
 {
 	RBRemovableMediaManagerPrivate *priv = REMOVABLE_MEDIA_MANAGER_GET_PRIVATE (data->manager);
 
-	rb_debug ("completed transferring track to %s", data->dest);
+	rb_debug ("completed transferring track to %s (%" G_GUINT64_FORMAT " bytes)", data->dest, dest_size);
 	if (!data->failed)
-		(data->callback) (data->entry, data->dest, data->userdata);
+		(data->callback) (data->entry, data->dest, dest_size, data->userdata);
 
 	priv->transfer_running = FALSE;
 	priv->transfer_done++;

Modified: trunk/shell/rb-removable-media-manager.h
==============================================================================
--- trunk/shell/rb-removable-media-manager.h	(original)
+++ trunk/shell/rb-removable-media-manager.h	Sat Jun  7 02:35:50 2008
@@ -47,6 +47,7 @@
 
 typedef void (*RBTranferCompleteCallback) (RhythmDBEntry *entry,
 					   const char *dest,
+					   guint64 dest_size,
 					   gpointer userdata);
 
 typedef struct

Modified: trunk/sources/rb-library-source.c
==============================================================================
--- trunk/sources/rb-library-source.c	(original)
+++ trunk/sources/rb-library-source.c	Sat Jun  7 02:35:50 2008
@@ -1243,7 +1243,7 @@
 
 #ifdef ENABLE_TRACK_TRANSFER
 static void
-completed_cb (RhythmDBEntry *entry, const char *dest, RBLibrarySource *source)
+completed_cb (RhythmDBEntry *entry, const char *dest, guint64 dest_size, RBLibrarySource *source)
 {
 	rhythmdb_add_uri (source->priv->db, dest);
 }

Modified: trunk/sources/rb-removable-media-source.c
==============================================================================
--- trunk/sources/rb-removable-media-source.c	(original)
+++ trunk/sources/rb-removable-media-source.c	Sat Jun  7 02:35:50 2008
@@ -264,9 +264,9 @@
 };
 
 static void
-_track_added_cb (RhythmDBEntry *entry, const char *uri, struct _TrackAddedData *data)
+_track_added_cb (RhythmDBEntry *entry, const char *uri, gint64 dest_size, struct _TrackAddedData *data)
 {
-	rb_removable_media_source_track_added (data->source, entry, uri, data->mimetype);
+	rb_removable_media_source_track_added (data->source, entry, uri, dest_size, data->mimetype);
 	g_free (data->mimetype);
 	g_free (data);
 }
@@ -546,13 +546,14 @@
 rb_removable_media_source_track_added (RBRemovableMediaSource *source,
 				       RhythmDBEntry *entry,
 				       const char *uri,
+				       guint64 filesize,
 				       const char *mimetype)
 {
 	RBRemovableMediaSourceClass *klass = RB_REMOVABLE_MEDIA_SOURCE_GET_CLASS (source);
 	gboolean add_to_db = TRUE;
 
 	if (klass->impl_track_added)
-		add_to_db = klass->impl_track_added (source, entry, uri, mimetype);
+		add_to_db = klass->impl_track_added (source, entry, uri, filesize, mimetype);
 
 	if (add_to_db) {
 		RhythmDBEntryType entry_type;

Modified: trunk/sources/rb-removable-media-source.h
==============================================================================
--- trunk/sources/rb-removable-media-source.h	(original)
+++ trunk/sources/rb-removable-media-source.h	Sat Jun  7 02:35:50 2008
@@ -60,6 +60,7 @@
 	gboolean	(*impl_track_added)	(RBRemovableMediaSource *source,
 						 RhythmDBEntry *entry,
 						 const char *uri,
+						 guint64 filesize,
 						 const char *mimetype);
 } RBRemovableMediaSourceClass;
 
@@ -72,6 +73,7 @@
 void		rb_removable_media_source_track_added		(RBRemovableMediaSource *source,
 								 RhythmDBEntry *entry,
 								 const char *uri,
+								 guint64 filesize,
 								 const char *mimetype);
 GList *		rb_removable_media_source_get_mime_types	(RBRemovableMediaSource *source);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]