MistPlayer - now with even more sanity!
This commit is contained in:
parent
8844f8691a
commit
54196c43c8
1 changed files with 14 additions and 14 deletions
|
@ -107,22 +107,22 @@ int main(int argc, char** argv){
|
||||||
JSON::Value pausemark;
|
JSON::Value pausemark;
|
||||||
pausemark["trackid"] = 0ll;
|
pausemark["trackid"] = 0ll;
|
||||||
pausemark["mark"] = "pause";
|
pausemark["mark"] = "pause";
|
||||||
pausemark["time"] = (long long int)0;
|
pausemark["time"] = 0ll;
|
||||||
|
|
||||||
Socket::Connection StatsSocket = Socket::Connection(Util::getTmpFolder() + "statistics", true);
|
Socket::Connection StatsSocket = Socket::Connection(Util::getTmpFolder() + "statistics", true);
|
||||||
int lasttime = Util::epoch(); //time last packet was sent
|
int lastSent = Util::epoch(); //time last packet was sent
|
||||||
|
|
||||||
JSON::Value last_pack;
|
JSON::Value last_pack;
|
||||||
|
|
||||||
bool meta_sent = false;
|
bool meta_sent = false;
|
||||||
int playUntil = -1;
|
int playUntil = -1;
|
||||||
long long now, lastTime = 0; //for timing of sending packets
|
long long now, prevTimestamp = 0; //for timing of sending packets
|
||||||
long long bench = 0; //for benchmarking
|
long long bench = 0; //for benchmarking
|
||||||
std::set<int> newSelect;
|
std::set<int> newSelect;
|
||||||
Stats sts;
|
Stats sts;
|
||||||
CYG_DEFI
|
CYG_DEFI
|
||||||
|
|
||||||
while (in_out.connected() && (Util::epoch() - lasttime < 60) && conf.is_active){
|
while (in_out.connected() && (Util::epoch() - lastSent < 60) && conf.is_active){
|
||||||
CYG_INCR
|
CYG_INCR
|
||||||
if (CYG_LOOP in_out.spool()){
|
if (CYG_LOOP in_out.spool()){
|
||||||
while (in_out.Received().size()){
|
while (in_out.Received().size()){
|
||||||
|
@ -175,18 +175,18 @@ int main(int argc, char** argv){
|
||||||
case 's': { //second-seek
|
case 's': { //second-seek
|
||||||
int ms = JSON::Value(in_out.Received().get().substr(2)).asInt();
|
int ms = JSON::Value(in_out.Received().get().substr(2)).asInt();
|
||||||
source.seek_time(ms);
|
source.seek_time(ms);
|
||||||
lasttime = Util::epoch();
|
lastSent = Util::epoch();
|
||||||
lastTime = 0;
|
prevTimestamp = 0;
|
||||||
playUntil = 0;
|
playUntil = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'p': { //play
|
case 'p': { //play
|
||||||
playing = -1;
|
playing = -1;
|
||||||
lasttime = Util::epoch();
|
lastSent = Util::epoch();
|
||||||
in_out.setBlocking(false);
|
in_out.setBlocking(false);
|
||||||
if (in_out.Received().get().size() >= 2){
|
if (in_out.Received().get().size() >= 2){
|
||||||
playUntil = atoi(in_out.Received().get().substr(2).c_str());
|
playUntil = atoi(in_out.Received().get().substr(2).c_str());
|
||||||
lastTime = 0;
|
prevTimestamp = 0;
|
||||||
bench = Util::getMS();
|
bench = Util::getMS();
|
||||||
}else{
|
}else{
|
||||||
playUntil = 0;
|
playUntil = 0;
|
||||||
|
@ -241,11 +241,11 @@ int main(int argc, char** argv){
|
||||||
if (playing > 0 && source.atKeyframe()){
|
if (playing > 0 && source.atKeyframe()){
|
||||||
--playing;
|
--playing;
|
||||||
}
|
}
|
||||||
if (lastTime == 0){
|
if (prevTimestamp == 0){
|
||||||
lastTime = now - source.getJSON()["time"].asInt();
|
prevTimestamp = now - source.getJSON()["time"].asInt();
|
||||||
}
|
}
|
||||||
if (playing == -1 && playUntil == 0 && source.getJSON()["time"].asInt() > now - lastTime + 7500){
|
if (playing == -1 && playUntil == 0 && source.getJSON()["time"].asInt() > now - prevTimestamp + 7500){
|
||||||
Util::sleep(source.getJSON()["time"].asInt() - (now - lastTime + 5000));
|
Util::sleep(source.getJSON()["time"].asInt() - (now - prevTimestamp + 5000));
|
||||||
}
|
}
|
||||||
if ( playUntil && playUntil <= source.getJSON()["time"].asInt()){
|
if ( playUntil && playUntil <= source.getJSON()["time"].asInt()){
|
||||||
playing = 0;
|
playing = 0;
|
||||||
|
@ -256,7 +256,7 @@ int main(int argc, char** argv){
|
||||||
pausemark.sendTo(in_out);
|
pausemark.sendTo(in_out);
|
||||||
in_out.setBlocking(true);
|
in_out.setBlocking(true);
|
||||||
}else{
|
}else{
|
||||||
lasttime = Util::epoch();
|
lastSent = Util::epoch();
|
||||||
source.getJSON().sendTo(in_out);
|
source.getJSON().sendTo(in_out);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
Loading…
Add table
Reference in a new issue