Worker: fix unitialized status

This commit is contained in:
Louis-Joseph Fournier 2016-01-12 22:11:20 +01:00
parent 27f93603ab
commit 91475dca78

View file

@ -56,6 +56,7 @@ static void blank_prevent(bool prevent)
TunerWorker::TunerWorker() : TunerWorker::TunerWorker() :
running(false), running(false),
playing(false),
quit(false), quit(false),
la_to_update(0), la_to_update(0),
temperament_to_update(0), // update the first time in every cases temperament_to_update(0), // update the first time in every cases
@ -164,6 +165,8 @@ void TunerWorker::Entry()
if (running || playing) blank_prevent(true); if (running || playing) blank_prevent(true);
while (1) { while (1) {
mutex.lock();
// free pulseaudio if not running // free pulseaudio if not running
if (!running && p_record) { if (!running && p_record) {
pa_simple_free(p_record); pa_simple_free(p_record);
@ -175,7 +178,6 @@ void TunerWorker::Entry()
} }
// wait for running // wait for running
mutex.lock();
if (!running && !playing) { if (!running && !playing) {
blank_prevent(false); blank_prevent(false);
while (!running && !playing && !quit) { while (!running && !playing && !quit) {
@ -209,9 +211,11 @@ void TunerWorker::Entry()
octave_to_update = -1; octave_to_update = -1;
player->SetFreq(pitchDetection->GetNoteFreq(result.note, result.octave)); player->SetFreq(pitchDetection->GetNoteFreq(result.note, result.octave));
} }
bool m_running = running;
bool m_playing = playing;
mutex.unlock(); mutex.unlock();
if (running ) { if (m_running ) {
// tuner detection running // tuner detection running
if (!p_record) { if (!p_record) {
@ -252,7 +256,7 @@ void TunerWorker::Entry()
} }
} // running } // running
if (playing) { if (m_playing) {
// play // play
if (!p_play) { if (!p_play) {
// start pulseaudio if stopped // start pulseaudio if stopped