Skip to content

Commit 9f8b16d

Browse files
committed
Move variables to ow_resampler struct
Having them declared as static would lead to issues when having more than one device running.
1 parent 9e25c90 commit 9f8b16d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/resampler.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ ow_resampler_compute_ratios (struct ow_resampler *resampler,
404404
{
405405
ow_engine_status_t engine_status;
406406
struct ow_dll *dll = &resampler->dll;
407-
static uint64_t booting_start_usecs, tuning_start_usecs;
408407
ow_resampler_status_t status;
409408

410409
engine_status = ow_engine_get_status (resampler->engine);
@@ -458,7 +457,7 @@ ow_resampler_compute_ratios (struct ow_resampler *resampler,
458457
ow_resampler_set_status (resampler, OW_RESAMPLER_STATUS_BOOT);
459458
ow_resampler_report_state (resampler);
460459

461-
booting_start_usecs = current_usecs;
460+
resampler->phase_start_usecs = current_usecs;
462461

463462
return 0;
464463
}
@@ -468,7 +467,7 @@ ow_resampler_compute_ratios (struct ow_resampler *resampler,
468467
ow_resampler_set_ratios_from_dll (resampler);
469468

470469
if (status == OW_RESAMPLER_STATUS_BOOT &&
471-
current_usecs - booting_start_usecs > BOOTING_PERIOD_US &&
470+
current_usecs - resampler->phase_start_usecs > BOOTING_PERIOD_US &&
472471
ow_dll_tuned (dll, BOOTING_ERROR))
473472
{
474473
debug_print (1, "%s (%s): Tuning resampler...", resampler->engine->name,
@@ -483,11 +482,11 @@ ow_resampler_compute_ratios (struct ow_resampler *resampler,
483482
resampler->report_period * resampler->samplerate / resampler->bufsize;
484483
resampler->log_cycles = 0;
485484

486-
tuning_start_usecs = current_usecs;
485+
resampler->phase_start_usecs = current_usecs;
487486
}
488487

489488
if (status == OW_RESAMPLER_STATUS_TUNE &&
490-
current_usecs - tuning_start_usecs > TUNING_PERIOD_US &&
489+
current_usecs - resampler->phase_start_usecs > TUNING_PERIOD_US &&
491490
ow_dll_tuned (dll, TUNING_ERROR))
492491
{
493492
debug_print (1, "%s (%s): Running resampler...",

src/resampler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ struct ow_resampler
5353
double samplerate;
5454
int report_period;
5555
struct ow_resampler_state state;
56+
uint64_t phase_start_usecs;
5657
};

0 commit comments

Comments
 (0)