replace sample rate callback used for superclock<=>sample conversion
Now using a globally-scoped static variable which is updated by the AudioEngine whenever an SR change occurs. Defaults to 48kHz and can be used even before there is a backend.
This commit is contained in:
parent
a4fd4cdaf0
commit
da95a0a0ee
|
@ -199,9 +199,6 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
|
|||
static AudioEngine* instance() { return _instance; }
|
||||
static void destroy();
|
||||
|
||||
/* this method is intended only to be used as a "fast" callback from libtemporal */
|
||||
static int static_sample_rate () { return _instance->sample_rate(); }
|
||||
|
||||
void died ();
|
||||
|
||||
/* The backend will cause these at the appropriate time(s) */
|
||||
|
|
|
@ -198,6 +198,7 @@ AudioEngine::sample_rate_change (pframes_t nframes)
|
|||
}
|
||||
|
||||
SampleRateChanged (nframes); /* EMIT SIGNAL */
|
||||
Temporal::set_sample_rate (nframes);
|
||||
|
||||
#ifdef SILENCE_AFTER_SECONDS
|
||||
_silence_countdown = nframes * SILENCE_AFTER_SECONDS;
|
||||
|
|
|
@ -529,8 +529,6 @@ ARDOUR::init (bool try_optimization, const char* localedir, bool with_gui)
|
|||
return true;
|
||||
}
|
||||
|
||||
Temporal::set_sample_rate_callback (AudioEngine::static_sample_rate);
|
||||
|
||||
running_from_gui = with_gui;
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -43,19 +43,14 @@ write_automation_list_xml (XMLNode* node, std::string filename)
|
|||
CPPUNIT_ASSERT (write_ref (node, output_file));
|
||||
}
|
||||
|
||||
static int
|
||||
static_sample_rate () { return 48000; }
|
||||
|
||||
void
|
||||
AutomationListPropertyTest::setUp ()
|
||||
{
|
||||
Temporal::set_sample_rate_callback (static_sample_rate);
|
||||
}
|
||||
|
||||
void
|
||||
AutomationListPropertyTest::tearDown ()
|
||||
{
|
||||
Temporal::set_sample_rate_callback (0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -107,7 +107,6 @@ create_and_start_dummy_backend ()
|
|||
CPPUNIT_ASSERT (engine->set_backend ("None (Dummy)", "Unit-Test", ""));
|
||||
|
||||
CPPUNIT_ASSERT (engine->start () == 0);
|
||||
Temporal::set_sample_rate_callback (AudioEngine::static_sample_rate);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -116,7 +115,6 @@ stop_and_destroy_backend ()
|
|||
AudioEngine::instance()->remove_session ();
|
||||
AudioEngine::instance()->stop ();
|
||||
AudioEngine::destroy ();
|
||||
Temporal::set_sample_rate_callback (0);
|
||||
}
|
||||
|
||||
/** @param dir Session directory.
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
Temporal::superclock_t Temporal::superclock_ticks_per_second = 508032000; // 2^10 * 3^4 * 5^3 * 7^2
|
||||
#endif
|
||||
|
||||
int (*Temporal::sample_rate_callback)() = 0;
|
||||
int Temporal::most_recent_engine_sample_rate = 48000; /* have to pick something as a default */
|
||||
|
||||
void
|
||||
Temporal::set_sample_rate_callback (int (*func)())
|
||||
Temporal::set_sample_rate (int sr)
|
||||
{
|
||||
sample_rate_callback = func;
|
||||
most_recent_engine_sample_rate = sr;
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ typedef int64_t superclock_t;
|
|||
static inline superclock_t superclock_to_samples (superclock_t s, int sr) { return int_div_round (s * sr, superclock_ticks_per_second); }
|
||||
static inline superclock_t samples_to_superclock (int64_t samples, int sr) { return int_div_round (samples * superclock_ticks_per_second, superclock_t (sr)); }
|
||||
|
||||
extern int (*sample_rate_callback)();
|
||||
extern int most_recent_engine_sample_rate;
|
||||
|
||||
LIBTEMPORAL_API void set_sample_rate_callback (int (*function)());
|
||||
LIBTEMPORAL_API void set_sample_rate (int sr);
|
||||
|
||||
}
|
||||
|
||||
#define TEMPORAL_SAMPLE_RATE (sample_rate_callback ())
|
||||
#define TEMPORAL_SAMPLE_RATE (most_recent_engine_sample_rate)
|
||||
|
||||
#endif /* __ardour_superclock_h__ */
|
||||
|
|
Loading…
Reference in New Issue