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)
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
23 #include "lib/thread.hpp"
24 
26 
27 
28 namespace steam {
29 namespace play {
30 
31 
32 
33  namespace { // hidden local details of the service implementation....
34 
35  } // (End) hidden service impl details
36 
37 
38 
41 
42 
50  : player_{PlayServiceHandle::NOT_YET_STARTED}
51  , shutdown_initiated_{false}
52  { }
53 
54  OutputDirector::~OutputDirector() { }
55 
56 
57 
62  bool
64  {
65  Lock sync{this};
66  REQUIRE (not shutdown_initiated_);
67 
68  player_.createInstance();
69  return this->isOperational();
70  }
71 
72 
74  bool
76  {
77  return bool(player_);
78  }
79 
80 
81 
90  void
91  OutputDirector::triggerDisconnect (SigTerm completedSignal) noexcept
92  {
93  if (not shutdown_initiated_)
94  {
95  shutdown_initiated_ = true;
96  launchDetached ("Output shutdown supervisor"
97  ,[=]{
98  bringDown (completedSignal);
99  });
100  }
101  }
102 
103 
113  void
114  OutputDirector::bringDown (SigTerm completedSignal)
115  {
116  Lock sync{this};
117  string problemLog;
118  if (not isOperational())
119  {
120  WARN (play, "Attempt to OutputDirector::bringDown() -- "
121  "which it is not in running state. Invocation ignored. "
122  "This indicates an error in Lifecycle logic.");
123  return;
124  }
125  try
126  {
127  TODO ("actually bring down the output generation");
128  player_.shutdown();
129 
130  completedSignal(0);
131  }
132 
133  catch (lumiera::Error& problem)
134  {
135  problemLog = problem.what();
136  lumiera_error(); // reset error state
137  completedSignal (&problemLog);
138  }
139  catch (...)
140  {
141  problemLog = "Unknown error while disconnecting output. "
142  "Lumiera error flag is = "+string(lumiera_error());
143  completedSignal (&problemLog);
144  }
145  }
146 
147 }} // 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:280
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:115
void launchDetached(ThreadHookable::Launch &&launchBuilder)
Launch an autonomous self-managing thread (and forget about it).
Definition: thread.hpp:742
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:62