BugFix Sync Play to Session ready when loading

Add test of session state on Play callback; the play action is then called after all sources are ready, thus starting in sync.
This commit is contained in:
Bruno Herbelin
2024-11-10 12:12:05 +01:00
parent f0f23cbd0b
commit 120909f8d6
3 changed files with 8 additions and 5 deletions

View File

@@ -1047,7 +1047,7 @@ void SessionLoader::visit (Source& s)
s.call( new Lock(l) ); s.call( new Lock(l) );
bool p = true; bool p = true;
sourceNode->QueryBoolAttribute("play", &p); sourceNode->QueryBoolAttribute("play", &p);
s.call( new Play(p) ); s.call( new Play(p, session_) );
xmlCurrent_ = sourceNode->FirstChildElement("Mixing"); xmlCurrent_ = sourceNode->FirstChildElement("Mixing");
if (xmlCurrent_) s.groupNode(View::MIXING)->accept(*this); if (xmlCurrent_) s.groupNode(View::MIXING)->accept(*this);

View File

@@ -494,7 +494,8 @@ void SetDepth::accept(Visitor& v)
v.visit(*this); v.visit(*this);
} }
Play::Play(bool on, bool revert) : SourceCallback(), play_(on), bidirectional_(revert) Play::Play(bool on, Session *parentsession, bool revert) : SourceCallback(),
session_(parentsession), play_(on), bidirectional_(revert)
{ {
} }
@@ -503,7 +504,8 @@ void Play::update(Source *s, float dt)
SourceCallback::update(s, dt); SourceCallback::update(s, dt);
// toggle play status when ready // toggle play status when ready
if ( status_ == READY && s->ready() ){ if ( status_ == READY && s->ready() &&
(session_ ? session_->ready() : true) ){
if (s->playing() != play_) if (s->playing() != play_)
// call play function // call play function
@@ -516,7 +518,7 @@ void Play::update(Source *s, float dt)
SourceCallback *Play::clone() const SourceCallback *Play::clone() const
{ {
return new Play(play_, bidirectional_); return new Play(play_, session_, bidirectional_);
} }
SourceCallback *Play::reverse(Source *s) const SourceCallback *Play::reverse(Source *s) const

View File

@@ -212,11 +212,12 @@ public:
class Play : public SourceCallback class Play : public SourceCallback
{ {
class Session *session_;
bool play_; bool play_;
bool bidirectional_; bool bidirectional_;
public: public:
Play (bool on = true, bool revert = false); Play (bool on = true, Session *parentsession = nullptr, bool revert = false);
bool value () const { return play_;} bool value () const { return play_;}
void setValue (bool on) { play_ = on; } void setValue (bool on) { play_ = on; }