From 2d7a3b1f0d80384b79169c818be24e5bf021c641 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 24 Sep 2012 15:04:58 +0200 Subject: [PATCH] Added workaround for cygwin bug. Fixed end of file not stopping playback in MistPlayer. --- src/player.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/player.cpp b/src/player.cpp index dab3acd7..3aaaf439 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -11,6 +11,18 @@ #include #include +//under cygwin, recv blocks for ~15ms if no data is available. +//This is a hack to keep performance decent with that bug present. +#ifdef __CYGWIN__ +#define CYG_DEFI int cyg_count; +#define CYG_INCR cyg_count++; +#define CYG_LOOP && (cyg_count % 20 == 0) +#else +#define CYG_DEFI +#define CYG_INCR +#define CYG_LOOP +#endif + /// Copy of stats from buffer_user.cpp class Stats{ public: @@ -83,9 +95,11 @@ int main(int argc, char** argv){ long long now, lastTime = 0;//for timing of sending packets long long bench = 0;//for benchmarking Stats sts; + CYG_DEFI while (in_out.connected() && std::cin.good() && std::cout.good() && (Util::epoch() - lasttime < 60)){ - if (in_out.spool()){ + CYG_INCR + if (in_out.spool() CYG_LOOP){ while (in_out.Received().size()){ //delete anything that doesn't end with a newline if (*(in_out.Received().get().rbegin()) != '\n'){ @@ -160,6 +174,7 @@ int main(int argc, char** argv){ if (playing != 0){ now = Util::getMS(); source.seekNext(); + if (!source.getJSON()){playing = 0;} if (source.getJSON().isMember("keyframe")){ if (playing == -1 && meta["video"]["keyms"].asInt() > now-lastTime) { Util::sleep(meta["video"]["keyms"].asInt()-(now-lastTime));