Lumiera  0.pre.03
»edit your freedom«
output-director.cpp
Go to the documentation of this file.
1 /*
2  OutputDirector - handling all the real external output connections
3 
4  Copyright (C) Lumiera.org
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
32 #include "lib/thread.hpp"
33 
35 
36 
37 namespace steam {
38 namespace play {
39 
40 
41 
42  namespace { // hidden local details of the service implementation....
43 
44  } // (End) hidden service impl details
45 
46 
47 
50 
51 
59  : player_{PlayServiceHandle::NOT_YET_STARTED}
60  , shutdown_initiated_{false}
61  { }
62 
63  OutputDirector::~OutputDirector() { }
64 
65 
66 
71  bool
73  {
74  Lock sync{this};
75  REQUIRE (not shutdown_initiated_);
76 
77  player_.createInstance();
78  return this->isOperational();
79  }
80 
81 
83  bool
85  {
86  return bool(player_);
87  }
88 
89 
90 
99  void
100  OutputDirector::triggerDisconnect (SigTerm completedSignal) noexcept
101  {
102  if (not shutdown_initiated_)
103  {
104  shutdown_initiated_ = true;
105  launchDetached ("Output shutdown supervisor"
106  ,[=]{
107  bringDown (completedSignal);
108  });
109  }
110  }
111 
112 
122  void
123  OutputDirector::bringDown (SigTerm completedSignal)
124  {
125  Lock sync{this};
126  string problemLog;
127  if (not isOperational())
128  {
129  WARN (play, "Attempt to OutputDirector::bringDown() -- "
130  "which it is not in running state. Invocation ignored. "
131  "This indicates an error in Lifecycle logic.");
132  return;
133  }
134  try
135  {
136  TODO ("actually bring down the output generation");
137  player_.shutdown();
138 
139  completedSignal(0);
140  }
141 
142  catch (lumiera::Error& problem)
143  {
144  problemLog = problem.what();
145  lumiera_error(); // reset error state
146  completedSignal (&problemLog);
147  }
148  catch (...)
149  {
150  problemLog = "Unknown error while disconnecting output. "
151  "Lumiera error flag is = "+string(lumiera_error());
152  completedSignal (&problemLog);
153  }
154  }
155 
156 }} // namespace steam::play
void bringDown(SigTerm completedSignal)
A global service to coordinate and handle all external output activities.
Primary service of the Player subsystem: Starting and controlling render/playback.
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
OutputDirector()
bring up the framework for handling input/output connections.
bool connectUp()
connect and bring up the external input/output connections, handlers and interface services and the r...
lumiera_err lumiera_error(void)
Get and clear current error state.
Definition: error-state.c:124
void launchDetached(ThreadHookable::Launch &&launchBuilder)
Launch an autonomous self-managing thread (and forget about it).
Definition: thread.hpp:750
Convenience front-end to simplify and codify basic thread handling.
static lib::Depend< OutputDirector > instance
storage for the single application wide OutputDirector instance
A global service to handle all external output connections.
void triggerDisconnect(SigTerm) noexcept
initiate shutdown of all ongoing render/playback processes and closing of all external input/output i...
Interface and Base definition for all Lumiera Exceptions.
Definition: error.hpp:71