diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2014-09-30 11:35:12 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2014-09-30 11:35:42 +0300 |
commit | 23a3377b1efcd634b6ca531ba29445905df0ceda (patch) | |
tree | 207c952fa71916d44712938e58d84cb7e299c8db /ext | |
parent | df053c997cef3156403a52dd00ceea576f680344 (diff) |
vp8enc/vp9enc: Protect the encoder with a mutex in all situations
Diffstat (limited to 'ext')
-rw-r--r-- | ext/vpx/gstvp8enc.c | 7 | ||||
-rw-r--r-- | ext/vpx/gstvp9enc.c | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/ext/vpx/gstvp8enc.c b/ext/vpx/gstvp8enc.c index a83beef5c..ed0bee3bb 100644 --- a/ext/vpx/gstvp8enc.c +++ b/ext/vpx/gstvp8enc.c @@ -1512,10 +1512,13 @@ gst_vp8_enc_set_format (GstVideoEncoder * video_encoder, if (encoder->inited) { gst_vp8_enc_drain (video_encoder); + g_mutex_lock (&encoder->encoder_lock); vpx_codec_destroy (&encoder->encoder); + encoder->inited = FALSE; + } else { + g_mutex_lock (&encoder->encoder_lock); } - g_mutex_lock (&encoder->encoder_lock); encoder->cfg.g_profile = gst_vp8_enc_get_downstream_profile (encoder); /* Scale default bitrate to our size */ @@ -1888,11 +1891,11 @@ gst_vp8_enc_drain (GstVideoEncoder * video_encoder) g_mutex_lock (&encoder->encoder_lock); deadline = encoder->deadline; - g_mutex_unlock (&encoder->encoder_lock); status = vpx_codec_encode (&encoder->encoder, NULL, encoder->n_frames, 1, flags, deadline); + g_mutex_unlock (&encoder->encoder_lock); if (status != 0) { GST_ERROR_OBJECT (encoder, "encode returned %d %s", status, diff --git a/ext/vpx/gstvp9enc.c b/ext/vpx/gstvp9enc.c index c4c2c9d81..58c98c74e 100644 --- a/ext/vpx/gstvp9enc.c +++ b/ext/vpx/gstvp9enc.c @@ -1488,10 +1488,13 @@ gst_vp9_enc_set_format (GstVideoEncoder * video_encoder, if (encoder->inited) { gst_vp9_enc_drain (video_encoder); + g_mutex_lock (&encoder->encoder_lock); vpx_codec_destroy (&encoder->encoder); + encoder->inited = FALSE; + } else { + g_mutex_lock (&encoder->encoder_lock); } - g_mutex_lock (&encoder->encoder_lock); encoder->cfg.g_profile = gst_vp9_enc_get_downstream_profile (encoder); /* Scale default bitrate to our size */ @@ -1827,11 +1830,11 @@ gst_vp9_enc_drain (GstVideoEncoder * video_encoder) g_mutex_lock (&encoder->encoder_lock); deadline = encoder->deadline; - g_mutex_unlock (&encoder->encoder_lock); status = vpx_codec_encode (&encoder->encoder, NULL, encoder->n_frames, 1, flags, deadline); + g_mutex_unlock (&encoder->encoder_lock); if (status != 0) { GST_ERROR_OBJECT (encoder, "encode returned %d %s", status, |