Lumiera  0.pre.03
»edit your freedom«
play-service.cpp
Go to the documentation of this file.
1 /*
2  PlayService - interface: render- and playback control
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/error.hpp"
24 #include "include/play-facade.hpp"
29 #include "lib/util-foreach.hpp"
30 
31 
32 #include <string>
33 //#include <memory>
35 #include <memory>
36 
37 
38 
39 namespace lumiera {
40 
41 
42  Play::~Play() { } // emit VTables here...
43 
46 
47 
48  namespace error {
49  LUMIERA_ERROR_DEFINE (CANT_PLAY, "unable to build playback or render process for this configuration");
50  }
51 }//(End) namespace lumiera
52 
53 
54 namespace steam {
55 namespace play {
56 
57 //using std::string;
58 //using lumiera::Subsys;
59 //using std::bind;
60  using lib::Sync;
61  using lib::RecursiveLock_NoWait;
62  using std::weak_ptr;
63  using std::bind;
64 //using std::function;
65  using std::placeholders::_1;
66  using util::remove_if;
67  using util::and_all;
68 
69 
70  namespace { // hidden local details of the service implementation....
71 
72 
73 
74 
75 
76 
77 
78  } // (End) hidden service impl details
79 
80  using lumiera::Play;
81 
82  typedef POutputManager Output;
83 
84 
85 
87  : public Sync<RecursiveLock_NoWait>
88  {
89  typedef weak_ptr<PlayProcess> Entry;
90  typedef std::vector<Entry> ProcTable;
91 
94  ProcTable processes_;
95 
96  public:
97 
99  establishProcess (PlayProcess* newProcess)
100  {
101  Play::Controller frontend;
102  try {
103  frontend.activate (newProcess, bind (&ProcessTable::endProcess, this, _1 ));
104  }
105  catch(...)
106  {
107  delete newProcess;
108  throw;
109  }
110 
111  Lock sync{this};
112  processes_.push_back (frontend); // keeping a weak-reference
113  return frontend;
114  }
115 
116 
117  bool
118  isActive() const
119  {
120  return not and_all (processes_, isDead);
121  }
122 
123  private:
124  void
125  endProcess (PlayProcess* dyingProcess)
126  {
128  delete dyingProcess;
129 
130  Lock sync{this};
131  remove_if (processes_, isDead);
132  }
133 
134  static bool
135  isDead (Entry const& e)
136  {
137  return e.expired();
138  }
139  };
140 
141 
142 
143 
144  PlayService::~PlayService()
145  {
146  if (pTable_->isActive())
147  {
148  UNIMPLEMENTED ("block waiting for any ongoing play processes. Ensure the process table is empty -- OR -- hand it over to some kind of cleanup service");
149  }
150  ENSURE (!pTable_->isActive());
151  }
152 
153 
160  PlayService::PlayService()
161  : pTable_(new ProcessTable)
162  { }
163 
164 
165 
166 
167 
180  PlayService::connect (ModelPorts dataGenerators, POutputManager outputPossibilities)
181  {
182  Timings playbackTimings (lib::time::FrameRate::PAL);
183 
184  return pTable_->establishProcess(
185  PlayProcess::initiate(dataGenerators,
186  buildRenderConfiguration(outputPossibilities, playbackTimings)));
187  }
188 
189 
190 
196 }} // namespace steam::play
197 
198 
199 namespace lumiera {
200 
201  /* ==== convenience shortcuts for creating a PlayProcess ==== */
202 
213  {
214  return this->connect (ports, output);
215  }
216 
217 
223  {
224  UNIMPLEMENTED ("build PlayProcess based on a set of pipes");
225  }
226 
227 
233  {
234  UNIMPLEMENTED ("build PlayProcess for a Timeline");
235  }
236 
237 
243  {
244  UNIMPLEMENTED ("build PlayProcess directly for a Viewer element");
245  }
246 
247 
253  {
254  UNIMPLEMENTED ("build PlayProcess for a single Fork");
255  }
256 
257 
263  {
264  UNIMPLEMENTED ("build virtual Timeline and PlayProcess to show a single Clip");
265  }
266 
267 
268 }
Facility for monitor object based locking.
Definition: sync.hpp:209
A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location w...
Definition: trait.hpp:82
Primary service of the Player subsystem: Starting and controlling render/playback.
Controller perform(ModelPorts, Output)
Generic point-of-Service for starting playback.
Strategy to hold all the detail knowledge necessary to establish a running render CalculationStream...
Generic frame timing specification.
Definition: timings.hpp:86
scoped guard to control the actual locking.
Definition: sync.hpp:226
bool and_all(CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
Accept binding for arbitrary function arguments.
Steam-Layer implementation namespace root.
virtual Controller connect(ModelPorts, POutputManager)
Implementation: build a PlayProcess.
Public access point to the playback service provided by the »play-out subsystem«
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:280
Playback/Render process within the Lumiera Player.
Interface to the Player subsystem of Lumiera (Steam-Layer).
Definition: play-facade.hpp:73
static lib::Depend< Play > facade
get an implementation instance of this service
Definition: play-facade.hpp:81
RenderConfigurator::ConnectFunction buildRenderConfiguration(POutputManager outputPossibilities, Timings playTimings)
Factory function to build a RenderConfigurator specifically tailored for a PlayProcess, about to be started.
Continuous playback process, which has been hooked up and started with a fixed set of output slots...
Definition: play-facade.hpp:98
bool remove_if(SET &set, FUN test)
remove all elements fulfilling a given predicate from a (sorted) set.
Definition: util.hpp:319
Lumiera error handling (C++ interface).
A global service to handle all external output connections.
Handle & activate(IMP *impl, DEL whenDead)
Activation of the handle by the managing service.
Definition: handle.hpp:112
Lumiera public interface.
Definition: advice.cpp:104
static PlayProcess * initiate(ModelPorts dataGenerators, FeedBuilder)
Factory: Initialise and configure a new PlayProcess.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition: trait.hpp:71
Perform operations "for each element" of a collection.
Organisational unit of an ongoing render- or playback process.
static const FrameRate PAL
predefined constant for PAL framerate
Definition: timevalue.hpp:671
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
Definition: error.h:71