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 {
|
||||
id: tuner
|
||||
running: true
|
||||
running: false
|
||||
}
|
||||
|
||||
DesktopTheme {
|
||||
|
|
|
@ -149,4 +149,11 @@ Item {
|
|||
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;
|
||||
ifstream fin;
|
||||
fin.open(filename);
|
||||
if (!fin.is_open()) {
|
||||
cerr << "file not opened" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
const int nb_frame = 1024;
|
||||
PitchDetection *pitch = new PitchDetection();
|
||||
|
|
|
@ -42,12 +42,6 @@ Tuner::Tuner()
|
|||
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
||||
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::temperamentListUpdated, this, &Tuner::TemperamentListUpdated);
|
||||
|
||||
|
@ -56,9 +50,9 @@ Tuner::Tuner()
|
|||
|
||||
Tuner::~Tuner()
|
||||
{
|
||||
quit();
|
||||
// workerThread.quit();
|
||||
workerThread.wait(10);
|
||||
worker->Quit();
|
||||
workerThread.quit();
|
||||
workerThread.wait(100);
|
||||
}
|
||||
|
||||
bool Tuner::GetRunning()
|
||||
|
@ -71,8 +65,8 @@ void Tuner::SetRunning(bool r)
|
|||
if (running == r) return;
|
||||
|
||||
running = r;
|
||||
if (r) emit start();
|
||||
else emit stop();
|
||||
if (r) worker->Start();
|
||||
else worker->Stop();
|
||||
|
||||
emit runningChanged();
|
||||
}
|
||||
|
@ -105,7 +99,7 @@ bool Tuner::GetFound()
|
|||
void Tuner::SetLa(double la)
|
||||
{
|
||||
this->la = la;
|
||||
emit setLa(la);
|
||||
worker->SetLa(la);
|
||||
emit laChanged();
|
||||
}
|
||||
|
||||
|
@ -122,7 +116,7 @@ unsigned int Tuner::GetTemperamentIndex()
|
|||
void Tuner::SetTemperamentIndex(int idx)
|
||||
{
|
||||
temperament_idx = idx;
|
||||
emit setTemperamentIndex(idx);
|
||||
worker->SetTemperamentIndex(idx);
|
||||
emit temperamentChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,13 +75,6 @@ class Tuner : public QObject {
|
|||
void resultChanged();
|
||||
void temperamentChanged();
|
||||
void temperamentListChanged();
|
||||
|
||||
// signals to worker
|
||||
void quit();
|
||||
void start();
|
||||
void stop();
|
||||
void setTemperamentIndex(int idx);
|
||||
void setLa(double la_freq);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@ using namespace std;
|
|||
|
||||
static void blank_prevent(bool prevent)
|
||||
{
|
||||
cerr << __func__ << endl;
|
||||
cerr << __func__ << " " << prevent << endl;
|
||||
QDBusConnection system = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "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()
|
||||
{
|
||||
cerr << __func__ << endl;
|
||||
mutex.lock();
|
||||
running = false;
|
||||
mutex.unlock();
|
||||
|
@ -84,7 +85,7 @@ void TunerWorker::SetLa(double la)
|
|||
mutex.unlock();
|
||||
}
|
||||
|
||||
void TunerWorker::SetTemperament(int idx)
|
||||
void TunerWorker::SetTemperamentIndex(int idx)
|
||||
{
|
||||
mutex.lock();
|
||||
temperament_to_update = idx;
|
||||
|
@ -94,6 +95,7 @@ void TunerWorker::SetTemperament(int idx)
|
|||
void TunerWorker::Entry()
|
||||
{
|
||||
cerr << __func__ << endl;
|
||||
|
||||
pitchDetection = new PitchDetection();
|
||||
emit temperamentListUpdated(pitchDetection->GetTemperamentList());
|
||||
|
||||
|
@ -124,6 +126,8 @@ void TunerWorker::Entry()
|
|||
|
||||
std::cout << __func__ << " do job" << std::endl;
|
||||
}
|
||||
|
||||
cerr << __func__ << " quit" << endl;
|
||||
/*
|
||||
// prevent screen blanking
|
||||
if (nb_sample_running >= nbSamplePreventRunning && running) {
|
||||
|
|
|
@ -55,7 +55,7 @@ class TunerWorker : public QObject {
|
|||
public slots:
|
||||
void Start();
|
||||
void Stop();
|
||||
void SetTemperament(int idx);
|
||||
void SetTemperamentIndex(int idx);
|
||||
void SetLa(double la);
|
||||
void Entry();
|
||||
void Quit();
|
||||
|
|
Loading…
Reference in a new issue