Skip to content

Commit

Permalink
tplay: graph manager now has a "do_end_of_play" command that has the …
Browse files Browse the repository at this point in the history
…effect of stopping the application due to playlist exhaustion (closes #47).
  • Loading branch information
juanrubio committed Apr 17, 2014
1 parent 8500400 commit 6dc26d8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
14 changes: 14 additions & 0 deletions tplay/src/tizgraphmgrfsm.hpp
Expand Up @@ -501,6 +501,19 @@ namespace tiz
}
};

struct do_end_of_play
{
template <class FSM,class EVT,class SourceState,class TargetState>
void operator()(EVT const& evt, FSM& fsm, SourceState& , TargetState& )
{
GMGR_FSM_LOG ();
if (fsm.pp_ops_ && *(fsm.pp_ops_))
{
(*(fsm.pp_ops_))->do_end_of_play ();
}
}
};

// guard conditions
struct is_fatal_error
{
Expand Down Expand Up @@ -540,6 +553,7 @@ namespace tiz
boost::msm::front::Row < starting , err_evt , restarting , boost::msm::front::none, boost::msm::front::euml::Not_<
is_fatal_error> >,
boost::msm::front::Row < starting , err_evt , stopped , do_report_fatal_error , is_fatal_error >,
boost::msm::front::Row < starting , graph_unlded_evt , stopped , do_end_of_play >,
// +------------------------------------------+-------------------------+-------------------------+------------------------+--------------------+
boost::msm::front::Row < running , next_evt , boost::msm::front::none , do_next >,
boost::msm::front::Row < running , prev_evt , boost::msm::front::none , do_prev >,
Expand Down
5 changes: 5 additions & 0 deletions tplay/src/tizgraphmgrops.cpp
Expand Up @@ -237,6 +237,11 @@ void graphmgr::ops::do_report_fatal_error (const OMX_ERRORTYPE error,
error_cback_ (error, msg);
}

void graphmgr::ops::do_end_of_play ()
{
error_cback_ (OMX_ErrorNoMore, "Playlist exhausted.");
}

bool graphmgr::ops::is_fatal_error (const OMX_ERRORTYPE error,
const std::string &msg) const
{
Expand Down
1 change: 1 addition & 0 deletions tplay/src/tizgraphmgrops.hpp
Expand Up @@ -100,6 +100,7 @@ namespace tiz
virtual void do_pause ();
virtual void do_report_fatal_error (const OMX_ERRORTYPE error,
const std::string &msg);
virtual void do_end_of_play ();
virtual bool is_fatal_error (const OMX_ERRORTYPE error,
const std::string &msg) const;

Expand Down
13 changes: 8 additions & 5 deletions tplay/src/tizgraphops.cpp
Expand Up @@ -454,11 +454,14 @@ bool graph::ops::is_end_of_play () const

assert (playlist_);

if (playlist_->loop_playback ()
|| !(playlist_->before_begin () || playlist_->past_end ()))
{
rc = false;
}
if (!playlist_->empty ())
{
if (playlist_->loop_playback ()
|| !(playlist_->before_begin () || playlist_->past_end ()))
{
rc = false;
}
}

TIZ_LOG (TIZ_PRIORITY_TRACE, "is_end_of_play [%s]...", rc ? "YES" : "NO");
return rc;
Expand Down
5 changes: 5 additions & 0 deletions tplay/src/tizplaylist.cpp
Expand Up @@ -348,6 +348,11 @@ int tiz::playlist::size () const
return uri_list_.size ();
}

bool tiz::playlist::empty () const
{
return uri_list_.empty ();
}

bool tiz::playlist::single_format () const
{
if (!uri_list_.empty ())
Expand Down
1 change: 1 addition & 0 deletions tplay/src/tizplaylist.hpp
Expand Up @@ -62,6 +62,7 @@ namespace tiz
const uri_lst_t &get_uri_list () const;
int current_index () const;
int size () const;
bool empty () const;
bool single_format () const;
bool before_begin () const;
bool past_end () const;
Expand Down

0 comments on commit 6dc26d8

Please sign in to comment.