From a6b3e01a27a60bcd24470a4f4a2f9edea647901a Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Tue, 3 Feb 2015 09:52:21 -0800 Subject: [PATCH] Add mutex initialization in encoder This resolves the encoder crashes on windows. Change-Id: I159d79014cf9279751e403936ce1f84482ae82da --- vp9/vp9_cx_iface.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 312e3f1a6..251d2400b 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -743,6 +743,12 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx, if (priv->buffer_pool == NULL) return VPX_CODEC_MEM_ERROR; +#if CONFIG_MULTITHREAD + if (pthread_mutex_init(&priv->buffer_pool->pool_mutex, NULL)) { + return VPX_CODEC_MEM_ERROR; + } +#endif + if (ctx->config.enc) { // Update the reference to the config structure to an internal copy. priv->cfg = *ctx->config.enc; @@ -774,6 +780,9 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx, static vpx_codec_err_t encoder_destroy(vpx_codec_alg_priv_t *ctx) { free(ctx->cx_data); vp9_remove_compressor(ctx->cpi); +#if CONFIG_MULTITHREAD + pthread_mutex_destroy(&ctx->buffer_pool->pool_mutex); +#endif vpx_free(ctx->buffer_pool); vpx_free(ctx); return VPX_CODEC_OK; -- 2.40.0