From 7e2fb0f884b2269c32cb42867346ec3917c7e480 Mon Sep 17 00:00:00 2001 From: Jochen Dolze Date: Sun, 31 Oct 2010 21:10:56 +0100 Subject: Fall back to single thread operation on libavcodec without pthreads --- command/decoder.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/command/decoder.cpp b/command/decoder.cpp index 008686d..9b3fcca 100644 --- a/command/decoder.cpp +++ b/command/decoder.cpp @@ -326,7 +326,14 @@ cMarkAdDecoder::cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3, int Threa } else { - avcodec_thread_init(video_context,threadcount); + if (threadcount>1) + { + if (avcodec_thread_init(video_context,threadcount)==-1) + { + esyslog("cannot use %i threads, falling back to single thread operation",threadcount); + threadcount=1; + } + } } } } @@ -382,7 +389,7 @@ cMarkAdDecoder::~cMarkAdDecoder() } if (mp2_context) - { + { avcodec_close(mp2_context); av_free(mp2_context); } @@ -412,7 +419,18 @@ bool cMarkAdDecoder::Clear() video_context=dest; if (avcodec_open(video_context,video_codec)<0) ret=false; } - avcodec_thread_init(video_context,threadcount); + if (threadcount>1) + { + if (avcodec_thread_init(video_context,threadcount)==-1) + { + video_context->execute=avcodec_default_execute; + threadcount=1; + } + } + else + { + video_context->execute=avcodec_default_execute; + } } if (ac3_context) avcodec_flush_buffers(ac3_context); if (mp2_context) avcodec_flush_buffers(mp2_context); -- cgit v1.2.3