less whacking on the disk during seek to zero. prettier debug output. :-)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6641 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1b89aa98ff
commit
65a8a591f1
@ -323,17 +323,21 @@ OggSeekable::Seek(uint32 seekTo, int64 *frame, bigtime_t *time)
|
||||
// how to handle this?
|
||||
}
|
||||
|
||||
// binary search to find our place
|
||||
int64 left_granulepos = 0;
|
||||
off_t right = GetLastPagePosition();
|
||||
int64 right_granulepos = 0;
|
||||
// if not the first, perform a binary search
|
||||
if (granulepos != fFirstGranulepos) {
|
||||
// binary search to find our place
|
||||
off_t right = GetLastPagePosition();
|
||||
uint width = (uint)log10(max_c(1, fFirstGranulepos + right)) + 2;
|
||||
while (true) {
|
||||
TRACE(" Seek: [%llu,%llu]: ", left, right);
|
||||
ogg_sync_reset(&fSync);
|
||||
ogg_stream_reset(&fStreamState);
|
||||
if (right - left > B_PAGE_SIZE) {
|
||||
TRACE(" Seek: [%*lld,%*lld]: ", width, left, width, right);
|
||||
fPosition = (right + left) / 2;
|
||||
} else {
|
||||
TRACE(" Seek: [%*lld,...]\n", width, left);
|
||||
fPosition = left;
|
||||
break;
|
||||
}
|
||||
@ -348,8 +352,8 @@ OggSeekable::Seek(uint32 seekTo, int64 *frame, bigtime_t *time)
|
||||
return B_ERROR;
|
||||
}
|
||||
} while (ogg_page_granulepos(&page) == -1);
|
||||
TRACE("granulepos = %lld, ", ogg_page_granulepos(&page));
|
||||
TRACE("fPosition = %llu\n", fPosition);
|
||||
TRACE("granulepos = %*lld, ", width, ogg_page_granulepos(&page));
|
||||
TRACE("fPosition = %*llu\n", width, fPosition);
|
||||
// check the granulepos of the page against the requested frame
|
||||
if (ogg_page_granulepos(&page) < granulepos) {
|
||||
// The packet that the frame is in is someplace after
|
||||
@ -365,6 +369,7 @@ OggSeekable::Seek(uint32 seekTo, int64 *frame, bigtime_t *time)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if not the first, look for a granulepos in a packet
|
||||
if (granulepos != fFirstGranulepos) {
|
||||
|
Loading…
Reference in New Issue
Block a user