omx: log states as strings
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 15 Mar 2013 00:47:47 +0000 (00:47 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 15 Mar 2013 09:29:55 +0000 (09:29 +0000)
omx/gstomx.c
omx/gstomx.h

index 0309e37..692fb70 100644 (file)
@@ -218,8 +218,8 @@ gst_omx_component_handle_messages (GstOMXComponent * comp)
 
     switch (msg->type) {
       case GST_OMX_MESSAGE_STATE_SET:{
-        GST_INFO_OBJECT (comp->parent, "%s state change to %d finished",
-            comp->name, msg->content.state_set.state);
+        GST_INFO_OBJECT (comp->parent, "%s state change to %s finished",
+            comp->name, gst_omx_state_to_string (msg->content.state_set.state));
         comp->state = msg->content.state_set.state;
         if (comp->state == comp->pending_state)
           comp->pending_state = OMX_StateInvalid;
@@ -425,8 +425,9 @@ EventHandler (OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_EVENTTYPE eEvent,
           msg->type = GST_OMX_MESSAGE_STATE_SET;
           msg->content.state_set.state = nData2;
 
-          GST_DEBUG_OBJECT (comp->parent, "%s state change to %d finished",
-              comp->name, msg->content.state_set.state);
+          GST_DEBUG_OBJECT (comp->parent, "%s state change to %s finished",
+              comp->name,
+              gst_omx_state_to_string (msg->content.state_set.state));
 
           gst_omx_component_send_message (comp, msg);
           break;
@@ -2435,6 +2436,32 @@ gst_omx_error_to_string (OMX_ERRORTYPE err)
   }
 }
 
+const gchar *
+gst_omx_state_to_string (OMX_STATETYPE state)
+{
+  switch (state) {
+    case OMX_StateInvalid:
+      return "Invalid";
+    case OMX_StateLoaded:
+      return "Loaded";
+    case OMX_StateIdle:
+      return "Idle";
+    case OMX_StateExecuting:
+      return "Executing";
+    case OMX_StatePause:
+      return "Pause";
+    case OMX_StateWaitForResources:
+      return "WaitForResources";
+    default:
+      if (state >= OMX_StateKhronosExtensions)
+        return "KhronosExtensionState";
+      else if (state >= OMX_StateVendorStartUnused)
+        return "CustomVendorState";
+      break;
+  }
+  return "Unknown state";
+}
+
 #if defined(USE_OMX_TARGET_RPI)
 #define DEFAULT_HACKS (GST_OMX_HACK_NO_COMPONENT_ROLE)
 #else
index 1fd6008..0c0ba2c 100644 (file)
@@ -273,6 +273,7 @@ struct _GstOMXClassData {
 GKeyFile *        gst_omx_get_configuration (void);
 
 const gchar *     gst_omx_error_to_string (OMX_ERRORTYPE err);
+const gchar *     gst_omx_state_to_string (OMX_STATETYPE state);
 guint64           gst_omx_parse_hacks (gchar ** hacks);
 
 GstOMXCore *      gst_omx_core_acquire (const gchar * filename);