(libs) call ARDOUR::init_post_engine() from within libardour rather than requiring "users" of the library to arrange for it

This commit is contained in:
Paul Davis 2019-01-16 15:29:21 -06:00
parent cd70c6bda5
commit 4c064081af
6 changed files with 21 additions and 8 deletions

View File

@ -62,7 +62,7 @@ namespace ARDOUR {
* @return true if Ardour library was successfully initialized
*/
LIBARDOUR_API bool init (bool with_vst, bool try_optimization, const char* localedir);
LIBARDOUR_API void init_post_engine ();
LIBARDOUR_API void init_post_engine (uint32_t);
LIBARDOUR_API void cleanup ();
LIBARDOUR_API bool no_auto_connect ();
LIBARDOUR_API void make_property_quarks ();

View File

@ -196,7 +196,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
started and stopped
*/
PBD::Signal0<void> Running;
PBD::Signal1<void,uint32_t> Running;
PBD::Signal0<void> Stopped;
/* these two are emitted when a device reset is initiated/finished
@ -306,6 +306,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
Glib::Threads::Cond _hw_devicelist_update_condition;
Glib::Threads::Mutex _devicelist_update_lock;
gint _stop_hw_devicelist_processing;
uint32_t _start_cnt;
void start_hw_event_processing();
void stop_hw_event_processing();

View File

@ -98,6 +98,7 @@ AudioEngine::AudioEngine ()
, _hw_devicelist_update_thread(0)
, _hw_devicelist_update_count(0)
, _stop_hw_devicelist_processing(0)
, _start_cnt (0)
#ifdef SILENCE_AFTER_SECONDS
, _silence_countdown (0)
, _silence_hit_cnt (0)
@ -929,9 +930,11 @@ AudioEngine::start (bool for_latency)
PortManager::fill_midi_port_info ();
if (!for_latency) {
Running(); /* EMIT SIGNAL */
Running (_start_cnt); /* EMIT SIGNAL */
}
_start_cnt++;
return 0;
}

View File

@ -161,6 +161,8 @@ extern void setup_enum_writer ();
*/
PBD::PropertyChange ARDOUR::bounds_change;
static PBD::ScopedConnection engine_startup_connection;
void
setup_hardware_optimization (bool try_optimization)
{
@ -559,6 +561,9 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
ARDOUR::AudioEngine::create ();
/* This will run only once in whatever thread calls AudioEngine::start() */
ARDOUR::AudioEngine::instance()->Running.connect_same_thread (engine_startup_connection, ARDOUR::init_post_engine);
/* it is unfortunate that we need to include reserved names here that
refer to control surfaces. But there's no way to ensure a complete
lack of collisions without doing this, since the control surface
@ -594,7 +599,7 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
}
void
ARDOUR::init_post_engine ()
ARDOUR::init_post_engine (uint32_t /* ignored */)
{
XMLNode* node;
@ -617,6 +622,12 @@ ARDOUR::init_post_engine ()
/* find plugins */
ARDOUR::PluginManager::instance().refresh (!Config->get_discover_vst_on_start());
/* Don't do this again - we are only meant to execute on the first
* engine start, not any subsequence starts
*/
engine_startup_connection.disconnect ();
}
void
@ -626,6 +637,8 @@ void
return;
}
engine_startup_connection.disconnect ();
delete &ControlProtocolManager::instance();
ARDOUR::AudioEngine::destroy ();

View File

@ -51,8 +51,6 @@ AudioEngineTest::test_start ()
CPPUNIT_ASSERT (backend);
init_post_engine ();
CPPUNIT_ASSERT (engine->start () == 0);
Glib::usleep(2000);

View File

@ -105,8 +105,6 @@ create_and_start_dummy_backend ()
CPPUNIT_ASSERT (engine);
CPPUNIT_ASSERT (engine->set_backend ("None (Dummy)", "Unit-Test", ""));
init_post_engine ();
CPPUNIT_ASSERT (engine->start () == 0);
}