Skip to content

Commit

Permalink
Revert preparation event support
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlivio committed Jan 6, 2023
1 parent 23c213f commit c8b991d
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 442 deletions.
7 changes: 0 additions & 7 deletions lib/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ Event::getFullId ()
return obj_id + "<" + _id + ">";
case Event::LOOKAT:
return obj_id + "<lookat>";
case Event::PREPARATION:
if (_id == "@lambda")
return obj_id + "$" + _id.substr (1, _id.length () - 1);
else
return obj_id + "$" + _id;
default:
g_assert_not_reached ();
}
Expand Down Expand Up @@ -254,8 +249,6 @@ Event::getEventTypeAsString (Event::Type type)
return "attribution";
case Event::SELECTION:
return "selection";
case Event::PREPARATION:
return "preparation";
case Event::LOOKAT:
return "lookAt";
default:
Expand Down
11 changes: 2 additions & 9 deletions lib/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,8 @@ class Event
* directed to the object.
*/
SELECTION,

/**
* @brief Preparation event.
*
* Stands for the preparation of a specific time interval of the object.
*/
PREPARATION,

/**

/**
* @brief lookAt event.
*
* Stands for the user viewport is on the objet.
Expand Down
2 changes: 1 addition & 1 deletion lib/Formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ Formatter::sendTick (uint64_t total, uint64_t diff, uint64_t frame)
// Formatter::sendKeyEvent() applies here. The difference is that ticks
// should only be propagated to objects that are occurring.
for (auto obj : *_doc->getObjects ())
if (obj->isOccurring () || obj->isPreparing ())
if (obj->isOccurring ())
buf.push_back (obj);
for (auto obj : buf)
obj->sendTick (total, diff, frame);
Expand Down
86 changes: 10 additions & 76 deletions lib/Media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ GINGA_NAMESPACE_BEGIN
Media::Media (const string &id) : Object (id)
{
_player = nullptr;
_currentPreparationEvent = nullptr;
}

Media::~Media ()
Expand Down Expand Up @@ -142,20 +141,6 @@ Media::sendTick (Time total, Time diff, Time frame)
{
Time dur;

if (this->isPreparing ())
{
g_assert_nonnull (_player);

if (_player->getPrepared () )
{
TRACE ("_player->getPrepared true");
Event *currentPreparation = this->getCurrentPreparationEvent ();
g_assert_nonnull (currentPreparation);
_doc->evalAction (currentPreparation, Event::STOP);
return;
}
}

// Update object time.
Object::sendTick (total, diff, frame);

Expand Down Expand Up @@ -202,11 +187,19 @@ Media::beforeTransition (Event *evt, Event::Transition transition)
{ // Lambda
Formatter *fmt;

createPlayer ();

g_assert (_doc->getData ("formatter", (void **) &fmt));
g_assert_null (_player);
_player = Player::createPlayer (
fmt, this, _properties["uri"], _properties["type"]);
if (unlikely (_player == nullptr))
return false; // fail

for (auto it : _properties)
_player->setProperty (it.first, it.second);

g_assert_nonnull (_player);
// Start underlying player.
// TODO: Check player failure.
_player->start (); // Just lambda events reaches this!
}
else
Expand Down Expand Up @@ -313,9 +306,6 @@ Media::beforeTransition (Event *evt, Event::Transition transition)
case Event::SELECTION:
break; // nothing to do

case Event::PREPARATION:
break; // nothing to do

case Event::LOOKAT:
break; // nothing to do

Expand Down Expand Up @@ -470,41 +460,6 @@ Media::afterTransition (Event *evt, Event::Transition transition)
}
break;
}
case Event::PREPARATION:
{
switch (transition)
{
case Event::START:
TRACE ("start %s", evt->getFullId ().c_str ());

createPlayer ();

if(evt->getId() != "@lambda")
{
Time begin, end;
evt->getInterval(&begin, &end);

string offsetStart = xstrbuild ("%" G_GUINT64_FORMAT, begin / GINGA_SECOND);

string offsetEnd = xstrbuild ("%" G_GUINT64_FORMAT, end / GINGA_SECOND);

_player->setProperty("offsetBuffer", offsetStart);
_player->setProperty("offsetEndBuffer",offsetEnd);
}

_player->startPreparation();
_isPreparing = true;
_currentPreparationEvent = evt;
break;
case Event::STOP:
TRACE ("stop %s", evt->getFullId ().c_str ());
_isPreparing = false;
break;
default:
g_assert_not_reached ();
}
break;
}
case Event::LOOKAT:
switch (transition)
{
Expand All @@ -525,27 +480,6 @@ Media::afterTransition (Event *evt, Event::Transition transition)
return true;
}

Event *
Media::getCurrentPreparationEvent ()
{
return _currentPreparationEvent;
}

void
Media::createPlayer ()
{
if (_player)
return;
Formatter *fmt;
g_assert (_doc->getData ("formatter", (void **) &fmt));
g_assert_null (_player);
_player = Player::createPlayer (fmt, this, _properties["uri"],
_properties["type"]);
g_assert_nonnull (_player);
for (auto it : _properties)
_player->setProperty (it.first, it.second);
}

// Public.

bool
Expand Down
3 changes: 0 additions & 3 deletions lib/Media.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ class Media : public Object

// Media:
virtual bool isFocused ();
virtual Event *getCurrentPreparationEvent ();
virtual bool getZ (int *, int *);
virtual void redraw (cairo_t *);

protected:
Player *_player; // underlying player
Event *_currentPreparationEvent;

void createPlayer ();
void doStop () override;
};

Expand Down
42 changes: 0 additions & 42 deletions lib/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Object::Object (const string &id) : _id (id)
_doc = nullptr;
_parent = nullptr;
_time = GINGA_TIME_NONE;
_isPreparing = false;

this->addPresentationEvent ("@lambda", 0, GINGA_TIME_NONE);
_lambda = this->getPresentationEvent ("@lambda");
Expand Down Expand Up @@ -137,11 +136,6 @@ Object::toString ()
+ Event::getEventStateAsString (evt->getState ())
+ ')');
break;
case Event::PREPARATION:
prep.push_back (evt->getId () + " ("
+ Event::getEventStateAsString (evt->getState ())
+ ')');
break;
default:
g_assert_not_reached ();
}
Expand Down Expand Up @@ -288,36 +282,6 @@ Object::addSelectionEvent (const string &key)
_events.insert (evt);
}

Event *
Object::getPreparationEvent (const string &key)
{
return this->getEvent (Event::PREPARATION, key);
}

void
Object::addPreparationEvent (const string &id)
{
Event *evt;
if (this->getPreparationEvent (id))
return;

evt = new Event (Event::PREPARATION, this, id);
_events.insert (evt);
}

void
Object::addPreparationEvent (const string &id, Time begin, Time end)
{
Event *evt;

if (this->getPreparationEvent (id))
return;

evt = new Event (Event::PREPARATION, this, id);
evt->setInterval (begin, end);
_events.insert (evt);
}

Event *
Object::getLookAtEvent (const string &id)
{
Expand Down Expand Up @@ -349,12 +313,6 @@ Object::isOccurring ()
return _lambda->getState () == Event::OCCURRING;
}

bool
Object::isPreparing ()
{
return _isPreparing;
}

bool
Object::isPaused ()
{
Expand Down
6 changes: 0 additions & 6 deletions lib/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ class Object
void addPresentationEvent (const string &, const string &);
Event *getSelectionEvent (const string &);
void addSelectionEvent (const string &);
Event *getPreparationEvent (const string &);
void addPreparationEvent (const string &);
void addPreparationEvent (const string &, Time, Time);
Event *getLookAtEvent (const string &);
void addLookAtEvent (const string &);

Expand Down Expand Up @@ -110,10 +107,7 @@ class Object
*/
virtual bool afterTransition (Event *, Event::Transition) = 0;

virtual bool isPreparing ();

protected:
bool _isPreparing;
string _id; // id
Document *_doc; // parent document
Composition *_parent; // parent object
Expand Down
25 changes: 0 additions & 25 deletions lib/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,22 +894,12 @@ static map<string, pair<Event::Type, Event::Transition> >
{ "onLookAway", { Event::LOOKAT, Event::STOP } },
{ "onBeginSelection", { Event::SELECTION, Event::START } },
{ "onEndSelection", { Event::SELECTION, Event::STOP } },
{ "onBeginPreparation", { Event::PREPARATION, Event::START } },
{ "onEndPreparation", { Event::PREPARATION, Event::STOP } },
{ "onAbortPreparation", { Event::PREPARATION, Event::ABORT } },
{ "onPausePreparation", { Event::PREPARATION, Event::PAUSE } },
{ "onResumePreparation", { Event::PREPARATION, Event::RESUME } },
{ "start", { Event::PRESENTATION, Event::START } }, // actions
{ "stop", { Event::PRESENTATION, Event::STOP } },
{ "abort", { Event::PRESENTATION, Event::ABORT } },
{ "pause", { Event::PRESENTATION, Event::PAUSE } },
{ "resume", { Event::PRESENTATION, Event::RESUME } },
{ "set", { Event::ATTRIBUTION, Event::START } },
{ "startPreparation", { Event::PREPARATION, Event::START } },
{ "stopPreparation", { Event::PREPARATION, Event::STOP } },
{ "abortPreparation", { Event::PREPARATION, Event::ABORT } },
{ "pausePreparation", { Event::PREPARATION, Event::PAUSE } },
{ "resumePreparation", { Event::PREPARATION, Event::RESUME } },
};

/// Index reserved role table.
Expand All @@ -933,7 +923,6 @@ static map<string, Event::Type> parser_syntax_event_type_table = {
{ "attribution", Event::ATTRIBUTION },
{ "selection", Event::SELECTION },
{ "lookat", Event::LOOKAT },
{ "preparation", Event::PREPARATION },
};

/// Known transitions.
Expand Down Expand Up @@ -2776,19 +2765,6 @@ borderColor='%s'}",
act.event->setParameter ("key", act.value);
break;
}
case Event::PREPARATION:
{
string eventId = evt->getId ();

if (eventId == "@lambda")
{
obj->addPreparationEvent (eventId);
}

act.event = obj->getPreparationEvent (eventId);
g_assert_nonnull (act.event);
break;
}
case Event::LOOKAT:
{
string eventId = evt->getId ();
Expand Down Expand Up @@ -4097,7 +4073,6 @@ ParserState::pushArea (ParserState *st, ParserElt *elt)
}

media->addPresentationEvent (id, begin, end);
media->addPreparationEvent (id, begin, end);
}

return true;
Expand Down
Loading

0 comments on commit c8b991d

Please sign in to comment.