[maemo-commits] [maemo-commits] r13148 - in projects/haf/trunk/hildon-thumbnail: . debian thumbs

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Aug 13 13:04:15 EEST 2007
Author: kihamala
Date: 2007-08-13 13:04:13 +0300 (Mon, 13 Aug 2007)
New Revision: 13148

Modified:
   projects/haf/trunk/hildon-thumbnail/ChangeLog
   projects/haf/trunk/hildon-thumbnail/debian/changelog
   projects/haf/trunk/hildon-thumbnail/debian/control
   projects/haf/trunk/hildon-thumbnail/debian/copyright
   projects/haf/trunk/hildon-thumbnail/thumbs/thumber-common.c
   projects/haf/trunk/hildon-thumbnail/thumbs/thumber-gdk-pixbuf.c
Log:
fixes from 0.13-1


Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-thumbnail/ChangeLog	2007-08-13 09:44:29 UTC (rev 13147)
+++ projects/haf/trunk/hildon-thumbnail/ChangeLog	2007-08-13 10:04:13 UTC (rev 13148)
@@ -1,7 +1,11 @@
-2007-06-12  Tommi Komulainen  <tommi.komulainen at nokia.com>
+2007-08-10  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
 
-	* thumbs/thumber-common.c (hildon_thumber_main): Call g_thread_init()
-	before g_type_init() or gnome_vfs_init() to avoid GSlice problems.
+	Applied a modified patch from Daniil Ivanov:
+	* thumbs/thumber-gdk-pixbuf.c (create_thumb): Read four bytes at a
+	time instead of one.
+	(thumbnailer_oom_func): New.
+	(main): Register thumbnailer_oom_func as the OOM callback. Add Glib
+	thread initialisation. Fixes: NB#63712
 
 2006-10-13  Marius Vollmer  <marius.vollmer at nokia.com>
 
@@ -27,9 +31,9 @@
 	
 2005-10-12  Luc Pionchon  <luc.pionchon at nokia.com>
 
-        N#20238 - Thumbnailer causes system crashes on large images
+	N#20238 - Thumbnailer causes system crashes on large images
 	
-        * thumbs/thumber-gdk-pixbuf.c
+	* thumbs/thumber-gdk-pixbuf.c
 
 	(can_crop_file): Removed artificial resolution restriction, since
 	                 more precice memory monitoring can be used now.

Modified: projects/haf/trunk/hildon-thumbnail/debian/changelog
===================================================================
--- projects/haf/trunk/hildon-thumbnail/debian/changelog	2007-08-13 09:44:29 UTC (rev 13147)
+++ projects/haf/trunk/hildon-thumbnail/debian/changelog	2007-08-13 10:04:13 UTC (rev 13148)
@@ -1,3 +1,24 @@
+hildon-thumbnail (0.13-1) unstable; urgency=low
+
+  * Fixed some lintian warnings. Fixes: NB#44044
+
+ -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>  Fri, 10 Aug 2007 16:19:45 +0300
+
+hildon-thumbnail (0.13) unstable; urgency=low
+
+  * Added Glib thread initialisation. Fixes: NB#62806
+  * Now OOM handler simply exits because the thumbnailer was still jamming
+    sometimes with Daniil's patch. Fixes: NB#63712
+
+ -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>  Fri, 10 Aug 2007 15:13:11 +0300
+
+hildon-thumbnail (0.12) unstable; urgency=low
+
+  * Applied patch to use Libosso saw functions.
+  * Read four bytes at a time, instead of one byte, in thumber-gdk-pixbuf.
+
+ -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>  Fri, 10 Aug 2007 14:28:59 +0300
+
 hildon-thumbnail (0.11) unstable; urgency=low
 
   * Use a real osso-thumbnail transitional package instead of a Provides

Modified: projects/haf/trunk/hildon-thumbnail/debian/control
===================================================================
--- projects/haf/trunk/hildon-thumbnail/debian/control	2007-08-13 09:44:29 UTC (rev 13147)
+++ projects/haf/trunk/hildon-thumbnail/debian/control	2007-08-13 10:04:13 UTC (rev 13148)
@@ -8,7 +8,7 @@
 Package: hildon-thumbnail
 Section: libs
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libhildon-thumbnail0 (= ${Source-Version})
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Recommends: osso-thumbnailer-libid3 (>= 0.3.0)
 Conflicts: osso-thumbnail (<< 0.11)
 Replaces: osso-thumbnail (<< 0.11)
@@ -20,6 +20,7 @@
 Architecture: any
 Depends: hildon-thumbnail
 Description: Transitional package for hildon-thumbnail
+ Contains transitional package for hildon-thumbnail.
 
 Package: libhildon-thumbnail0
 Section: libs
@@ -27,15 +28,18 @@
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Conflicts: osso-thumbnail0 (<< 0.3.0), osso-thumbnail-libid3 (<< 0.3.0)
 Description: Thumbnail library.
+ Contains the thumbnail library.
 
 Package: libhildon-thumbnail0-dbg
 Section: devel
 Architecture: any
 Depends: libhildon-thumbnail0 (= ${Source-Version})
 Description: Debug symbols for libhildon-thumbnail0
+ Contains debug symbols for libhildon-thumbnail0.
 
 Package: libhildon-thumbnail-dev
 Section: devel
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, libhildon-thumbnail0 (= ${Source-Version}), libosso-gnomevfs2-dev, libgtk2.0-dev, libosso-dev
 Description: libhildon-thumbnail0 development files.
+ Contains libhildon-thumbnail0 development files.

Modified: projects/haf/trunk/hildon-thumbnail/debian/copyright
===================================================================
--- projects/haf/trunk/hildon-thumbnail/debian/copyright	2007-08-13 09:44:29 UTC (rev 13147)
+++ projects/haf/trunk/hildon-thumbnail/debian/copyright	2007-08-13 10:04:13 UTC (rev 13148)
@@ -1,9 +1,11 @@
 Copyright (C) 2004-2006 Nokia Corporation.
 
 This thumbnail library is licensed under the terms of the LGPL.
+See /usr/share/common-licenses/LGPL-2 on your debian system.
 
 osso-thumb-gdk-pixbuf and osso-thumber-register are licensed 
 under the terms of the GPL.
+See /usr/share/common-licenses/GPL-2 on your debian system.
 
 MD5 code:
 Copyright (C) 1999 Aladdin Enterprises.

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/thumber-common.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/thumber-common.c	2007-08-13 09:44:29 UTC (rev 13147)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/thumber-common.c	2007-08-13 10:04:13 UTC (rev 13148)
@@ -53,7 +53,6 @@
     guint width, height;
     HildonThumbnailFlags flags;
     gchar *uri, *file, *mime_type, *local_file;
-    //gchar *fail_file, *final_file;
 
     time_t mtime = 0;
     GdkPixbuf *pixbuf;
@@ -61,7 +60,6 @@
     GError *error = NULL;
     int status = 0;
 
-    //const char *meta;
     gchar **keys = NULL, **values = NULL;
 
     argc = *argc_p;
@@ -82,8 +80,6 @@
     width = atoi(argv[5]);
     height = atoi(argv[6]);
 
-    if (!g_thread_supported ())
-      g_thread_init (NULL);
     g_type_init();
 
     gnome_vfs_init();
@@ -96,14 +92,7 @@
 
     local_file = gnome_vfs_get_local_path_from_uri(uri);
 
-    //if(gnome_vfs_uri_is_local(vfs_uri)) {
     if(local_file && strlen(local_file)) {
-        /*
-        if(!local_file || strlen(local_file) == 0) {
-            g_warning("Failed to get local file for uri: %s", uri);
-            return 4;
-        }
-        */
         mtime = get_file_mtime(local_file);
     } else {
         gchar *file_uri;
@@ -130,8 +119,6 @@
 
     gnome_vfs_uri_unref(vfs_uri);
 
-    //g_message("thumber from %s to %s", local_file, file);
-
     pixbuf = create_thumb(local_file, mime_type,
         width, height, flags, &keys, &values, &error);
 
@@ -151,8 +138,6 @@
     if(keys) g_strfreev(keys);
     if(values) g_strfreev(values);
 
-    //g_message("Saved %s to %s", uri, final_file);
-
     gdk_pixbuf_unref(pixbuf);
 
     g_free(local_file);

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/thumber-gdk-pixbuf.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/thumber-gdk-pixbuf.c	2007-08-13 09:44:29 UTC (rev 13147)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/thumber-gdk-pixbuf.c	2007-08-13 10:04:13 UTC (rev 13148)
@@ -1,7 +1,7 @@
  /*
   * This file is part of osso-thumbnail package
   *
-  * Copyright (C) 2005, 2006 Nokia Corporation.  All rights reserved.
+  * Copyright (C) 2005-2007 Nokia Corporation.  All rights reserved.
   *
   * Contact: Marius Vollmer <marius.vollmer at nokia.com>
   *
@@ -28,6 +28,7 @@
 #include <osso-mem.h>
 #include <osso-log.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <sys/resource.h>
 #include <stdio.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
@@ -72,8 +73,6 @@
             v = b;
         }
 
-        //printf("na=%f, nb=%f, nx=%d, ny=%d, u=%d, v=%d\n", na, nb, nx, ny, u, v);
-
         if(a * y < b * x) {
             nb = (double)a * v / u;
             // Center
@@ -91,13 +90,6 @@
     offx = -offx * scax;
     offy = -offy * scay;
 
-    /*
-    printf("(%d, %d) -> (%d, %d) => (%f, %f) -> (%d, %d)\n",
-        a, b, x, y, na, nb, nx, ny);
-    printf("offx=%f, offy=%f, scax=%f, scay=%f\n",
-        offx, offy, scax, scay);
-    */
-
     dest = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(src),
         gdk_pixbuf_get_has_alpha(src), gdk_pixbuf_get_bits_per_sample(src),
         nx, ny);
@@ -141,6 +133,8 @@
   }
 }
 
+#define BLK 4
+
 GdkPixbuf *create_thumb(const gchar *local_file, const gchar *mime_type,
     guint width, guint height, HildonThumbnailFlags flags,
     gchar ***opt_keys, gchar ***opt_values, GError **error)
@@ -148,36 +142,59 @@
     if((flags & HILDON_THUMBNAIL_FLAG_CROP)) {
        GdkPixbuf *pixbuf, *result = NULL;
        GdkPixbufLoader *loader;
-       guchar buffer[2048];
+       guchar buffer[2048]; /* size must be dividable by BLK */
        FILE *f; 
-       size_t bytes_read;
+       size_t items_read = sizeof(buffer) / BLK;
        size_t desired_max_area;
 
        f = fopen(local_file, "r");
        if (!f) return NULL;
-     
+
        desired_max_area = (width * height * 4) - 1;
        loader = gdk_pixbuf_loader_new ();
        g_signal_connect(loader, "size-prepared", G_CALLBACK(size_prepared),
                         GINT_TO_POINTER(desired_max_area));
 
-       do
+       while (items_read >= sizeof(buffer) / BLK)
        {
-         bytes_read = fread(buffer, 1, sizeof(buffer), f);
-         if (!gdk_pixbuf_loader_write(loader, buffer, bytes_read, error))
+         long pos;
+         int nbytes;
+
+         /* read BLK bytes at a time as much as possible */
+         if ((pos = ftell(f)) == -1)
+         {
+           gdk_pixbuf_loader_close(loader, NULL);
+           goto cleanup;
+         }
+         items_read = fread(buffer, BLK, sizeof(buffer) / BLK, f);
+
+         if (items_read < sizeof(buffer) / BLK)
+         {
+           /* read again one byte at a time */
+           if (fseek(f, pos, SEEK_SET) == -1)
+           {
+             gdk_pixbuf_loader_close(loader, NULL);
+             goto cleanup;
+           }
+           nbytes = fread(buffer, 1, sizeof(buffer), f);
+         }
+         else
+           nbytes = items_read * BLK;
+
+         if (!gdk_pixbuf_loader_write(loader, buffer, nbytes, error))
          { /* We have to call close before unreffing */
            gdk_pixbuf_loader_close(loader, NULL);
            goto cleanup;
          }
-       } while (bytes_read >= sizeof(buffer));
+       }
 
        if (!gdk_pixbuf_loader_close(loader, error))
          goto cleanup;
-       
+
        /* Loader owns reference to this pixbuf */
        pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
 
-       if(pixbuf)
+       if (pixbuf)
          result = crop_resize(pixbuf, width, height);
 cleanup:
        fclose(f);
@@ -191,23 +208,31 @@
        pixbuf = gdk_pixbuf_new_from_file_at_size (local_file, width, height, 
 	 					  &error);
        if (error) {
- 	   ULOG_ERR ("can't create thumb: %s", error->message);
+ 	   ULOG_ERR_F("can't create thumb: %s", error->message);
 	   g_error_free (error);
        }
        return pixbuf;
     }
-    
+
     return NULL;
 }
 
+static void
+thumbnailer_oom_func (size_t cur, size_t max, void *data)
+{
+    ULOG_DEBUG_F("OOM: %u of %u!", cur, max);
+    exit(1);
+}
+
 int main(int argc, char **argv)
 {
     int result;
 
     setpriority(PRIO_PROCESS, getpid(), 10);
-    result = osso_mem_saw_enable(4 << 20, 64, NULL, NULL);
+    g_thread_init(NULL);
+    result = osso_mem_saw_enable(4 << 20, 64, thumbnailer_oom_func, NULL);
     if (result != 0)
-      ULOG_ERR ("can't install memory watchdog: code %d\n", result);
+      ULOG_ERR_F("osso_mem_saw_enable failed with error %d", result);
     else
       {
 	result = hildon_thumber_main(&argc, &argv, create_thumb);


More information about the maemo-commits mailing list