Skip to content

Commit

Permalink
TEMP: print debug info around locks with explicit unlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
he29-net committed Dec 3, 2019
1 parent 4c8884a commit b043792
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/SpectrumAnalyzer/SaControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "EffectControls.h"
#include "lmms_constants.h"

//#define SA_DEBUG 1 // define SA_DEBUG to enable performance measurements
#define SA_DEBUG 1 // define SA_DEBUG to enable performance measurements


class Analyzer;
Expand Down
4 changes: 4 additions & 0 deletions plugins/SpectrumAnalyzer/SaProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ void SaProcessor::reallocateBuffers()
// Lock data shared with SaSpectrumView and SaWaterfallView.
// Reallocation lock must be acquired first to avoid deadlock (a view class
// may already have it and request the "stronger" data lock on top of that).
std::cout<<"get locks"<<std::endl;
QMutexLocker reloc_lock(&m_reallocationAccess);
QMutexLocker data_lock(&m_dataAccess);

Expand Down Expand Up @@ -436,8 +437,11 @@ void SaProcessor::reallocateBuffers()
m_inBlockSize = new_in_size;
m_fftBlockSize = new_fft_size;

std::cout<<"going to unlock data"<<std::endl;
data_lock.unlock();
std::cout<<"going to unlock reloc"<<std::endl;
reloc_lock.unlock();
std::cout<<"all done"<<std::endl;
m_reallocating = false;

clear();
Expand Down
4 changes: 4 additions & 0 deletions plugins/SpectrumAnalyzer/SaWaterfallView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <algorithm>
#ifdef SA_DEBUG
#include <chrono>
#include <iostream>
#endif
#include <cmath>
#include <QImage>
Expand Down Expand Up @@ -138,12 +139,15 @@ void SaWaterfallView::paintEvent(QPaintEvent *event)
// draw the spectrogram precomputed in SaProcessor
if (m_processor->waterfallNotEmpty())
{
std::cout<<"get waterfall lock"<<std::endl;
QMutexLocker lock(&m_processor->m_reallocationAccess);
QImage temp = QImage(m_processor->getHistory(), // raw pixel data to display
m_processor->waterfallWidth(), // width = number of frequency bins
m_processor->waterfallHeight(), // height = number of history lines
QImage::Format_RGB32);
std::cout<<"going to unlock reloc from waterfall"<<std::endl;
lock.unlock();
std::cout<<"waterfall done"<<std::endl;
temp.setDevicePixelRatio(devicePixelRatio()); // display at native resolution
painter.drawImage(m_displayLeft, m_displayTop,
temp.scaled(m_displayWidth * devicePixelRatio(),
Expand Down

0 comments on commit b043792

Please sign in to comment.