]> Shamusworld >> Repos - wozmaker/blob - src/analysisthread.cpp
Flesh out the disk settings dialog.
[wozmaker] / src / analysisthread.cpp
1 //
2 // analysisthread.cpp: Disk image analysis thread
3 //
4 // Part of the WOZ Maker project
5 // by James Hammons
6 // (C) 2018 Underground Software
7 //
8 // Since this can take a bit of time, we shunt all the heavy lifting to a
9 // separate worker thread so that it doesn't block the GUI thread.
10 //
11
12 #include "analysisthread.h"
13
14 #include <stdlib.h>
15 #include <QtWidgets>
16 #include <cmath>
17 #include "dsp.h"
18 #include "fileio.h"
19 #include "global.h"
20
21
22 AnalysisThread::AnalysisThread(QObject * parent): QThread(parent)
23 {
24 }
25
26
27 AnalysisThread::~AnalysisThread()
28 {
29 #if 0
30         mutex.lock();
31         abort = true;
32         condition.wakeOne();
33         mutex.unlock();
34
35         wait();
36 #endif
37 }
38
39
40 void AnalysisThread::StartAnalysis(void)
41 {
42         start(LowPriority);
43 }
44
45
46 void AnalysisThread::run()
47 {
48         // Sanity clause
49         if (Global::a2r == NULL)
50                 return;
51
52         // Run full tracks first
53         for(uint32_t i=0; i<141; i+=4)
54         {
55                 SynthesizeTrack(i);
56                 int a = rand() & 0x03;
57                 Global::trackStatus[i] = (a == 0 ? 3 : a);
58                 emit(ShowTracks());
59         }
60
61         // Then fill in with half/quarter tracks
62         for(uint32_t i=0; i<141; i++)
63         {
64                 if ((i % 4) == 0)
65                         continue;
66
67                 SynthesizeTrack(i);
68                 int a = rand() & 0x03;
69                 Global::trackStatus[i] = (a == 0 ? 3 : a);
70                 emit(ShowTracks());
71         }
72 }
73