vp8enc/vp9enc: Protect the encoder with a mutex in all situations

This commit is contained in:
Sebastian Dröge 2014-09-30 11:35:12 +03:00
parent df053c997c
commit 23a3377b1e
2 changed files with 10 additions and 4 deletions

View file

@ -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,

View file

@ -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,