summaryrefslogtreecommitdiff
path: root/command/decoder.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2010-10-31 21:10:56 +0100
committerJochen Dolze <vdr@dolze.de>2010-10-31 21:10:56 +0100
commit7e2fb0f884b2269c32cb42867346ec3917c7e480 (patch)
tree6cc92fb8c92926aae5bdca25a020f41e2fdaed08 /command/decoder.cpp
parentbe98be7c5a9891b581cc46c45a8975ca16244752 (diff)
downloadvdr-plugin-markad-7e2fb0f884b2269c32cb42867346ec3917c7e480.tar.gz
vdr-plugin-markad-7e2fb0f884b2269c32cb42867346ec3917c7e480.tar.bz2
Fall back to single thread operation on libavcodec without pthreads
Diffstat (limited to 'command/decoder.cpp')
-rw-r--r--command/decoder.cpp24
1 files 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);