1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-02-02 20:36:44 +01:00

Merge pull request #4343 from TheUbuntuGuy/master

Fix block analyzer framerate
This commit is contained in:
John Maguire 2014-05-14 14:14:33 +02:00
commit 42a2739daf
4 changed files with 13 additions and 1 deletions

View File

@ -50,6 +50,8 @@ class Base : public QWidget {
}
}
virtual void framerateChanged() {}
protected:
Base(QWidget*, uint scopeSize = 7);

View File

@ -165,6 +165,9 @@ void AnalyzerContainer::ChangeFramerate(int new_framerate) {
// Even if it is not supposed to happen, I don't want to get a dbz error
new_framerate = new_framerate == 0 ? kMediumFramerate : new_framerate;
current_analyzer_->changeTimeout(1000 / new_framerate);
// notify the current analyzer that the framerate has changed
current_analyzer_->framerateChanged();
}
SaveFramerate(new_framerate);
}

View File

@ -100,10 +100,16 @@ void BlockAnalyzer::determineStep() {
// boxes/blocks of pixels)
// I calculated the value 30 based on some trial and error
const double fallTime = 30 * m_rows;
// the fall time of 30 is too slow on framerates above 50fps
const double fallTime = timeout() < 20 ? 20 * m_rows : 30 * m_rows;
m_step = double(m_rows * timeout()) / fallTime;
}
void BlockAnalyzer::framerateChanged() { // virtual
determineStep();
}
void BlockAnalyzer::transform(Analyzer::Scope& s) // pure virtual
{
for (uint x = 0; x < s.size(); ++x) s[x] *= 2;

View File

@ -36,6 +36,7 @@ class BlockAnalyzer : public Analyzer::Base {
virtual void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
virtual void resizeEvent(QResizeEvent*);
virtual void paletteChange(const QPalette&);
virtual void framerateChanged();
void drawBackground();
void determineStep();