From 63986edca4868fc9bd04b46a1a3c19583fa35e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timmy=20Sj=C3=B6stedt?= Date: Fri, 27 May 2016 15:41:14 +0200 Subject: [PATCH] Make libmad decoder run in a thread --- rwengine/src/audio/MADStream.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rwengine/src/audio/MADStream.cpp b/rwengine/src/audio/MADStream.cpp index 6eef5e8f..7f064750 100644 --- a/rwengine/src/audio/MADStream.cpp +++ b/rwengine/src/audio/MADStream.cpp @@ -1,5 +1,7 @@ #include "audio/MADStream.hpp" +#include + inline signed int MADStream::scale(mad_fixed_t sample) { /* round */ @@ -144,7 +146,9 @@ bool MADStream::openFromFile(const std::string& loc) mad_decoder_init(&mDecoder, this, ms_input, ms_header, 0, ms_output, ms_error, 0); - mad_decoder_run(&mDecoder, MAD_DECODER_MODE_SYNC); + new std::thread([&] () { + mad_decoder_run(&mDecoder, MAD_DECODER_MODE_SYNC); + }); this->initialize(2, mMadSampleRate);