theoraenc: refuse to get to READY if the encoder was disabled
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Fri, 4 Nov 2011 11:10:46 +0000 (11:10 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 7 Nov 2011 12:27:11 +0000 (12:27 +0000)
https://bugzilla.gnome.org/show_bug.cgi?id=663391

ext/theora/gsttheoraenc.c

index cae79db..b7cd8ae 100644 (file)
@@ -1405,11 +1405,19 @@ theora_enc_change_state (GstElement * element, GstStateChange transition)
 {
   GstTheoraEnc *enc;
   GstStateChangeReturn ret;
+  th_enc_ctx *th_ctx;
 
   enc = GST_THEORA_ENC (element);
 
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
+      th_ctx = dummy_encode_ctx ();
+      if (!th_ctx) {
+        GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL),
+            ("libtheora has been compiled with the encoder disabled"));
+        return GST_STATE_CHANGE_FAILURE;
+      }
+      th_encode_free (th_ctx);
       break;
     case GST_STATE_CHANGE_READY_TO_PAUSED:
       GST_DEBUG_OBJECT (enc, "READY->PAUSED Initing theora state");