diff options
author | Chris Robinson <[email protected]> | 2018-01-07 17:23:51 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-07 17:23:51 -0800 |
commit | c8a30592e81b5ae15a35a0e9f52c395fa75ca752 (patch) | |
tree | 990d5afcd79898279d15714dad6f887d619ea5d5 /examples/alffplay.cpp | |
parent | d8258984b48719ffabef812ea842f25713ae81b1 (diff) |
Only print the time in alffplay when it changes
Diffstat (limited to 'examples/alffplay.cpp')
-rw-r--r-- | examples/alffplay.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp index 42987b86..acd2e149 100644 --- a/examples/alffplay.cpp +++ b/examples/alffplay.cpp @@ -1467,7 +1467,7 @@ int MovieState::parse_handler() // Helper class+method to print the time with human-readable formatting. struct PrettyTime { - seconds_d64 mTime; + seconds mTime; }; inline std::ostream &operator<<(std::ostream &os, const PrettyTime &rhs) { @@ -1475,7 +1475,7 @@ inline std::ostream &operator<<(std::ostream &os, const PrettyTime &rhs) using minutes = std::chrono::minutes; using std::chrono::duration_cast; - seconds t = duration_cast<seconds>(rhs.mTime); + seconds t = rhs.mTime; if(t.count() < 0) { os << '-'; @@ -1636,13 +1636,19 @@ int main(int argc, char *argv[]) enum class EomAction { Next, Quit } eom_action = EomAction::Next; + seconds last_time(-1); SDL_Event event; while(1) { int have_evt = SDL_WaitEventTimeout(&event, 10); - std::cout<< "\r "<<PrettyTime{movState->getMasterClock()}<<" / "<< - PrettyTime{movState->getDuration()} <<std::flush; + auto cur_time = std::chrono::duration_cast<seconds>(movState->getMasterClock()); + if(cur_time != last_time) + { + auto end_time = std::chrono::duration_cast<seconds>(movState->getDuration()); + std::cout<< "\r "<<PrettyTime{cur_time}<<" / "<<PrettyTime{end_time} <<std::flush; + last_time = cur_time; + } if(!have_evt) continue; switch(event.type) @@ -1697,6 +1703,7 @@ int main(int argc, char *argv[]) case FF_MOVIE_DONE_EVENT: std::cout<<'\n'; + last_time = seconds(-1); if(eom_action != EomAction::Quit) { movState = nullptr; |