lumiera_/src/proc/facade.cpp

149 lines
3.9 KiB
C++
Raw Normal View History

/*
Facade - access point for communicating with the Proc-Interface
2010-12-17 23:28:49 +01:00
Copyright (C) Lumiera.org
2008, Hermann Vosseler <Ichthyostega@web.de>
2010-12-17 23:28:49 +01:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2010-12-17 23:28:49 +01:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2010-12-17 23:28:49 +01:00
* *****************************************************/
#include "proc/facade.hpp"
#include "lib/depend.hpp"
//#include "lib/sync.hpp"
#include "proc/control/proc-dispatcher.hpp"
#include "proc/play/output-director.hpp"
#include <string>
//#include <memory>
namespace proc {
using std::string;
using std::unique_ptr;
using lumiera::Subsys;
using lumiera::Option;
using lib::Sync;
// using lib::RecursiveLock_NoWait;
using proc::control::ProcDispatcher;
class SessionSubsystem
: public Subsys
{
operator string() const { return "Session"; }
/** @remarks there is no need explicitly to start the session,
* since it is passive, waiting for invocations and will be
* pulled up as prerequisite of other subsystems. */
bool
shouldStart (Option&) override
{
return false;
}
bool
start (Option&, Subsys::SigTerm termNotification) override
{
return ProcDispatcher::instance().start (termNotification);
}
void
triggerShutdown() noexcept override
{
ProcDispatcher::instance().requestStop();
}
bool
checkRunningState() noexcept override
{
return ProcDispatcher::instance().isRunning();
}
};
2011-05-24 03:48:49 +02:00
class PlayOutSubsysDescriptor
: public Subsys
{
operator string() const { return "PlayOut"; }
2011-05-24 03:48:49 +02:00
/** determine, if any output system is required to start up explicitly.
* Moreover, extract configuration variations for specific kinds of output
* @return true if any output system is required to start stand-alone.
* otherwise, the player and a default configured output connection
* is pulled up only when required by another subsystem (e.g. GUI)
* @todo actually define cmdline options and parse/decide here!
*/
bool
shouldStart (Option&) override
2011-05-24 03:48:49 +02:00
{
TODO ("extract options about specific output systems to be brought up");
return false;
}
bool
start (Option&, Subsys::SigTerm termination) override
2011-05-24 03:48:49 +02:00
{
this->completedSignal_ = termination;
return play::OutputDirector::instance().connectUp();
2011-05-24 03:48:49 +02:00
}
SigTerm completedSignal_;
2011-05-24 03:48:49 +02:00
void
triggerShutdown() noexcept override
2011-05-24 03:48:49 +02:00
{
play::OutputDirector::instance().triggerDisconnect (completedSignal_);
2011-05-24 03:48:49 +02:00
}
2011-05-24 03:48:49 +02:00
bool
checkRunningState() noexcept override
2011-05-24 03:48:49 +02:00
{
return play::OutputDirector::instance().isOperational();
2011-05-24 03:48:49 +02:00
}
};
namespace {
lib::Depend<SessionSubsystem> theSessionSubsystemLifecycle;
lib::Depend<PlayOutSubsysDescriptor> thePlayOutDescriptor;
}
/** @internal intended for use by main(). */
Subsys&
Facade::getSessionDescriptor()
{
return theSessionSubsystemLifecycle();
}
2011-05-24 03:48:49 +02:00
/** @internal intended for use by main(). */
Subsys&
Facade::getPlayOutDescriptor()
{
return thePlayOutDescriptor();
}
} // namespace proc