[libdmapsharing] Fix daap-share.c:should_transcode()



commit 77e846271dd5df841c6156d8a5a5eb8ded32f511
Author: W. Michael Petullo <mike flyn org>
Date:   Thu Aug 15 23:18:27 2013 -0400

    Fix daap-share.c:should_transcode()
    
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/daap-share.c |   23 +++++++++++++++++++----
 tests/test-dmap-client.c    |   12 +++++++-----
 2 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index 9867e1c..f251f47 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -375,14 +375,29 @@ static struct DMAPMetaDataMap meta_data_map[] = {
 
 static gboolean should_transcode (const gchar *format, const gboolean has_video, const gchar 
*transcode_mimetype)
 {
-       gboolean fnval;
+       gboolean fnval = FALSE;
        char *format2 = NULL;
 
        // Not presently transcoding videos (see also same comments elsewhere).
-       fnval = has_video 
-            || transcode_mimetype == NULL
-            || ((format2 = dmap_mime_to_format (transcode_mimetype)) && strcmp (format, format2));
+       if (TRUE == has_video) {
+               goto done;
+       }
+
+       if (NULL == transcode_mimetype) {
+               goto done;
+       }
+
+       format2 = dmap_mime_to_format (transcode_mimetype);
+       if (NULL == format2) {
+               g_warning ("Configured to transcode, but target format is bad");
+               goto done;
+       }
+
+       if (strcmp (format, format2)) {
+               fnval = TRUE;
+       }
 
+done:
        g_debug ("    Should%s transcode %s %s", fnval ? "" : " not", format, format2 ? format2 : "[no target 
format]");
 
        return fnval;
diff --git a/tests/test-dmap-client.c b/tests/test-dmap-client.c
index 5cc8add..e127bd6 100644
--- a/tests/test-dmap-client.c
+++ b/tests/test-dmap-client.c
@@ -39,14 +39,16 @@ static guint conn_type = DAAP;
 static void
 print_record (gpointer id, DMAPRecord *record, gpointer user_data)
 {
-       gchar *artist, *title;
+       gboolean has_video;
+       gchar   *artist, *title;
 
        g_object_get (record,
-                    "songartist", &artist,
-                    "title",  &title,
-                    NULL);
+                    "has-video", &has_video,
+                    "songartist", &artist,
+                    "title",  &title,
+                     NULL);
 
-       g_print ("%d: %s %s\n", GPOINTER_TO_UINT (id), artist, title);
+       g_print ("%d: %s %s (has video: %s)\n", GPOINTER_TO_UINT (id), artist, title, has_video ? "Y" : "N");
 
        g_free (artist);
        g_free (title);


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