mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 23:35:03 +01:00
library changes to get libtemporal setup at application startup
This commit is contained in:
parent
d2a94468d4
commit
8dbbc1df54
6 changed files with 53 additions and 15 deletions
|
|
@ -28,6 +28,7 @@
|
||||||
#include "pbd/pthread_utils.h"
|
#include "pbd/pthread_utils.h"
|
||||||
|
|
||||||
#include "temporal/superclock.h"
|
#include "temporal/superclock.h"
|
||||||
|
#include "temporal/tempo.h"
|
||||||
|
|
||||||
#include "ardour/audioengine.h"
|
#include "ardour/audioengine.h"
|
||||||
#include "ardour/debug.h"
|
#include "ardour/debug.h"
|
||||||
|
|
@ -535,6 +536,7 @@ void
|
||||||
Graph::setup_thread_local_variables ()
|
Graph::setup_thread_local_variables ()
|
||||||
{
|
{
|
||||||
Temporal::_thread_sample_rate = _session.sample_rate ();
|
Temporal::_thread_sample_rate = _session.sample_rate ();
|
||||||
|
Temporal::TempoMap::fetch ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -1557,6 +1557,20 @@ Session::set_state (const XMLNode& node, int version)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* need the tempo map setup ASAP */
|
||||||
|
|
||||||
|
if ((child = find_named_node (node, "TempoMap")) == 0) {
|
||||||
|
error << _("Session: XML state has no Tempo Map section") << endmsg;
|
||||||
|
goto out;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
TempoMap::SharedPtr new_map (new TempoMap (*child, version));
|
||||||
|
TempoMap::update (new_map);
|
||||||
|
} catch (...) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
node.get_property ("name", _name);
|
node.get_property ("name", _name);
|
||||||
|
|
||||||
if (node.get_property (X_("sample-rate"), _base_sample_rate)) {
|
if (node.get_property (X_("sample-rate"), _base_sample_rate)) {
|
||||||
|
|
@ -1645,18 +1659,6 @@ Session::set_state (const XMLNode& node, int version)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((child = find_named_node (node, "TempoMap")) == 0) {
|
|
||||||
error << _("Session: XML state has no Tempo Map section") << endmsg;
|
|
||||||
goto out;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
TempoMap::SharedPtr new_map (new TempoMap (*child, version));
|
|
||||||
TempoMap::update (new_map);
|
|
||||||
} catch (...) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((child = find_named_node (node, "Locations")) == 0) {
|
if ((child = find_named_node (node, "Locations")) == 0) {
|
||||||
error << _("Session: XML state has no locations section") << endmsg;
|
error << _("Session: XML state has no locations section") << endmsg;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
|
|
@ -144,11 +144,19 @@ template <class T>
|
||||||
class /*LIBPBD_API*/ SerializedRCUManager : public RCUManager<T>
|
class /*LIBPBD_API*/ SerializedRCUManager : public RCUManager<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SerializedRCUManager (T* new_rcu_value)
|
SerializedRCUManager(T* new_rcu_value)
|
||||||
: RCUManager<T> (new_rcu_value)
|
: RCUManager<T>(new_rcu_value)
|
||||||
|
, current_write_old (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init (boost::shared_ptr<T> new_rcu_value) {
|
||||||
|
assert (*RCUManager<T>::x.m_rcu_value == boost::shared_ptr<T> ());
|
||||||
|
|
||||||
|
boost::shared_ptr<T>* new_spp = new boost::shared_ptr<T> (new_rcu_value);
|
||||||
|
g_atomic_pointer_set (&RCUManager<T>::x.gptr, new_spp);
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<T> write_copy ()
|
boost::shared_ptr<T> write_copy ()
|
||||||
{
|
{
|
||||||
_lock.lock ();
|
_lock.lock ();
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ using namespace PBD;
|
||||||
using namespace Temporal;
|
using namespace Temporal;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
static bool libtemporal_initialized = false;
|
||||||
|
|
||||||
void
|
void
|
||||||
setup_libtemporal_enums ()
|
setup_libtemporal_enums ()
|
||||||
{
|
{
|
||||||
|
|
@ -62,5 +64,19 @@ setup_libtemporal_enums ()
|
||||||
|
|
||||||
void Temporal::init ()
|
void Temporal::init ()
|
||||||
{
|
{
|
||||||
setup_libtemporal_enums ();
|
if (!libtemporal_initialized) {
|
||||||
|
setup_libtemporal_enums ();
|
||||||
|
|
||||||
|
|
||||||
|
/* this should be the main (typically GUI) thread. Normally
|
||||||
|
* this will be done by some
|
||||||
|
* Gtkmm2ext::UI::event_loop_precall() but we need to make sure
|
||||||
|
* that things are set up for this thread before we get started
|
||||||
|
*/
|
||||||
|
|
||||||
|
Temporal::_thread_sample_rate = 44100;
|
||||||
|
TempoMap::init ();
|
||||||
|
|
||||||
|
libtemporal_initialized = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2877,3 +2877,11 @@ TempoMap::MementoBinder::set_state (XMLNode const & node, int version) const
|
||||||
/* now update this thread's view of the current tempo map */
|
/* now update this thread's view of the current tempo map */
|
||||||
fetch ();
|
fetch ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TempoMap::init ()
|
||||||
|
{
|
||||||
|
SharedPtr new_map (new TempoMap (Tempo (120), Meter (4, 4)));
|
||||||
|
_map_mgr.init (new_map);
|
||||||
|
fetch ();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -619,6 +619,8 @@ class LIBTEMPORAL_API TempoMap : public PBD::StatefulDestructible
|
||||||
static thread_local SharedPtr _tempo_map_p;
|
static thread_local SharedPtr _tempo_map_p;
|
||||||
static SerializedRCUManager<TempoMap> _map_mgr;
|
static SerializedRCUManager<TempoMap> _map_mgr;
|
||||||
public:
|
public:
|
||||||
|
static void init ();
|
||||||
|
|
||||||
static void update_thread_tempo_map() { _tempo_map_p = _map_mgr.reader(); }
|
static void update_thread_tempo_map() { _tempo_map_p = _map_mgr.reader(); }
|
||||||
static SharedPtr use() { assert (_tempo_map_p); return _tempo_map_p; }
|
static SharedPtr use() { assert (_tempo_map_p); return _tempo_map_p; }
|
||||||
static SharedPtr fetch() { update_thread_tempo_map(); return use(); }
|
static SharedPtr fetch() { update_thread_tempo_map(); return use(); }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue