Skip to content

Commit

Permalink
video{en,de}coder: Call reset() before the start() vfunc
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sdroege committed Dec 22, 2014
1 parent aae6400 commit 87d6c26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions gst-libs/gst/video/gstvideodecoder.c
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions gst-libs/gst/video/gstvideoencoder.c
Expand Up @@ -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;
Expand Down

0 comments on commit 87d6c26

Please sign in to comment.