Commit 2f0eaa68 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2

alsa: fix possible threading issue

An std::thread, ctor constructer, must be the last members in a class to be sure
that all previous members are initialized in class ctor before to run the thread
itself.
This may fixes random issues seen with others member accesses.

Change-Id: I7ceb0cf522236411f4a2faa34ff4f32eae0e4c13
Tuleap: #171
parent 131301b4
......@@ -36,20 +36,19 @@
namespace ring {
class AlsaThread {
public:
AlsaThread(AlsaLayer *alsa);
~AlsaThread();
void initAudioLayer();
void start();
bool isRunning() const;
private:
void run();
NON_COPYABLE(AlsaThread);
std::thread thread_;
AlsaLayer* alsa_;
std::atomic<bool> running_;
public:
AlsaThread(AlsaLayer *alsa);
~AlsaThread();
void initAudioLayer();
void start();
bool isRunning() const;
private:
NON_COPYABLE(AlsaThread);
void run();
AlsaLayer* alsa_;
std::atomic<bool> running_;
std::thread thread_;
};
AlsaThread::AlsaThread(AlsaLayer *alsa)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment