Those last two commit, but slightly better.

This commit is contained in:
Thulinma 2013-07-23 16:23:52 +02:00
parent 9cdf8d92a1
commit 588e171733
2 changed files with 33 additions and 27 deletions

View file

@ -206,6 +206,8 @@ void DTSC::Stream::addPacket(JSON::Value & newPack){
newPos.seekTime = lastPos.seekTime+1; newPos.seekTime = lastPos.seekTime+1;
} }
} }
}else{
buffers.clear();
} }
std::string newTrack = trackMapping[newPos.trackID]; std::string newTrack = trackMapping[newPos.trackID];
while (buffers.count(newPos) > 0){ while (buffers.count(newPos) > 0){
@ -237,10 +239,10 @@ void DTSC::Stream::addPacket(JSON::Value & newPack){
} }
int keySize = metadata["tracks"][newTrack]["keys"].size(); int keySize = metadata["tracks"][newTrack]["keys"].size();
if (buffercount > 1){ if (buffercount > 1){
metadata["tracks"][newTrack]["lastms"] = newPack["time"];
#define prevKey metadata["tracks"][newTrack]["keys"][keySize - 1] #define prevKey metadata["tracks"][newTrack]["keys"][keySize - 1]
if (newPack.isMember("keyframe") || !keySize || (datapointertype != VIDEO && newPack["time"].asInt() - 2000 > prevKey["time"].asInt())){ if (newPack.isMember("keyframe") || !keySize || (datapointertype != VIDEO && newPack["time"].asInt() - 2000 > prevKey["time"].asInt())){
updateMeta = true; updateMeta = true;
metadata["tracks"][newTrack]["lastms"] = newPack["time"];
keyframes[newPos.trackID].insert(newPos); keyframes[newPos.trackID].insert(newPos);
JSON::Value key; JSON::Value key;
key["time"] = newPack["time"]; key["time"] = newPack["time"];

View file

@ -91,11 +91,14 @@ void Util::Procs::childsig_handler(int signum){
return; return;
} }
int status; int status;
pid_t ret = waitpid( -1, &status, 0); pid_t ret = -1;
if (ret <= 0){ while (ret != 0){
childsig_handler(signum); ret = waitpid( -1, &status, WNOHANG);
if (ret <= 0){ //ignore, would block otherwise
if (ret == 0 || errno != EINTR){
return; return;
} }
}
int exitcode; int exitcode;
if (WIFEXITED(status)){ if (WIFEXITED(status)){
exitcode = WEXITSTATUS(status); exitcode = WEXITSTATUS(status);
@ -126,6 +129,7 @@ void Util::Procs::childsig_handler(int signum){
#endif #endif
tn(ret, exitcode); tn(ret, exitcode);
} }
}
} }
/// Attempts to run the command cmd. /// Attempts to run the command cmd.