video{en,de}coder: Call reset() before the start() vfunc

This makes sure that the element is in the same state before start() is called
the very first time and every future call after the element was used already.

Also it ensure that we always have a clean state before start(), cleaned the
same way in every case.
This commit is contained in:
Sebastian Dröge 2014-12-22 11:38:20 +01:00
parent aae6400962
commit 87d6c265a8
2 changed files with 8 additions and 6 deletions

View file

@ -2275,12 +2275,13 @@ gst_video_decoder_change_state (GstElement * element, GstStateChange transition)
goto open_failed;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
/* Initialize device/library if needed */
if (decoder_class->start && !decoder_class->start (decoder))
goto start_failed;
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
gst_video_decoder_reset (decoder, TRUE, TRUE);
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
/* Initialize device/library if needed */
if (decoder_class->start && !decoder_class->start (decoder))
goto start_failed;
break;
default:
break;

View file

@ -1411,12 +1411,13 @@ gst_video_encoder_change_state (GstElement * element, GstStateChange transition)
goto open_failed;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
/* Initialize device/library if needed */
if (encoder_class->start && !encoder_class->start (encoder))
goto start_failed;
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
gst_video_encoder_reset (encoder, TRUE);
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
/* Initialize device/library if needed */
if (encoder_class->start && !encoder_class->start (encoder))
goto start_failed;
break;
default:
break;