mirror of
https://github.com/taglib/taglib.git
synced 2026-01-30 20:10:17 -05:00
Fix reading of last page in ogg stream
When trying to read a packet from the last page the readPages() method would return false for all packets on the last page. Move the lastPage check just before trying to create the next page, and after the packetIndex check of the last fetched page.
This commit is contained in:
committed by
Urs Fleisch
parent
b4a4b42254
commit
8c7d3368da
@ -191,13 +191,16 @@ bool Ogg::File::readPages(unsigned int i)
|
||||
const Page *page = d->pages.back();
|
||||
packetIndex = nextPacketIndex(page);
|
||||
offset = page->fileOffset() + page->size();
|
||||
|
||||
// Enough pages have been fetched.
|
||||
if(packetIndex > i) {
|
||||
return true;
|
||||
}
|
||||
else if(page->header()->lastPageOfStream()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Enough pages have been fetched.
|
||||
|
||||
if(packetIndex > i)
|
||||
return true;
|
||||
|
||||
// Read the next page and add it to the page list.
|
||||
|
||||
auto nextPage = new Page(this, offset);
|
||||
@ -208,9 +211,6 @@ bool Ogg::File::readPages(unsigned int i)
|
||||
|
||||
nextPage->setFirstPacketIndex(packetIndex);
|
||||
d->pages.append(nextPage);
|
||||
|
||||
if(nextPage->header()->lastPageOfStream())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user