a52dec: Check that the a52_state is correctly initialized

This commit is contained in:
Julien Isorce 2011-12-13 14:52:26 +01:00 committed by Sebastian Dröge
parent da9f20eceb
commit cdf8d0f6b2

View file

@ -229,6 +229,9 @@ gst_a52dec_init (GstA52Dec * a52dec, GstA52DecClass * g_class)
a52dec->request_channels = A52_CHANNEL; a52dec->request_channels = A52_CHANNEL;
a52dec->dynamic_range_compression = FALSE; a52dec->dynamic_range_compression = FALSE;
a52dec->state = NULL;
a52dec->samples = NULL;
gst_segment_init (&a52dec->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&a52dec->segment, GST_FORMAT_UNDEFINED);
} }
@ -390,6 +393,7 @@ gst_a52dec_push (GstA52Dec * a52dec,
samples[c * 256 + n]; samples[c * 256 + n];
} }
} }
GST_BUFFER_TIMESTAMP (buf) = timestamp; GST_BUFFER_TIMESTAMP (buf) = timestamp;
GST_BUFFER_DURATION (buf) = 256 * GST_SECOND / a52dec->sample_rate; GST_BUFFER_DURATION (buf) = 256 * GST_SECOND / a52dec->sample_rate;
@ -596,8 +600,8 @@ gst_a52dec_handle_frame (GstA52Dec * a52dec, guint8 * data,
*/ */
gst_structure_fixate_field_nearest_int (structure, "channels", gst_structure_fixate_field_nearest_int (structure, "channels",
flags ? gst_a52dec_channels (flags, NULL) : 6); flags ? gst_a52dec_channels (flags, NULL) : 6);
gst_structure_get_int (structure, "channels", &channels); if (gst_structure_get_int (structure, "channels", &channels)
if (channels <= 6) && channels <= 6)
flags = a52_channels[channels - 1]; flags = a52_channels[channels - 1];
else else
flags = a52_channels[5]; flags = a52_channels[5];
@ -870,6 +874,12 @@ gst_a52dec_change_state (GstElement * element, GstStateChange transition)
klass = GST_A52DEC_CLASS (G_OBJECT_GET_CLASS (a52dec)); klass = GST_A52DEC_CLASS (G_OBJECT_GET_CLASS (a52dec));
a52dec->state = a52_init (klass->a52_cpuflags); a52dec->state = a52_init (klass->a52_cpuflags);
if (!a52dec->state) {
GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL),
("Failed to initialize a52 state"));
ret = GST_STATE_CHANGE_FAILURE;
}
break; break;
} }
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
@ -905,8 +915,10 @@ gst_a52dec_change_state (GstElement * element, GstStateChange transition)
clear_queued (a52dec); clear_queued (a52dec);
break; break;
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
a52_free (a52dec->state); if (a52dec->state) {
a52dec->state = NULL; a52_free (a52dec->state);
a52dec->state = NULL;
}
break; break;
default: default:
break; break;