imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp
changeset 14 2edacbf5d3f9
parent 0 2014ca87e772
child 15 7197e789b953
--- a/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp	Tue Feb 02 00:23:15 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp	Fri Mar 19 09:35:30 2010 +0200
@@ -19,9 +19,9 @@
 //INCLUDE FILES
 #include <e32base.h>
 #include <imageconversion.h>
-#include <exifread.h>
+#include <ExifRead.h>
 
-#include <iclextjpegapi.h>
+#include <IclExtJpegApi.h>
 #include "thumbnailimagedecoderv3.h"
 #include "thumbnaillog.h"
 #include "thumbnailpanic.h"
@@ -198,18 +198,25 @@
     iDecoder = NULL;
 	
     CImageDecoder::TOptions options = ( CImageDecoder::TOptions )( 
-            CImageDecoder::EOptionNoDither | CImageDecoder::EPreferFastDecode );
+            CImageDecoder::EOptionNoDither | CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionAlwaysThread );
  
     TRAPD( decErr, iDecoder = CExtJpegDecoder::DataNewL(
             CExtJpegDecoder::EHwImplementation, iFs, *iBuffer, options ));
     
     if ( decErr != KErrNone )
         {
+        TN_DEBUG2( "CThumbnailImageDecoderv3::CreateDecoderL() - HW CExtJpegDecoder failed %d", decErr);
+        
+        LeaveIfCorruptL( decErr );
+        
         TRAP( decErr, iDecoder = CExtJpegDecoder::DataNewL(
                 CExtJpegDecoder::ESwImplementation, iFs, *iBuffer, options ));
         
         if ( decErr != KErrNone )
-            {                                              
+            {                             
+            TN_DEBUG2( "CThumbnailImageDecoderv3::CreateDecoderL() - SW CExtJpegDecoder failed %d", decErr);
+            
+            LeaveIfCorruptL( decErr );
             // don't force any mime type
             TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) );
             if ( decErr != KErrNone )
@@ -217,7 +224,7 @@
                 delete iBuffer;
                 iBuffer = NULL;
                 
-                TN_DEBUG1( "CThumbnailImageDecoderv3::CreateDecoderL() - error" );
+                TN_DEBUG2( "CThumbnailImageDecoderv3::CreateDecoderL() - CImageDecoder error %d", decErr );
                 
                 User::Leave( decErr );
                 }     
@@ -246,4 +253,18 @@
     return iOriginalSize;
     }
 
+// -----------------------------------------------------------------------------
+// CThumbnailImageDecoder3::LeaveIfCorruptL()
+// Leave is image is corrupted
+// -----------------------------------------------------------------------------
+//
+void CThumbnailImageDecoderv3::LeaveIfCorruptL(const TInt aError )
+    {
+    //no sense to try other codecs if image is corrupted
+    if( aError == KErrCorrupt || aError == KErrUnderflow)
+        {
+        User::Leave( aError );
+        }
+    }
+
 //End of file