Commit cacdc382 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Fix problems with non-thread-safe code being run in ThreadPool.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 1a1a4930
...@@ -165,14 +165,20 @@ private: ...@@ -165,14 +165,20 @@ private:
const double step; const double step;
const int n_steps; const int n_steps;
const double seconds; const double seconds;
const int frames_per_block;
public: public:
SpeedSync (const WavData& in_data, double center, double step, int n_steps, double seconds) : SpeedSync (const WavData& in_data, double center, double step, int n_steps, double seconds) :
in_data (in_data), in_data (in_data),
center (center), center (center),
step (step), step (step),
n_steps (n_steps), n_steps (n_steps),
seconds (seconds) seconds (seconds),
frames_per_block (mark_sync_frame_count() + mark_data_frame_count())
{ {
// constructor is run in the main thread; everything that is not thread-safe must happen here
SyncFinder sync_finder;
sync_bits = sync_finder.get_sync_bits (in_data, SyncFinder::Mode::BLOCK);
} }
void void
prepare_job (ThreadPool& thread_pool) prepare_job (ThreadPool& thread_pool)
...@@ -290,9 +296,6 @@ SpeedSync::prepare_mags() ...@@ -290,9 +296,6 @@ SpeedSync::prepare_mags()
window[i] *= 2.0 / window_weight; window[i] *= 2.0 / window_weight;
} }
SyncFinder sync_finder;
sync_bits = sync_finder.get_sync_bits (in_data, SyncFinder::Mode::BLOCK);
FFTProcessor fft_processor (sub_frame_size); FFTProcessor fft_processor (sub_frame_size);
float *in = fft_processor.in(); float *in = fft_processor.in();
...@@ -346,7 +349,6 @@ SpeedSync::prepare_mags() ...@@ -346,7 +349,6 @@ SpeedSync::prepare_mags()
void void
SpeedSync::compare (double relative_speed) SpeedSync::compare (double relative_speed)
{ {
const int frames_per_block = mark_sync_frame_count() + mark_data_frame_count();
const int pad_start = frames_per_block * /* HACK */ 4; const int pad_start = frames_per_block * /* HACK */ 4;
Score best_score; Score best_score;
// FIXME: pad_start must be scaled with speed // FIXME: pad_start must be scaled with speed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment