videodecoder: avoid crash when getting duration

Check that we have a valid output_state before attempting to use it to calculate
the duration of a buffer. It is possible that we don't have a state yet, for
example when we are dropping the first buffers.
This commit is contained in:
Wim Taymans 2012-06-27 16:38:38 +02:00
parent 43e94eea98
commit c68683c15f

View file

@ -2342,6 +2342,11 @@ gst_video_decoder_get_frame_duration (GstVideoDecoder * decoder,
{ {
GstVideoCodecState *state = decoder->priv->output_state; GstVideoCodecState *state = decoder->priv->output_state;
/* it's possible that we don't have a state yet when we are dropping the
* initial buffers */
if (state == NULL)
return GST_CLOCK_TIME_NONE;
if (state->info.fps_d == 0 || state->info.fps_n == 0) { if (state->info.fps_d == 0 || state->info.fps_n == 0) {
return GST_CLOCK_TIME_NONE; return GST_CLOCK_TIME_NONE;
} }