diff options
author | Julien Isorce | 2011-12-13 07:52:26 -0600 |
---|---|---|
committer | Nikhil Devshatwar | 2013-05-17 04:40:49 -0500 |
commit | 063d7b92a4e315718b66e2214e474b02ef48912e (patch) | |
tree | 6deee361a095135315c80fe84bcf9665bc13edc3 | |
parent | a2e64fa16e94e65bfeb80a23afe7e3193c212575 (diff) | |
download | gst-plugins-ugly0-10-063d7b92a4e315718b66e2214e474b02ef48912e.tar.gz gst-plugins-ugly0-10-063d7b92a4e315718b66e2214e474b02ef48912e.tar.xz gst-plugins-ugly0-10-063d7b92a4e315718b66e2214e474b02ef48912e.zip |
a52dec: Check that the a52_state is correctly initialized
-rw-r--r-- | ext/a52dec/gsta52dec.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/ext/a52dec/gsta52dec.c b/ext/a52dec/gsta52dec.c index 5c7e4626..83c3f5f9 100644 --- a/ext/a52dec/gsta52dec.c +++ b/ext/a52dec/gsta52dec.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * SECTION:element-a52dec | 21 | * SECTION:element-a52dec |
22 | * | 22 | * |
23 | * Dolby Digital (AC-3) audio decoder. | 23 | * Dolby Digital (AC-3) audio decoder. |
24 | * | 24 | * |
25 | * <refsect2> | 25 | * <refsect2> |
26 | * <title>Example launch line</title> | 26 | * <title>Example launch line</title> |
27 | * |[ | 27 | * |[ |
@@ -171,7 +171,7 @@ gst_a52dec_class_init (GstA52DecClass * klass) | |||
171 | * | 171 | * |
172 | * Force a particular output channel configuration from the decoder. By default, | 172 | * Force a particular output channel configuration from the decoder. By default, |
173 | * the channel downmix (if any) is chosen automatically based on the downstream | 173 | * the channel downmix (if any) is chosen automatically based on the downstream |
174 | * capabilities of the pipeline. | 174 | * capabilities of the pipeline. |
175 | */ | 175 | */ |
176 | g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE, | 176 | g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE, |
177 | g_param_spec_enum ("mode", "Decoder Mode", "Decoding Mode (default 3f2r)", | 177 | g_param_spec_enum ("mode", "Decoder Mode", "Decoding Mode (default 3f2r)", |
@@ -229,6 +229,9 @@ gst_a52dec_init (GstA52Dec * a52dec, GstA52DecClass * g_class) | |||
229 | a52dec->request_channels = A52_CHANNEL; | 229 | a52dec->request_channels = A52_CHANNEL; |
230 | a52dec->dynamic_range_compression = FALSE; | 230 | a52dec->dynamic_range_compression = FALSE; |
231 | 231 | ||
232 | a52dec->state = NULL; | ||
233 | a52dec->samples = NULL; | ||
234 | |||
232 | gst_segment_init (&a52dec->segment, GST_FORMAT_UNDEFINED); | 235 | gst_segment_init (&a52dec->segment, GST_FORMAT_UNDEFINED); |
233 | } | 236 | } |
234 | 237 | ||
@@ -390,6 +393,7 @@ gst_a52dec_push (GstA52Dec * a52dec, | |||
390 | samples[c * 256 + n]; | 393 | samples[c * 256 + n]; |
391 | } | 394 | } |
392 | } | 395 | } |
396 | |||
393 | GST_BUFFER_TIMESTAMP (buf) = timestamp; | 397 | GST_BUFFER_TIMESTAMP (buf) = timestamp; |
394 | GST_BUFFER_DURATION (buf) = 256 * GST_SECOND / a52dec->sample_rate; | 398 | GST_BUFFER_DURATION (buf) = 256 * GST_SECOND / a52dec->sample_rate; |
395 | 399 | ||
@@ -566,8 +570,8 @@ gst_a52dec_handle_frame (GstA52Dec * a52dec, guint8 * data, | |||
566 | } | 570 | } |
567 | 571 | ||
568 | /* If we haven't had an explicit number of channels chosen through properties | 572 | /* If we haven't had an explicit number of channels chosen through properties |
569 | * at this point, choose what to downmix to now, based on what the peer will | 573 | * at this point, choose what to downmix to now, based on what the peer will |
570 | * accept - this allows a52dec to do downmixing in preference to a | 574 | * accept - this allows a52dec to do downmixing in preference to a |
571 | * downstream element such as audioconvert. | 575 | * downstream element such as audioconvert. |
572 | */ | 576 | */ |
573 | if (a52dec->request_channels != A52_CHANNEL) { | 577 | if (a52dec->request_channels != A52_CHANNEL) { |
@@ -591,13 +595,13 @@ gst_a52dec_handle_frame (GstA52Dec * a52dec, guint8 * data, | |||
591 | A52_3F2R | A52_LFE, | 595 | A52_3F2R | A52_LFE, |
592 | }; | 596 | }; |
593 | 597 | ||
594 | /* Prefer the original number of channels, but fixate to something | 598 | /* Prefer the original number of channels, but fixate to something |
595 | * preferred (first in the caps) downstream if possible. | 599 | * preferred (first in the caps) downstream if possible. |
596 | */ | 600 | */ |
597 | gst_structure_fixate_field_nearest_int (structure, "channels", | 601 | gst_structure_fixate_field_nearest_int (structure, "channels", |
598 | flags ? gst_a52dec_channels (flags, NULL) : 6); | 602 | flags ? gst_a52dec_channels (flags, NULL) : 6); |
599 | gst_structure_get_int (structure, "channels", &channels); | 603 | if (gst_structure_get_int (structure, "channels", &channels) |
600 | if (channels <= 6) | 604 | && channels <= 6) |
601 | flags = a52_channels[channels - 1]; | 605 | flags = a52_channels[channels - 1]; |
602 | else | 606 | else |
603 | flags = a52_channels[5]; | 607 | flags = a52_channels[5]; |
@@ -781,10 +785,10 @@ gst_a52dec_chain_raw (GstPad * pad, GstBuffer * buf) | |||
781 | if (!a52dec->sent_segment) { | 785 | if (!a52dec->sent_segment) { |
782 | GstSegment segment; | 786 | GstSegment segment; |
783 | 787 | ||
784 | /* Create a basic segment. Usually, we'll get a new-segment sent by | 788 | /* Create a basic segment. Usually, we'll get a new-segment sent by |
785 | * another element that will know more information (a demuxer). If we're | 789 | * another element that will know more information (a demuxer). If we're |
786 | * just looking at a raw AC3 stream, we won't - so we need to send one | 790 | * just looking at a raw AC3 stream, we won't - so we need to send one |
787 | * here, but we don't know much info, so just send a minimal TIME | 791 | * here, but we don't know much info, so just send a minimal TIME |
788 | * new-segment event | 792 | * new-segment event |
789 | */ | 793 | */ |
790 | gst_segment_init (&segment, GST_FORMAT_TIME); | 794 | gst_segment_init (&segment, GST_FORMAT_TIME); |
@@ -870,6 +874,12 @@ gst_a52dec_change_state (GstElement * element, GstStateChange transition) | |||
870 | 874 | ||
871 | klass = GST_A52DEC_CLASS (G_OBJECT_GET_CLASS (a52dec)); | 875 | klass = GST_A52DEC_CLASS (G_OBJECT_GET_CLASS (a52dec)); |
872 | a52dec->state = a52_init (klass->a52_cpuflags); | 876 | a52dec->state = a52_init (klass->a52_cpuflags); |
877 | |||
878 | if (!a52dec->state) { | ||
879 | GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL), | ||
880 | ("Failed to initialize a52 state")); | ||
881 | ret = GST_STATE_CHANGE_FAILURE; | ||
882 | } | ||
873 | break; | 883 | break; |
874 | } | 884 | } |
875 | case GST_STATE_CHANGE_READY_TO_PAUSED: | 885 | case GST_STATE_CHANGE_READY_TO_PAUSED: |
@@ -905,8 +915,10 @@ gst_a52dec_change_state (GstElement * element, GstStateChange transition) | |||
905 | clear_queued (a52dec); | 915 | clear_queued (a52dec); |
906 | break; | 916 | break; |
907 | case GST_STATE_CHANGE_READY_TO_NULL: | 917 | case GST_STATE_CHANGE_READY_TO_NULL: |
908 | a52_free (a52dec->state); | 918 | if (a52dec->state) { |
909 | a52dec->state = NULL; | 919 | a52_free (a52dec->state); |
920 | a52dec->state = NULL; | ||
921 | } | ||
910 | break; | 922 | break; |
911 | default: | 923 | default: |
912 | break; | 924 | break; |