improve error cases
[platform/adaptation/emulator/gst-plugins-emulator.git] / src / gstmarudevice.c
index 3e00b74..8de3c5b 100644 (file)
@@ -153,20 +153,20 @@ gst_maru_avcodec_open (CodecContext *ctx,
 int
 gst_maru_avcodec_close (CodecContext *ctx, CodecDevice *dev)
 {
-  int ret;
-
-  GST_DEBUG ("close %d of context", ctx->index);
+  int ret = 0;
 
-  if (ctx && ctx->index == 0) {
-    GST_INFO ("context is not opened yet or context before %d", ctx->index);
+  if (!ctx || (ctx->index == 0)) {
+    GST_INFO ("context is null or closed before");
     return -1;
   }
 
-  if (dev && dev->fd < 0) {
-    GST_INFO ("fd is not opened yet or closed before %d", dev->fd);
+  if (!dev || (dev->fd < 0)) {
+    GST_INFO ("dev is null or fd is closed before");
     return -1;
   }
 
+  GST_DEBUG ("close %d of context", ctx->index);
+
   g_mutex_lock (&gst_avcodec_mutex);
   interface->deinit (ctx, dev);
   g_mutex_unlock (&gst_avcodec_mutex);