[ML-API] add log messages
authorHyoung Joo Ahn <hello.ahn@samsung.com>
Thu, 4 Feb 2021 03:02:27 +0000 (12:02 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 4 Feb 2021 07:22:21 +0000 (16:22 +0900)
The additional log messages are required because returning the error code `ML_ERROR_STREAMS_PIPE` gives very little information for the abnormal situation.

Signed-off-by: Hyoung Joo Ahn <hello.ahn@samsung.com>
api/capi/src/nnstreamer-capi-pipeline.c
api/capi/src/nnstreamer-capi-single.c

index 7393e0b..5eea665 100644 (file)
@@ -716,6 +716,7 @@ ml_pipeline_destroy (ml_pipeline_h pipe)
       scret = gst_element_set_state (p->element, GST_STATE_PAUSED);
       if (scret == GST_STATE_CHANGE_FAILURE) {
         g_mutex_unlock (&p->lock);
+        ml_loge ("Failed to wait until state changed PLAYING to PAUSED. For the detail, please check the GStreamer log messages.");
         return ML_ERROR_STREAMS_PIPE;
       }
     }
@@ -736,6 +737,7 @@ ml_pipeline_destroy (ml_pipeline_h pipe)
     scret = gst_element_set_state (p->element, GST_STATE_NULL);
     if (scret != GST_STATE_CHANGE_SUCCESS) {
       g_mutex_unlock (&p->lock);
+      ml_loge ("Failed to wait until state changed to NULL(STOP). For the detail, please check the GStreamer log messages.");
       return ML_ERROR_STREAMS_PIPE;
     }
 
@@ -781,8 +783,10 @@ ml_pipeline_get_state (ml_pipeline_h pipe, ml_pipeline_state_e * state)
   scret = gst_element_get_state (p->element, &_state, NULL, GST_MSECOND);       /* Do it within 1ms! */
   g_mutex_unlock (&p->lock);
 
-  if (scret == GST_STATE_CHANGE_FAILURE)
+  if (scret == GST_STATE_CHANGE_FAILURE) {
+    ml_loge ("Failed to get the state of the pipeline. For the detail, please check the GStreamer log messages.");
     return ML_ERROR_STREAMS_PIPE;
+  }
 
   *state = (ml_pipeline_state_e) _state;
   return ML_ERROR_NONE;
@@ -825,8 +829,10 @@ ml_pipeline_start (ml_pipeline_h pipe)
   }
 
   scret = gst_element_set_state (p->element, GST_STATE_PLAYING);
-  if (scret == GST_STATE_CHANGE_FAILURE)
+  if (scret == GST_STATE_CHANGE_FAILURE) {
+    ml_loge ("Failed to set the state of the pipeline to PLAYING. For the detail, please check the GStreamer log messages.");
     status = ML_ERROR_STREAMS_PIPE;
+  }
 
 done:
   g_mutex_unlock (&p->lock);
@@ -851,8 +857,10 @@ ml_pipeline_stop (ml_pipeline_h pipe)
   scret = gst_element_set_state (p->element, GST_STATE_PAUSED);
   g_mutex_unlock (&p->lock);
 
-  if (scret == GST_STATE_CHANGE_FAILURE)
+  if (scret == GST_STATE_CHANGE_FAILURE) {
+    ml_loge ("Failed to set the state of the pipeline to PAUSED. For the detail, please check the GStreamer log messages.");
     return ML_ERROR_STREAMS_PIPE;
+  }
 
   return ML_ERROR_NONE;
 }
@@ -1009,6 +1017,7 @@ ml_pipeline_src_parse_tensors_info (ml_pipeline_element * elem)
     elem->size = 0;
 
     if (elem->src == NULL) {
+      ml_loge ("Failed to get the src pad of the element[%s]. For the detail, please check the GStreamer log messages.", elem->name);
       ret = ML_ERROR_STREAMS_PIPE;
     } else {
       GstCaps *caps = gst_pad_get_allowed_caps (elem->src);
index f2bce73..9cd83e1 100644 (file)
@@ -230,6 +230,7 @@ __invoke (ml_single * single_h)
   /** invoke the thread */
   if (!single_h->klass->invoke (single_h->filter, in_tensors, out_tensors,
           single_h->free_output)) {
+    ml_loge ("Failed to invoke the tensors.");
     status = ML_ERROR_STREAMS_PIPE;
     if (single_h->free_output)
       ml_tensors_data_destroy (single_h->output);
@@ -752,6 +753,7 @@ ml_single_open_custom (ml_single_h * single, ml_single_preset * info)
 
   /* 4. Start the nnfw to get inout configurations if needed */
   if (!single_h->klass->start (single_h->filter)) {
+    ml_loge ("Failed to start NNFW to get inout configurations.");
     status = ML_ERROR_STREAMS_PIPE;
     goto error;
   }