mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix buffer queue when filled in one shot.
It would mod by the size and think it was empty, even though it had plenty of data. This could happen if a game creates a ringbuffer with 512 packets and then does a single put operation with 512 packets. Such behavior is rare though, since it will cause lag in starting the video.
This commit is contained in:
parent
628426bbd4
commit
7287da38cb
1 changed files with 13 additions and 8 deletions
|
@ -49,7 +49,11 @@ struct BufferQueue {
|
|||
}
|
||||
|
||||
inline int getQueueSize() {
|
||||
return (end + bufQueueSize - start) % bufQueueSize;
|
||||
if (end >= start) {
|
||||
return end - start;
|
||||
} else {
|
||||
return bufQueueSize + end - start;
|
||||
}
|
||||
}
|
||||
|
||||
inline int getRemainSize() {
|
||||
|
@ -63,12 +67,13 @@ struct BufferQueue {
|
|||
return false;
|
||||
if (end + addsize <= bufQueueSize) {
|
||||
memcpy(bufQueue + end, buf, addsize);
|
||||
end += addsize;
|
||||
} else {
|
||||
int size = bufQueueSize - end;
|
||||
memcpy(bufQueue + end, buf, size);
|
||||
memcpy(bufQueue, buf + size, addsize - size);
|
||||
int firstSize = bufQueueSize - end;
|
||||
memcpy(bufQueue + end, buf, firstSize);
|
||||
memcpy(bufQueue, buf + firstSize, addsize - firstSize);
|
||||
end = addsize - firstSize;
|
||||
}
|
||||
end = (end + addsize) % bufQueueSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -82,9 +87,9 @@ struct BufferQueue {
|
|||
if (start + bytesgot <= bufQueueSize) {
|
||||
memcpy(buf, bufQueue + start, bytesgot);
|
||||
} else {
|
||||
int size = bufQueueSize - start;
|
||||
memcpy(buf, bufQueue + start, size);
|
||||
memcpy(buf + size, bufQueue, bytesgot - size);
|
||||
int firstSize = bufQueueSize - start;
|
||||
memcpy(buf, bufQueue + start, firstSize);
|
||||
memcpy(buf + firstSize, bufQueue, bytesgot - firstSize);
|
||||
}
|
||||
}
|
||||
start = (start + bytesgot) % bufQueueSize;
|
||||
|
|
Loading…
Add table
Reference in a new issue