summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2015-04-02 17:24:05 +0100
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2015-04-03 09:57:38 +0100
commitf529481b3da32d9414219784bcee4f042e1dc86c (patch)
tree46fa569b00e6e03db651f7823411a5566631e593
parentca5fd568624366942d3548003ddc49b7ac2a3ea6 (diff)
a52dec: fix race in liba52dec lookup table initialization
a52_init initializes the IMDCT global state as well as creating a new state. When two A52 decoders are created (eg, when two AC3 tracks are contained in a video), calls to a52_init may happen at the same time, and the IMDCT initialization is not reentrant. https://bugzilla.gnome.org/show_bug.cgi?id=746781
-rw-r--r--ext/a52dec/gsta52dec.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/a52dec/gsta52dec.c b/ext/a52dec/gsta52dec.c
index f62ab4c7..b987482d 100644
--- a/ext/a52dec/gsta52dec.c
+++ b/ext/a52dec/gsta52dec.c
@@ -242,10 +242,12 @@ gst_a52dec_start (GstAudioDecoder * dec)
{
GstA52Dec *a52dec = GST_A52DEC (dec);
GstA52DecClass *klass;
+ static GMutex init_mutex;
GST_DEBUG_OBJECT (dec, "start");
klass = GST_A52DEC_CLASS (G_OBJECT_GET_CLASS (a52dec));
+ g_mutex_lock (&init_mutex);
#if defined(A52_ACCEL_DETECT)
a52dec->state = a52_init ();
/* This line is just to avoid being accused of not using klass */
@@ -253,6 +255,7 @@ gst_a52dec_start (GstAudioDecoder * dec)
#else
a52dec->state = a52_init (klass->a52_cpuflags);
#endif
+ g_mutex_unlock (&init_mutex);
if (!a52dec->state) {
GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), LIBRARY, INIT, (NULL),