From 9d4f72f2faca7ee4793870e52d62d99a87b47f36 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 4 Sep 2009 14:06:09 +0200 Subject: [PATCH] theora: Add assertions that functions don't fail Some functions in libtheora can return an error, but that error cannot ever happen inside theoraenc. In those cases assert that it doesn't. --- ext/theora/theoraenc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/theora/theoraenc.c b/ext/theora/theoraenc.c index fec96b14a5..f7ab79cf8a 100644 --- a/ext/theora/theoraenc.c +++ b/ext/theora/theoraenc.c @@ -351,8 +351,12 @@ theora_enc_finalize (GObject * object) static void theora_enc_reset (GstTheoraEnc * enc) { + int result; + theora_clear (&enc->state); - theora_encode_init (&enc->state, &enc->info); + result = theora_encode_init (&enc->state, &enc->info); + /* We ensure this function cannot fail. */ + g_assert (result == 0); #ifdef TH_ENCCTL_SET_SPLEVEL theora_control (&enc->state, TH_ENCCTL_SET_SPLEVEL, &enc->speed_level, sizeof (enc->speed_level)); @@ -1062,6 +1066,8 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer) } res = theora_encode_YUVin (&enc->state, &yuv); + /* none of the failure cases can happen here */ + g_assert (res == 0); ret = GST_FLOW_OK; while (theora_encode_packetout (&enc->state, 0, &op)) {