basevideoencoder: handle failures in start() and stop()
authorAlessandro Decina <alessandro.decina@collabora.co.uk>
Mon, 31 Oct 2011 10:36:06 +0000 (11:36 +0100)
committerAlessandro Decina <alessandro.d@gmail.com>
Mon, 31 Oct 2011 10:38:58 +0000 (11:38 +0100)
gst-libs/gst/video/gstbasevideoencoder.c

index b04cf7710bc344ef619785611517df3381fe8aed..70c20b275ad3a7e439c000b26b42691926d3dcf5 100644 (file)
@@ -799,7 +799,8 @@ gst_base_video_encoder_change_state (GstElement * element,
       gst_base_video_encoder_reset (base_video_encoder);
       gst_base_video_encoder_reset (base_video_encoder);
       if (base_video_encoder_class->start) {
-        base_video_encoder_class->start (base_video_encoder);
+        if (!base_video_encoder_class->start (base_video_encoder))
+          goto start_error;
       }
       break;
     default:
@@ -812,7 +813,8 @@ gst_base_video_encoder_change_state (GstElement * element,
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       gst_base_video_encoder_reset (base_video_encoder);
       if (base_video_encoder_class->stop) {
-        base_video_encoder_class->stop (base_video_encoder);
+        if (!base_video_encoder_class->stop (base_video_encoder))
+          goto stop_error;
       }
       break;
     default:
@@ -820,6 +822,14 @@ gst_base_video_encoder_change_state (GstElement * element,
   }
 
   return ret;
+
+start_error:
+  GST_WARNING_OBJECT (base_video_encoder, "failed to start");
+  return GST_STATE_CHANGE_FAILURE;
+
+stop_error:
+  GST_WARNING_OBJECT (base_video_encoder, "failed to stop");
+  return GST_STATE_CHANGE_FAILURE;
 }
 
 /**