From 1613e9ce46cda6c4326b56faf46d93d0b4e2cced Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Tue, 19 Jul 2022 23:52:51 +0200 Subject: [PATCH] BugFix: session creator restore play status of all types of sources moved 'play' attribute to source instead of mediaplayer and use source callback to set play state after initialization. --- SessionCreator.cpp | 17 +++++++++++++---- SessionVisitor.cpp | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/SessionCreator.cpp b/SessionCreator.cpp index 5da4f80..17dc5c7 100644 --- a/SessionCreator.cpp +++ b/SessionCreator.cpp @@ -851,9 +851,12 @@ void SessionLoader::visit(MediaPlayer &n) mediaplayerNode->QueryIntAttribute("sync_to_metronome", &sync_to_metronome); n.setSyncToMetronome( (Metronome::Synchronicity) sync_to_metronome); - bool play = true; - mediaplayerNode->QueryBoolAttribute("play", &play); - n.play(play); + // only read media player play attribute if the source has no play attribute (backward compatibility) + if ( !xmlCurrent_->Attribute( "play" ) ) { + bool play = true; + mediaplayerNode->QueryBoolAttribute("play", &play); + n.play(play); + } } } } @@ -933,9 +936,14 @@ void SessionLoader::visit (Source& s) XMLElement* sourceNode = xmlCurrent_; const char *pName = sourceNode->Attribute("name"); s.setName(pName); + + // schedule lock and play of the source (callbacks called after init) bool l = false; sourceNode->QueryBoolAttribute("locked", &l); - s.setLocked(l); + s.call( new Lock(l) ); + bool p = true; + sourceNode->QueryBoolAttribute("play", &p); + s.call( new Play(p) ); xmlCurrent_ = sourceNode->FirstChildElement("Mixing"); if (xmlCurrent_) s.groupNode(View::MIXING)->accept(*this); @@ -990,6 +998,7 @@ void SessionLoader::visit (Source& s) // restore current xmlCurrent_ = sourceNode; + } void SessionLoader::visit (MediaSource& s) diff --git a/SessionVisitor.cpp b/SessionVisitor.cpp index 2a13b4e..ce63cd5 100644 --- a/SessionVisitor.cpp +++ b/SessionVisitor.cpp @@ -574,6 +574,7 @@ void SessionVisitor::visit (Source& s) sourceNode->SetAttribute("id", s.id()); sourceNode->SetAttribute("name", s.name().c_str() ); sourceNode->SetAttribute("locked", s.locked() ); + sourceNode->SetAttribute("play", s.playing() ); // insert into hierarchy xmlCurrent_->InsertFirstChild(sourceNode);