summaryrefslogtreecommitdiffstats
path: root/src/ModPlugin.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-25 18:21:12 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-25 18:21:12 +0100
commit887d270a8327da46a89d8e5375f172db778f0ff9 (patch)
tree449d2f0c39ea121490e013d9a9ab221ccdcdd5a2 /src/ModPlugin.h
parentf9e0a5c8eef355e14e276a7456ca020a11f24924 (diff)
downloaddabmod-887d270a8327da46a89d8e5375f172db778f0ff9.tar.gz
dabmod-887d270a8327da46a89d8e5375f172db778f0ff9.tar.bz2
dabmod-887d270a8327da46a89d8e5375f172db778f0ff9.zip
Fix race condition for PipelinedModCodec thread startup
The thread could start before the vtable containing the subclass function is ready, leading to a crash because the thread calls a pure virtual function.
Diffstat (limited to 'src/ModPlugin.h')
-rw-r--r--src/ModPlugin.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ModPlugin.h b/src/ModPlugin.h
index f3a8e2a..d3aa780 100644
--- a/src/ModPlugin.h
+++ b/src/ModPlugin.h
@@ -83,15 +83,20 @@ public:
virtual const char* name() = 0;
protected:
- void process_thread(void);
+ // Once the instance implementing PipelinedModCodec has been constructed,
+ // it must call start_pipeline_thread()
+ void start_pipeline_thread(void);
virtual int internal_process(Buffer* const dataIn, Buffer* dataOut) = 0;
+private:
+ size_t m_number_of_runs;
+
ThreadsafeQueue<std::shared_ptr<Buffer> > m_input_queue;
ThreadsafeQueue<std::shared_ptr<Buffer> > m_output_queue;
std::atomic<bool> m_running;
- size_t m_number_of_runs;
std::thread m_thread;
+ void process_thread(void);
};