ffmpeg: disable multithreading in favor of our own

Our renderer system is already heavily multithreaded and prioritized to keep the
main thread active. As a result, FFmpeg receives little benefits from being
multithreaded and is actually detrimental to our main thread as it hasn't been
prioritized to keep the main thread as active as possible.
This commit is contained in:
itsmattkc
2020-02-14 10:08:19 +11:00
parent d66425c324
commit 9de164cfba
2 changed files with 13 additions and 3 deletions
+9 -3
View File
@@ -47,7 +47,8 @@ FFmpegDecoder::FFmpegDecoder() :
scale_ctx_(nullptr),
pkt_(nullptr),
frame_(nullptr),
opts_(nullptr)
opts_(nullptr),
multithreading_(false)
{
}
@@ -125,8 +126,8 @@ bool FFmpegDecoder::Open()
return false;
}
// enable multithreading on decoding
error_code = av_dict_set(&opts_, "threads", "auto", 0);
// Set multithreading setting
error_code = av_dict_set(&opts_, "threads", multithreading_ ? "auto" : "1", 0);
// Handle failure to set multithreaded decoding
if (error_code < 0) {
@@ -524,6 +525,11 @@ bool FFmpegDecoder::SupportsAudio()
return true;
}
void FFmpegDecoder::SetMultithreading(bool e)
{
multithreading_ = e;
}
void FFmpegDecoder::ConformInternal(SwrContext* resampler, WaveOutput* output, const char* in_data, int in_sample_count)
{
// Determine how many samples the output will be