[rhythmbox] encoder: remove the 'dest_size' argument to the completed signal



commit 91897a469669b4448fac432ffa2635d6285ee849
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Oct 10 14:25:09 2009 +1000

    encoder: remove the 'dest_size' argument to the completed signal
    
    This temporarily breaks transcoding onto MTP devices, but I promise it's
    worth it.

 backends/gstreamer/rb-encoder-gst.c |   23 ++---------------------
 backends/rb-encoder.c               |    8 ++++----
 backends/rb-encoder.h               |    4 ++--
 bindings/python/rb.defs             |    2 --
 plugins/ipod/rb-ipod-source.c       |    2 --
 plugins/mtpdevice/rb-mtp-source.c   |    7 ++-----
 shell/rb-removable-media-manager.c  |    6 +++---
 shell/rb-removable-media-manager.h  |    1 -
 sources/rb-library-source.c         |    2 +-
 sources/rb-removable-media-source.c |    7 +++----
 sources/rb-removable-media-source.h |    2 --
 11 files changed, 17 insertions(+), 47 deletions(-)
---
diff --git a/backends/gstreamer/rb-encoder-gst.c b/backends/gstreamer/rb-encoder-gst.c
index 0c520e2..7a427d2 100644
--- a/backends/gstreamer/rb-encoder-gst.c
+++ b/backends/gstreamer/rb-encoder-gst.c
@@ -187,9 +187,6 @@ static void
 rb_encoder_gst_emit_completed (RBEncoderGst *encoder)
 {
 	GError *error = NULL;
-	guint64 dest_size;
-	GFile *file;
-	GFileInfo *file_info;
 
 	g_return_if_fail (encoder->priv->completion_emitted == FALSE);
 
@@ -211,24 +208,8 @@ rb_encoder_gst_emit_completed (RBEncoderGst *encoder)
 		g_error_free (error);
 	}
 
-	/* find the size of the output file, assuming we can get at it with gio */
-	dest_size = 0;
-	file = g_file_new_for_uri (encoder->priv->dest_uri);
-	file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, &error);
-	if (error != NULL) {
-		rb_debug ("couldn't get size of destination %s: %s",
-			  encoder->priv->dest_uri,
-			  error->message);
-		g_clear_error (&error);
-	} else {
-		dest_size = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
-		rb_debug ("destination file size: %" G_GUINT64_FORMAT, dest_size);
-		g_object_unref (file_info);
-	}
-	g_object_unref (file);
-
 	encoder->priv->completion_emitted = TRUE;
-	_rb_encoder_emit_completed (RB_ENCODER (encoder), dest_size);
+	_rb_encoder_emit_completed (RB_ENCODER (encoder));
 }
 
 static gboolean
@@ -1026,7 +1007,7 @@ rb_encoder_gst_encode (RBEncoder *encoder,
 					     error->message);		/* I guess */
 
 		_rb_encoder_emit_error (encoder, error);
-		_rb_encoder_emit_completed (encoder, 0);
+		_rb_encoder_emit_completed (encoder);
 		g_error_free (error);
 		return FALSE;
 	}
diff --git a/backends/rb-encoder.c b/backends/rb-encoder.c
index 60d483b..ec957b1 100644
--- a/backends/rb-encoder.c
+++ b/backends/rb-encoder.c
@@ -150,9 +150,9 @@ rb_encoder_interface_init (RBEncoderIface *iface)
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (RBEncoderIface, completed),
 			      NULL, NULL,
-			      rb_marshal_VOID__UINT64,
+			      g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE,
-			      1, G_TYPE_UINT64);
+			      0);
 	/**
 	 * RBEncoder::error:
 	 * @encoder: the #RBEncoder instance
@@ -299,9 +299,9 @@ _rb_encoder_emit_progress (RBEncoder *encoder, double fraction)
 }
 
 void
-_rb_encoder_emit_completed (RBEncoder *encoder, guint64 dest_size)
+_rb_encoder_emit_completed (RBEncoder *encoder)
 {
-	g_signal_emit (encoder, signals[COMPLETED], 0, dest_size);
+	g_signal_emit (encoder, signals[COMPLETED], 0);
 }
 
 void
diff --git a/backends/rb-encoder.h b/backends/rb-encoder.h
index e7048c9..1087dde 100644
--- a/backends/rb-encoder.h
+++ b/backends/rb-encoder.h
@@ -82,7 +82,7 @@ struct _RBEncoderIface
 
 	/* signals */
 	void (*progress) (RBEncoder *encoder,  double fraction);
-	void (*completed) (RBEncoder *encoder, guint64 dest_size);
+	void (*completed) (RBEncoder *encoder);
 	void (*error) (RBEncoder *encoder, GError *error);
 };
 
@@ -120,7 +120,7 @@ gboolean	rb_encoder_get_preferred_mimetype (RBEncoder *encoder,
 
 /* only to be used by subclasses */
 void	_rb_encoder_emit_progress (RBEncoder *encoder, double fraction);
-void	_rb_encoder_emit_completed (RBEncoder *encoder, guint64 dest_size);
+void	_rb_encoder_emit_completed (RBEncoder *encoder);
 void	_rb_encoder_emit_error (RBEncoder *encoder, GError *error);
 
 void	_rb_encoder_emit_prepare_source (RBEncoder *encoder, const char *uri, GObject *source);
diff --git a/bindings/python/rb.defs b/bindings/python/rb.defs
index 4a133b2..507f816 100644
--- a/bindings/python/rb.defs
+++ b/bindings/python/rb.defs
@@ -1853,7 +1853,6 @@
   (parameters
     '("RhythmDBEntry*" "entry")
     '("const-char*" "uri")
-    '("guint64" "filesize")
     '("const-char*" "mimetype")
   )
 )
@@ -1880,7 +1879,6 @@
   (parameters
     '("RhythmDBEntry*" "entry")
     '("const-char*" "uri")
-    '("guint64" "track_added")
     '("const-char*" "mimetype")
   )
 )
diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c
index 6e8852d..b6abd41 100644
--- a/plugins/ipod/rb-ipod-source.c
+++ b/plugins/ipod/rb-ipod-source.c
@@ -72,7 +72,6 @@ static GList * impl_get_mime_types (RBRemovableMediaSource *source);
 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,
@@ -1225,7 +1224,6 @@ static gboolean
 impl_track_added (RBRemovableMediaSource *source,
 		  RhythmDBEntry *entry,
 		  const char *dest,
-		  guint64 filesize,
 		  const char *mimetype)
 {
 	RBiPodSource *isource = RB_IPOD_SOURCE (source);
diff --git a/plugins/mtpdevice/rb-mtp-source.c b/plugins/mtpdevice/rb-mtp-source.c
index 37952a2..e41872f 100644
--- a/plugins/mtpdevice/rb-mtp-source.c
+++ b/plugins/mtpdevice/rb-mtp-source.c
@@ -81,7 +81,6 @@ static GList * impl_get_mime_types (RBRemovableMediaSource *source);
 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,
@@ -952,7 +951,6 @@ transfer_track (RBMtpSource *source,
 		LIBMTP_mtpdevice_t *device,
 		RhythmDBEntry *entry,
 		const char *filename,
-		guint64 filesize,
 		const char *mimetype)
 {
 	LIBMTP_track_t *trackmeta = LIBMTP_new_track_t ();
@@ -974,7 +972,7 @@ transfer_track (RBMtpSource *source,
 	trackmeta->duration = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_DURATION) * 1000;
 	trackmeta->rating = rhythmdb_entry_get_double (entry, RHYTHMDB_PROP_RATING) * 20;
 	trackmeta->usecount = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_PLAY_COUNT);
-	trackmeta->filesize = filesize;
+	trackmeta->filesize = rhythmdb_entry_get_uint64 (entry, RHYTHMDB_PROP_FILE_SIZE);
 	if (mimetype == NULL) {
 		mimetype = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MIMETYPE);
 	}
@@ -1010,7 +1008,6 @@ static gboolean
 impl_track_added (RBRemovableMediaSource *isource,
 		  RhythmDBEntry *entry,
 		  const char *dest,
-		  guint64 filesize,
 		  const char *mimetype)
 {
 	RBMtpSource *source = RB_MTP_SOURCE (isource);
@@ -1021,7 +1018,7 @@ impl_track_added (RBRemovableMediaSource *isource,
 
 	file = g_file_new_for_uri (dest);
 	path = g_file_get_path (file);
-	track = transfer_track (source, priv->device, entry, path, filesize, mimetype);
+	track = transfer_track (source, priv->device, entry, path, mimetype);
 	g_free (path);
 
 	g_file_delete (file, NULL, NULL);
diff --git a/shell/rb-removable-media-manager.c b/shell/rb-removable-media-manager.c
index c001324..fbf429a 100644
--- a/shell/rb-removable-media-manager.c
+++ b/shell/rb-removable-media-manager.c
@@ -1114,13 +1114,13 @@ progress_cb (RBEncoder *encoder, double fraction, TransferData *data)
 }
 
 static void
-completed_cb (RBEncoder *encoder, guint64 dest_size, TransferData *data)
+completed_cb (RBEncoder *encoder, TransferData *data)
 {
 	RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (data->manager);
 
-	rb_debug ("completed transferring track to %s (%" G_GUINT64_FORMAT " bytes)", data->dest, dest_size);
+	rb_debug ("completed transferring track to %s", data->dest);
 	if (!data->failed)
-		(data->callback) (data->entry, data->dest, dest_size, data->userdata);
+		(data->callback) (data->entry, data->dest, data->userdata);
 
 	priv->transfer_running = FALSE;
 	priv->transfer_done++;
diff --git a/shell/rb-removable-media-manager.h b/shell/rb-removable-media-manager.h
index 8116554..575ff1f 100644
--- a/shell/rb-removable-media-manager.h
+++ b/shell/rb-removable-media-manager.h
@@ -49,7 +49,6 @@ G_BEGIN_DECLS
 
 typedef void (*RBTransferCompleteCallback) (RhythmDBEntry *entry,
 					    const char *dest,
-					    guint64 dest_size,
 					    gpointer userdata);
 
 typedef struct _RBRemovableMediaManager RBRemovableMediaManager;
diff --git a/sources/rb-library-source.c b/sources/rb-library-source.c
index 3307ea3..dc55c6b 100644
--- a/sources/rb-library-source.c
+++ b/sources/rb-library-source.c
@@ -1206,7 +1206,7 @@ impl_can_paste (RBSource *asource)
 }
 
 static void
-completed_cb (RhythmDBEntry *entry, const char *dest, guint64 dest_size, RBLibrarySource *source)
+completed_cb (RhythmDBEntry *entry, const char *dest, RBLibrarySource *source)
 {
 	rhythmdb_add_uri (source->priv->db, dest);
 }
diff --git a/sources/rb-removable-media-source.c b/sources/rb-removable-media-source.c
index 225a990..50b2478 100644
--- a/sources/rb-removable-media-source.c
+++ b/sources/rb-removable-media-source.c
@@ -313,9 +313,9 @@ struct _TrackAddedData {
 };
 
 static void
-_track_added_cb (RhythmDBEntry *entry, const char *uri, gint64 dest_size, struct _TrackAddedData *data)
+_track_added_cb (RhythmDBEntry *entry, const char *uri, struct _TrackAddedData *data)
 {
-	rb_removable_media_source_track_added (data->source, entry, uri, dest_size, data->mimetype);
+	rb_removable_media_source_track_added (data->source, entry, uri, data->mimetype);
 	g_free (data->mimetype);
 	g_free (data);
 }
@@ -699,14 +699,13 @@ void
 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, filesize, mimetype);
+		add_to_db = klass->impl_track_added (source, entry, uri, mimetype);
 
 	if (add_to_db) {
 		RhythmDBEntryType entry_type;
diff --git a/sources/rb-removable-media-source.h b/sources/rb-removable-media-source.h
index cd40dd1..0a59f8b 100644
--- a/sources/rb-removable-media-source.h
+++ b/sources/rb-removable-media-source.h
@@ -60,7 +60,6 @@ typedef struct
 	gboolean	(*impl_track_added)	(RBRemovableMediaSource *source,
 						 RhythmDBEntry *entry,
 						 const char *uri,
-						 guint64 filesize,
 						 const char *mimetype);
 	gboolean	(*impl_should_paste)	(RBRemovableMediaSource *source,
 						 RhythmDBEntry *entry);
@@ -78,7 +77,6 @@ char*		rb_removable_media_source_build_dest_uri 	(RBRemovableMediaSource *source
 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);
 gboolean	rb_removable_media_source_should_paste		(RBRemovableMediaSource *source,



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