[rhythmbox] track-transfer-batch: use lossless if that's all we have (bug #661806)



commit 9f0e6a19f8e82a0ce2f495e4180725c8e290c714
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Oct 15 12:08:40 2011 +1000

    track-transfer-batch: use lossless if that's all we have (bug #661806)
    
    If the encoding target for the batch only includes lossless profiles,
    use the first one that works.  The only situation this should occur in
    is when extracting from an audio CD with FLAC as the preferred media type.
    
    Otherwise lossless profiles are still ignored, even if a lossy profile
    requires additional plugins to be installed.

 shell/rb-track-transfer-batch.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/shell/rb-track-transfer-batch.c b/shell/rb-track-transfer-batch.c
index c26eadf..e77ea7a 100644
--- a/shell/rb-track-transfer-batch.c
+++ b/shell/rb-track-transfer-batch.c
@@ -166,11 +166,14 @@ select_profile_for_entry (RBTrackTransferBatch *batch, RhythmDBEntry *entry, Gst
 	 */
 
 	const char *media_type = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MEDIA_TYPE);
+	GstEncodingProfile *lossless = NULL;
+	gboolean found_lossy = FALSE;
 	const GList *p;
 
 	for (p = gst_encoding_target_get_profiles (batch->priv->target); p != NULL; p = p->next) {
 		GstEncodingProfile *profile = GST_ENCODING_PROFILE (p->data);
 		char *profile_media_type;
+		gboolean is_missing;
 		gboolean skip;
 
 		if (g_str_has_prefix (media_type, "audio/x-raw") == FALSE &&
@@ -181,7 +184,8 @@ select_profile_for_entry (RBTrackTransferBatch *batch, RhythmDBEntry *entry, Gst
 		}
 
 		skip = FALSE;
-		/* ignore lossless encodings for now */
+		is_missing = (g_list_find (batch->priv->missing_plugin_profiles, profile) != NULL);
+
 		profile_media_type = rb_gst_encoding_profile_get_media_type (profile);
 		if (profile_media_type == NULL) {
 			if (g_str_has_prefix (media_type, "audio/x-raw")) {
@@ -189,8 +193,15 @@ select_profile_for_entry (RBTrackTransferBatch *batch, RhythmDBEntry *entry, Gst
 			}
 		} else if (rb_gst_media_type_is_lossless (profile_media_type)) {
 			skip = TRUE;
-		} else if (allow_missing == FALSE) {
-			if (g_list_find (batch->priv->missing_plugin_profiles, profile)) {
+			if (allow_missing == FALSE && is_missing) {
+				/* ignore entirely */
+			} else if (lossless == NULL) {
+				/* remember the first lossless profile that works */
+				lossless = profile;
+			}
+		} else {
+			found_lossy = TRUE;
+			if (allow_missing == FALSE && is_missing) {
 				skip = TRUE;
 			}
 		}
@@ -201,6 +212,11 @@ select_profile_for_entry (RBTrackTransferBatch *batch, RhythmDBEntry *entry, Gst
 		g_free (profile_media_type);
 	}
 
+	/* if we only found a lossless encoding, use it */
+	if (*rprofile == NULL && found_lossy == FALSE && lossless != NULL) {
+		*rprofile = lossless;
+	}
+
 	return (*rprofile != NULL);
 }
 



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