player: faster seek termination detection
Instead of hanging when the gap between two frames is larger than 100ms, terminate after 5 times of trying.
This commit is contained in:
parent
25b1d31b00
commit
25300c48cd
1 changed files with 6 additions and 1 deletions
|
@ -76,8 +76,10 @@ namespace Player{
|
||||||
DTSC::Stream * tmpStream = new DTSC::Stream(1);
|
DTSC::Stream * tmpStream = new DTSC::Stream(1);
|
||||||
unsigned long leftByte = 1, rightByte = fileSize;
|
unsigned long leftByte = 1, rightByte = fileSize;
|
||||||
unsigned int leftMS = 0, rightMS = INT_MAX;
|
unsigned int leftMS = 0, rightMS = INT_MAX;
|
||||||
|
unsigned long foundRange = 0;//leftMS concatenated with rightMS
|
||||||
|
int lastOccurences = 0;//times that foundRange stayed the same during an iteration
|
||||||
/// \todo set last packet as last byte, consider metadata
|
/// \todo set last packet as last byte, consider metadata
|
||||||
while (rightMS - leftMS >= 100 && leftMS + 100 <= miliseconds){
|
while (lastOccurences < 5){//assume that we have found the position if the boundaries do not in 5 times
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
// binary search: pick the first packet on the right
|
// binary search: pick the first packet on the right
|
||||||
unsigned long medByte = leftByte + (rightByte - leftByte) / 2;
|
unsigned long medByte = leftByte + (rightByte - leftByte) / 2;
|
||||||
|
@ -112,6 +114,9 @@ namespace Player{
|
||||||
leftByte = medByte;
|
leftByte = medByte;
|
||||||
leftMS = medMS;
|
leftMS = medMS;
|
||||||
}
|
}
|
||||||
|
//concatenate leftMS with rightMS
|
||||||
|
unsigned long sum = ((unsigned long)leftMS << (CHAR_BIT * sizeof(leftMS))) | rightMS;
|
||||||
|
if (foundRange == sum){++lastOccurences;}else{foundRange = sum;lastOccurences = 0;}
|
||||||
}
|
}
|
||||||
seekDone:
|
seekDone:
|
||||||
// clear the buffer and adjust file pointer
|
// clear the buffer and adjust file pointer
|
||||||
|
|
Loading…
Add table
Reference in a new issue