Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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"
29#include "lib/util-foreach.hpp"
30
31
32#include <string>
33//#include <memory>
35#include <memory>
36
37
38
39namespace 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
54namespace steam {
55namespace 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
83
84
85
87 : public Sync<RecursiveLock_NoWait>
88 {
89 typedef weak_ptr<PlayProcess> Entry;
90 typedef std::vector<Entry> ProcTable;
91
95
96 public:
97
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
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
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
199namespace lumiera {
200
201 /* ==== convenience shortcuts for creating a PlayProcess ==== */
202
211 Play::Controller
213 {
214 return this->connect (ports, output);
215 }
216
217
222 Play::perform (Pipes, Output)
223 {
224 UNIMPLEMENTED ("build PlayProcess based on a set of pipes");
225 }
226
227
231 Play::Controller
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}
Access point to singletons and other kinds of dependencies designated by type.
Definition depend.hpp:281
Handle & activate(IMP *impl, DEL whenDead)
Activation of the handle by the managing service.
Definition handle.hpp:112
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition p.hpp:77
scoped guard to control the actual locking.
Definition sync.hpp:228
Facility for monitor object based locking.
Definition sync.hpp:210
static const FrameRate PAL
predefined constant for PAL framerate
Continuous playback process, which has been hooked up and started with a fixed set of output slots.
Interface to the Player subsystem of Lumiera (Steam-Layer).
steam::play::POutputManager Output
static lib::Depend< Play > facade
get an implementation instance of this service
Controller perform(ModelPorts, Output)
Generic point-of-Service for starting playback.
virtual Controller connect(ModelPorts, Output)=0
core operation: create a new playback process outputting to the given viewer/display
virtual ~Play()
A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location w...
Playback/Render process within the Lumiera Player.
static PlayProcess * initiate(ModelPorts dataGenerators, FeedBuilder)
Factory: Initialise and configure a new PlayProcess.
std::unique_ptr< ProcessTable > pTable_
PlayService()
bring up the global render- and playback service.
virtual Controller connect(ModelPorts, POutputManager)
Implementation: build a PlayProcess.
Play::Controller establishProcess(PlayProcess *newProcess)
static bool isDead(Entry const &e)
void endProcess(PlayProcess *dyingProcess)
std::vector< Entry > ProcTable
weak_ptr< PlayProcess > Entry
Generic frame timing specification.
Definition timings.hpp:87
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
Definition error.h:71
Lumiera error handling (C++ interface).
Lumiera public interface.
Definition advice.hpp:102
RenderConfigurator::ConnectFunction buildRenderConfiguration(POutputManager outputPossibilities, Timings playTimings)
Factory function to build a RenderConfigurator specifically tailored for a PlayProcess,...
POutputManager Output
shared_ptr< OutputManager > POutputManager
Steam-Layer implementation namespace root.
bool remove_if(SET &set, FUN test)
remove all elements fulfilling a given predicate from a (sorted) set.
Definition util.hpp:319
bool and_all(IT i, IT end, FUN predicate)
All quantification: check if all elements of a collection satisfy the given predicate.
A global service to handle all external output connections.
Public access point to the playback service provided by the »play-out subsystem«
Organisational unit of an ongoing render- or playback process.
Primary service of the Player subsystem: Starting and controlling render/playback.
Strategy to hold all the detail knowledge necessary to establish a running render CalculationStream.
Perform operations "for each element" of a collection.