csc: handle Gscaler errors
authorGreg Hackmann <ghackmann@google.com>
Mon, 10 Dec 2012 23:28:45 +0000 (15:28 -0800)
committerGreg Hackmann <ghackmann@google.com>
Tue, 8 Jan 2013 23:07:42 +0000 (15:07 -0800)
Change-Id: I75f0d0966e9f7ef10068645df0f41fa6b837c517
Signed-off-by: Greg Hackmann <ghackmann@google.com>
libcsc/csc.c

index 409391acc20ceb3a4e1d99c9c30636609790f194..ddb4541646eea50dcdbb9875be1611529b7d0f1a 100644 (file)
@@ -363,8 +363,7 @@ static CSC_ERRORCODE csc_init_hw(
     if (csc_handle->csc_method == CSC_METHOD_HW) {
         if (csc_handle->csc_hw_handle == NULL) {
             ALOGE("%s:: CSC_METHOD_HW can't open HW", __func__);
-            free(csc_handle);
-            csc_handle = NULL;
+            ret = CSC_Error;
         }
     }
 
@@ -711,11 +710,19 @@ CSC_ERRORCODE csc_convert(
         return CSC_ErrorNotInit;
 
     if ((csc_handle->csc_method == CSC_METHOD_HW) &&
-        (csc_handle->csc_hw_handle == NULL))
-        csc_init_hw(handle);
+        (csc_handle->csc_hw_handle == NULL)) {
+        ret = csc_init_hw(handle);
+        if (ret != CSC_ErrorNone)
+            return ret;
+    }
+
+    ret = csc_set_format(csc_handle);
+    if (ret != CSC_ErrorNone)
+        return ret;
 
-    csc_set_format(csc_handle);
-    csc_set_buffer(csc_handle);
+    ret = csc_set_buffer(csc_handle);
+    if (ret != CSC_ErrorNone)
+        return ret;
 
     if (csc_handle->csc_method == CSC_METHOD_HW)
         ret = conv_hw(csc_handle);