Fixed MistPlayer CPU usage and benchmarking texts.
This commit is contained in:
parent
85e9416b02
commit
892dfa4e38
1 changed files with 12 additions and 2 deletions
|
@ -112,7 +112,7 @@ int main(int argc, char** argv){
|
||||||
|
|
||||||
bool meta_sent = false;
|
bool meta_sent = false;
|
||||||
int playUntil = -1;
|
int playUntil = -1;
|
||||||
long long now = 0; //for timing of sending packets
|
long long now, lastTime = 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;
|
||||||
|
@ -170,13 +170,16 @@ 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();
|
||||||
bool ret = source.seek_time(ms);
|
bool ret = source.seek_time(ms);
|
||||||
|
lasttime = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'p': { //play
|
case 'p': { //play
|
||||||
playing = -1;
|
playing = -1;
|
||||||
|
lasttime = 0;
|
||||||
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());
|
||||||
|
bench = Util::getMS();
|
||||||
}else{
|
}else{
|
||||||
playUntil = 0;
|
playUntil = 0;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +235,14 @@ int main(int argc, char** argv){
|
||||||
--playing;
|
--playing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( playUntil && playUntil <= source.getJSON()["time"].asInt()){
|
if (lastTime == 0){
|
||||||
|
lastTime = now - source.getJSON()["time"].asInt();
|
||||||
|
}
|
||||||
|
if (playing == -1 && playUntil == 0 && source.getJSON()["time"].asInt() > now - lastTime + 2500){
|
||||||
|
std::cerr << (source.getJSON()["time"].asInt() - (now - lastTime)) << " sleepytimes" << std::endl;
|
||||||
|
Util::sleep(source.getJSON()["time"].asInt() - (now - lastTime));
|
||||||
|
}
|
||||||
|
if ( playUntil && playUntil < source.getJSON()["time"].asInt()){
|
||||||
playing = 0;
|
playing = 0;
|
||||||
}
|
}
|
||||||
if (playing == 0){
|
if (playing == 0){
|
||||||
|
|
Loading…
Add table
Reference in a new issue