diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2014-09-30 11:35:12 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2014-10-14 09:30:06 +0200 |
commit | 24ad7f6e35213d78d03f3eee597c76071f2fb50e (patch) | |
tree | 9dce400035352e6c5b269a2ba8c877a3d2c4f257 | |
parent | 6eb201c120e697898de8508015fcdeaf615d1faf (diff) |
vp8enc/vp9enc: Protect the encoder with a mutex in all situations
-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 613ce8ada..3dad28344 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, |