Worker: fix commands from Tuner to TunerWorker
This commit is contained in:
parent
1d857fd25d
commit
cd9ded443e
7 changed files with 26 additions and 24 deletions
|
@ -24,7 +24,7 @@ Item {
|
||||||
|
|
||||||
Tuner {
|
Tuner {
|
||||||
id: tuner
|
id: tuner
|
||||||
running: true
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopTheme {
|
DesktopTheme {
|
||||||
|
|
|
@ -149,4 +149,11 @@ Item {
|
||||||
index: tuner.octave
|
index: tuner.octave
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
tuner.running = tuner.running ^ true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,10 @@ void PitchDetection::analyse_file(const char *filename)
|
||||||
cout << "analyse file " << filename << endl;
|
cout << "analyse file " << filename << endl;
|
||||||
ifstream fin;
|
ifstream fin;
|
||||||
fin.open(filename);
|
fin.open(filename);
|
||||||
|
if (!fin.is_open()) {
|
||||||
|
cerr << "file not opened" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const int nb_frame = 1024;
|
const int nb_frame = 1024;
|
||||||
PitchDetection *pitch = new PitchDetection();
|
PitchDetection *pitch = new PitchDetection();
|
||||||
|
|
|
@ -42,12 +42,6 @@ Tuner::Tuner()
|
||||||
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
||||||
connect(&workerThread, &QThread::started, worker, &TunerWorker::Entry);
|
connect(&workerThread, &QThread::started, worker, &TunerWorker::Entry);
|
||||||
|
|
||||||
connect(this, &Tuner::quit, worker, &TunerWorker::Quit, Qt::DirectConnection);
|
|
||||||
connect(this, &Tuner::start, worker, &TunerWorker::Start);
|
|
||||||
connect(this, &Tuner::stop, worker, &TunerWorker::Stop);
|
|
||||||
connect(this, &Tuner::setTemperamentIndex, worker, &TunerWorker::SetTemperament);
|
|
||||||
connect(this, &Tuner::setLa, worker, &TunerWorker::SetLa);
|
|
||||||
|
|
||||||
connect(worker, &TunerWorker::resultUpdated, this, &Tuner::ResultUpdated);
|
connect(worker, &TunerWorker::resultUpdated, this, &Tuner::ResultUpdated);
|
||||||
connect(worker, &TunerWorker::temperamentListUpdated, this, &Tuner::TemperamentListUpdated);
|
connect(worker, &TunerWorker::temperamentListUpdated, this, &Tuner::TemperamentListUpdated);
|
||||||
|
|
||||||
|
@ -56,9 +50,9 @@ Tuner::Tuner()
|
||||||
|
|
||||||
Tuner::~Tuner()
|
Tuner::~Tuner()
|
||||||
{
|
{
|
||||||
quit();
|
worker->Quit();
|
||||||
// workerThread.quit();
|
workerThread.quit();
|
||||||
workerThread.wait(10);
|
workerThread.wait(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tuner::GetRunning()
|
bool Tuner::GetRunning()
|
||||||
|
@ -71,8 +65,8 @@ void Tuner::SetRunning(bool r)
|
||||||
if (running == r) return;
|
if (running == r) return;
|
||||||
|
|
||||||
running = r;
|
running = r;
|
||||||
if (r) emit start();
|
if (r) worker->Start();
|
||||||
else emit stop();
|
else worker->Stop();
|
||||||
|
|
||||||
emit runningChanged();
|
emit runningChanged();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +99,7 @@ bool Tuner::GetFound()
|
||||||
void Tuner::SetLa(double la)
|
void Tuner::SetLa(double la)
|
||||||
{
|
{
|
||||||
this->la = la;
|
this->la = la;
|
||||||
emit setLa(la);
|
worker->SetLa(la);
|
||||||
emit laChanged();
|
emit laChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +116,7 @@ unsigned int Tuner::GetTemperamentIndex()
|
||||||
void Tuner::SetTemperamentIndex(int idx)
|
void Tuner::SetTemperamentIndex(int idx)
|
||||||
{
|
{
|
||||||
temperament_idx = idx;
|
temperament_idx = idx;
|
||||||
emit setTemperamentIndex(idx);
|
worker->SetTemperamentIndex(idx);
|
||||||
emit temperamentChanged();
|
emit temperamentChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,13 +75,6 @@ class Tuner : public QObject {
|
||||||
void resultChanged();
|
void resultChanged();
|
||||||
void temperamentChanged();
|
void temperamentChanged();
|
||||||
void temperamentListChanged();
|
void temperamentListChanged();
|
||||||
|
|
||||||
// signals to worker
|
|
||||||
void quit();
|
|
||||||
void start();
|
|
||||||
void stop();
|
|
||||||
void setTemperamentIndex(int idx);
|
|
||||||
void setLa(double la_freq);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,7 @@ using namespace std;
|
||||||
|
|
||||||
static void blank_prevent(bool prevent)
|
static void blank_prevent(bool prevent)
|
||||||
{
|
{
|
||||||
cerr << __func__ << endl;
|
cerr << __func__ << " " << prevent << endl;
|
||||||
QDBusConnection system = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "system");
|
QDBusConnection system = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "system");
|
||||||
QDBusInterface interface("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", system);
|
QDBusInterface interface("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", system);
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ void TunerWorker::Start()
|
||||||
|
|
||||||
void TunerWorker::Stop()
|
void TunerWorker::Stop()
|
||||||
{
|
{
|
||||||
|
cerr << __func__ << endl;
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
running = false;
|
running = false;
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
@ -84,7 +85,7 @@ void TunerWorker::SetLa(double la)
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TunerWorker::SetTemperament(int idx)
|
void TunerWorker::SetTemperamentIndex(int idx)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
temperament_to_update = idx;
|
temperament_to_update = idx;
|
||||||
|
@ -94,6 +95,7 @@ void TunerWorker::SetTemperament(int idx)
|
||||||
void TunerWorker::Entry()
|
void TunerWorker::Entry()
|
||||||
{
|
{
|
||||||
cerr << __func__ << endl;
|
cerr << __func__ << endl;
|
||||||
|
|
||||||
pitchDetection = new PitchDetection();
|
pitchDetection = new PitchDetection();
|
||||||
emit temperamentListUpdated(pitchDetection->GetTemperamentList());
|
emit temperamentListUpdated(pitchDetection->GetTemperamentList());
|
||||||
|
|
||||||
|
@ -124,6 +126,8 @@ void TunerWorker::Entry()
|
||||||
|
|
||||||
std::cout << __func__ << " do job" << std::endl;
|
std::cout << __func__ << " do job" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cerr << __func__ << " quit" << endl;
|
||||||
/*
|
/*
|
||||||
// prevent screen blanking
|
// prevent screen blanking
|
||||||
if (nb_sample_running >= nbSamplePreventRunning && running) {
|
if (nb_sample_running >= nbSamplePreventRunning && running) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TunerWorker : public QObject {
|
||||||
public slots:
|
public slots:
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
void SetTemperament(int idx);
|
void SetTemperamentIndex(int idx);
|
||||||
void SetLa(double la);
|
void SetLa(double la);
|
||||||
void Entry();
|
void Entry();
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
Loading…
Reference in a new issue