libhwjpeg: know earlier about thumbnail scaler

If thumbnail scaler is not available due to some problem with
configuration or file system, libhwjpeg handles the problem after
starting compression but we know that before compression. If it
is found before processing EXIF, we can gracefully handle the
exception.

Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
Change-Id: I7844216c672f7b3aafc790758088487a0a20a5b0
diff --git a/libhwjpeg/ExynosJpegEncoderForCamera.cpp b/libhwjpeg/ExynosJpegEncoderForCamera.cpp
index ed09cb8..272a577 100644
--- a/libhwjpeg/ExynosJpegEncoderForCamera.cpp
+++ b/libhwjpeg/ExynosJpegEncoderForCamera.cpp
@@ -373,6 +373,11 @@
             "Debugging information is not specified. Skipping writing APP4 marker");
     ALOGD("Given stream buffer size: %d bytes", *size);
 
+    if (!mThumbnailScaler->available() && (exifInfo != nullptr)) {
+        exifInfo->enableThumb = false;
+        ALOGW("Thumbnail scaler is not available. No thumbnail is embedded");
+    }
+
     CStopWatch stopwatch(true);
 
     if (!ProcessExif(jpeg_base, m_nStreamSize, exifInfo, appInfo))
diff --git a/libhwjpeg/LibScalerForJpeg.h b/libhwjpeg/LibScalerForJpeg.h
index 7753e04..f8914d7 100644
--- a/libhwjpeg/LibScalerForJpeg.h
+++ b/libhwjpeg/LibScalerForJpeg.h
@@ -38,6 +38,7 @@
     bool RunStream(int srcBuf[SCALER_MAX_PLANES], int srcLen[SCALER_MAX_PLANES], int dstBuf, size_t dstLen);
     bool RunStream(char *srcBuf[SCALER_MAX_PLANES], int srcLen[SCALER_MAX_PLANES], int dstBuf, size_t dstLen);
 
+    bool available() { return mDevice.mFd >= 0; }
 private:
     struct Device {
         int mFd;
diff --git a/libhwjpeg/ThumbnailScaler.h b/libhwjpeg/ThumbnailScaler.h
index a1a6a08..cb23365 100644
--- a/libhwjpeg/ThumbnailScaler.h
+++ b/libhwjpeg/ThumbnailScaler.h
@@ -16,6 +16,8 @@
     virtual bool RunStream(char *srcBuf[SCALER_MAX_PLANES], int srcLen[SCALER_MAX_PLANES], int dstBuf, size_t dstLen) = 0;
 
     static ThumbnailScaler *createInstance();
+
+    virtual bool available() { return false; }
 };
 
 #endif //__HARDWARE_EXYNOS_THUMBNAIL_SCALER_H__