Message ID | 1478913810-14063-2-git-send-email-cus@passwd.hu |
---|---|
State | Accepted |
Commit | e20e9b9033b75fac32a4a3bc2cdd3fcc3cedb33a |
Headers | show |
On 11/12/2016 02:23 AM, Marton Balint wrote: > Signed-off-by: Marton Balint <cus@passwd.hu> > --- > libavformat/fifo.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/libavformat/fifo.c b/libavformat/fifo.c > index 15435fe..8f525e5 100644 > --- a/libavformat/fifo.c > +++ b/libavformat/fifo.c > @@ -73,6 +73,7 @@ typedef struct FifoContext { > int restart_with_keyframe; > > pthread_mutex_t overflow_flag_lock; > + int overflow_flag_lock_initialized; > /* Value > 0 signals queue overflow */ > volatile uint8_t overflow_flag; > > @@ -515,6 +516,7 @@ static int fifo_init(AVFormatContext *avf) > ret = pthread_mutex_init(&fifo->overflow_flag_lock, NULL); > if (ret < 0) > return AVERROR(ret); > + fifo->overflow_flag_lock_initialized = 1; > > return 0; > } > @@ -601,7 +603,8 @@ static void fifo_deinit(AVFormatContext *avf) > av_dict_free(&fifo->format_options); > avformat_free_context(fifo->avf); > av_thread_message_queue_free(&fifo->queue); > - pthread_mutex_destroy(&fifo->overflow_flag_lock); > + if (fifo->overflow_flag_lock_initialized) > + pthread_mutex_destroy(&fifo->overflow_flag_lock); > } > > #define OFFSET(x) offsetof(FifoContext, x) LGTM, thanks! :) Reviewed-by: jsebechlebsky
On Sat, 12 Nov 2016, Jan Sebechlebsky wrote: > On 11/12/2016 02:23 AM, Marton Balint wrote: > >> Signed-off-by: Marton Balint <cus@passwd.hu> >> --- >> libavformat/fifo.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/libavformat/fifo.c b/libavformat/fifo.c >> index 15435fe..8f525e5 100644 >> --- a/libavformat/fifo.c >> +++ b/libavformat/fifo.c >> @@ -73,6 +73,7 @@ typedef struct FifoContext { >> int restart_with_keyframe; >> >> pthread_mutex_t overflow_flag_lock; >> + int overflow_flag_lock_initialized; >> /* Value > 0 signals queue overflow */ >> volatile uint8_t overflow_flag; >> >> @@ -515,6 +516,7 @@ static int fifo_init(AVFormatContext *avf) >> ret = pthread_mutex_init(&fifo->overflow_flag_lock, NULL); >> if (ret < 0) >> return AVERROR(ret); >> + fifo->overflow_flag_lock_initialized = 1; >> >> return 0; >> } >> @@ -601,7 +603,8 @@ static void fifo_deinit(AVFormatContext *avf) >> av_dict_free(&fifo->format_options); >> avformat_free_context(fifo->avf); >> av_thread_message_queue_free(&fifo->queue); >> - pthread_mutex_destroy(&fifo->overflow_flag_lock); >> + if (fifo->overflow_flag_lock_initialized) >> + pthread_mutex_destroy(&fifo->overflow_flag_lock); >> } >> >> #define OFFSET(x) offsetof(FifoContext, x) > LGTM, thanks! :) > > Reviewed-by: jsebechlebsky > Applied, thanks. Marton
diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 15435fe..8f525e5 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -73,6 +73,7 @@ typedef struct FifoContext { int restart_with_keyframe; pthread_mutex_t overflow_flag_lock; + int overflow_flag_lock_initialized; /* Value > 0 signals queue overflow */ volatile uint8_t overflow_flag; @@ -515,6 +516,7 @@ static int fifo_init(AVFormatContext *avf) ret = pthread_mutex_init(&fifo->overflow_flag_lock, NULL); if (ret < 0) return AVERROR(ret); + fifo->overflow_flag_lock_initialized = 1; return 0; } @@ -601,7 +603,8 @@ static void fifo_deinit(AVFormatContext *avf) av_dict_free(&fifo->format_options); avformat_free_context(fifo->avf); av_thread_message_queue_free(&fifo->queue); - pthread_mutex_destroy(&fifo->overflow_flag_lock); + if (fifo->overflow_flag_lock_initialized) + pthread_mutex_destroy(&fifo->overflow_flag_lock); } #define OFFSET(x) offsetof(FifoContext, x)
Signed-off-by: Marton Balint <cus@passwd.hu> --- libavformat/fifo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)