Disable FFT when no analyzer in use.
This commit is contained in:
parent
acc71de1d9
commit
59233f5192
|
@ -15,10 +15,11 @@
|
|||
*/
|
||||
|
||||
#include "analyzercontainer.h"
|
||||
#include "glblockanalyzer.h"
|
||||
#include "baranalyzer.h"
|
||||
#include "blockanalyzer.h"
|
||||
#include "boomanalyzer.h"
|
||||
#include "engines/enginebase.h"
|
||||
#include "glblockanalyzer.h"
|
||||
#include "sonogram.h"
|
||||
#include "turbine.h"
|
||||
|
||||
|
@ -104,12 +105,19 @@ void AnalyzerContainer::SetEngine(EngineBase *engine) {
|
|||
if (current_analyzer_)
|
||||
QMetaObject::invokeMethod(current_analyzer_, "set_engine", Qt::DirectConnection, Q_ARG(Engine::Base*, engine));
|
||||
engine_ = engine;
|
||||
if (engine_) {
|
||||
engine_->SetSpectrum(current_analyzer_);
|
||||
}
|
||||
}
|
||||
|
||||
void AnalyzerContainer::DisableAnalyzer() {
|
||||
delete current_analyzer_;
|
||||
current_analyzer_ = NULL;
|
||||
|
||||
if (engine_) {
|
||||
engine_->SetSpectrum(false);
|
||||
}
|
||||
|
||||
Save();
|
||||
}
|
||||
|
||||
|
@ -130,6 +138,10 @@ void AnalyzerContainer::ChangeAnalyzer(int id) {
|
|||
|
||||
layout()->addWidget(current_analyzer_);
|
||||
|
||||
if (engine_) {
|
||||
engine_->SetSpectrum(true);
|
||||
}
|
||||
|
||||
Save();
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@ class Base : public QObject, boost::noncopyable {
|
|||
bool is_crossfade_enabled() const { return crossfade_enabled_; }
|
||||
bool is_autocrossfade_enabled() const { return autocrossfade_enabled_; }
|
||||
|
||||
virtual void SetSpectrum(bool) {}
|
||||
|
||||
static const char* kSettingsGroup;
|
||||
static const int kScopeSize = 1024;
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ GstEngine::GstEngine()
|
|||
rg_compression_(true),
|
||||
seek_timer_(new QTimer(this)),
|
||||
timer_id_(-1),
|
||||
next_element_id_(0)
|
||||
next_element_id_(0),
|
||||
spectrum_enabled_(false)
|
||||
{
|
||||
seek_timer_->setSingleShot(true);
|
||||
seek_timer_->setInterval(kSeekDelay);
|
||||
|
@ -468,7 +469,6 @@ bool GstEngine::Load(const QUrl& url, Engine::TrackChangeType change) {
|
|||
current_pipeline_ = pipeline;
|
||||
preload_pipeline_.reset();
|
||||
|
||||
qDebug() << current_pipeline_.get();
|
||||
connect(current_pipeline_.get(), SIGNAL(SpectrumAvailable(const QVector<float>&)),
|
||||
this, SIGNAL(SpectrumAvailable(const QVector<float>&)));
|
||||
|
||||
|
@ -537,6 +537,8 @@ void GstEngine::PlayDone() {
|
|||
Seek(watcher->data());
|
||||
}
|
||||
|
||||
SetSpectrum(spectrum_enabled_);
|
||||
|
||||
emit StateChanged(Engine::Playing);
|
||||
}
|
||||
|
||||
|
@ -857,3 +859,10 @@ int GstEngine::AllGloryToTheHypnotoad() {
|
|||
pipeline->SetVolume(5); // Hypnotoad is *loud*.
|
||||
return AddBackgroundStream(pipeline);
|
||||
}
|
||||
|
||||
void GstEngine::SetSpectrum(bool enable) {
|
||||
spectrum_enabled_ = enable;
|
||||
if (current_pipeline_) {
|
||||
current_pipeline_->SetSpectrum(enable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,8 @@ class GstEngine : public Engine::Base, public BufferConsumer {
|
|||
void AddBufferConsumer(BufferConsumer* consumer);
|
||||
void RemoveBufferConsumer(BufferConsumer* consumer);
|
||||
|
||||
void SetSpectrum(bool enable);
|
||||
|
||||
protected:
|
||||
void SetVolumeSW(uint percent);
|
||||
void timerEvent(QTimerEvent*);
|
||||
|
@ -184,6 +186,8 @@ class GstEngine : public Engine::Base, public BufferConsumer {
|
|||
int next_element_id_;
|
||||
|
||||
QHash<int, boost::shared_ptr<GstEnginePipeline> > background_streams_;
|
||||
|
||||
bool spectrum_enabled_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -168,8 +168,8 @@ bool GstEnginePipeline::Init() {
|
|||
g_object_set(G_OBJECT(spectrum_),
|
||||
"bands", kSpectrumBands,
|
||||
"threshold", kSpectrumThreshold,
|
||||
"interval", kSpectrumIntervalns,
|
||||
NULL);
|
||||
SetSpectrum(false); // Spectrum disabled by default.
|
||||
|
||||
GstPad* pad = gst_element_get_pad(audioconvert_, "sink");
|
||||
gst_element_add_pad(audiobin_, gst_ghost_pad_new("sink", pad));
|
||||
|
@ -604,3 +604,9 @@ void GstEnginePipeline::RemoveAllBufferConsumers() {
|
|||
QMutexLocker l(&buffer_consumers_mutex_);
|
||||
buffer_consumers_.clear();
|
||||
}
|
||||
|
||||
void GstEnginePipeline::SetSpectrum(bool enable) {
|
||||
g_object_set(spectrum_,
|
||||
"interval", enable ? kSpectrumIntervalns : std::numeric_limits<quint64>::max(),
|
||||
NULL);
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ class GstEnginePipeline : public QObject {
|
|||
|
||||
QUrl redirect_url() const { return redirect_url_; }
|
||||
|
||||
void SetSpectrum(bool enable);
|
||||
|
||||
public slots:
|
||||
void SetVolumeModifier(qreal mod);
|
||||
|
||||
|
|
Loading…
Reference in New Issue