mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
movies: fix for loading unseekable ogg vorbis files
Now, compressed/encrypted ogg files will properly be detected as unseekable, and will still be able to be played.
This commit is contained in:
parent
ca5b4e7b54
commit
00b3fbdb1a
@ -199,6 +199,22 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
|
// Vorbis uses a seek with offset 0 to determine whether seeking is
|
||||||
|
// supported, but this is not good enough. We seek to the end and back.
|
||||||
|
if (offset == 0) {
|
||||||
|
std::streambuf *buf = stream->rdbuf();
|
||||||
|
std::streampos pos = buf->pubseekoff(0, std::ios::cur, std::ios::in);
|
||||||
|
if (pos < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (buf->pubseekoff(0, std::ios::end, std::ios::in) >= 0) {
|
||||||
|
// It worked; seek back to the previous location.
|
||||||
|
buf->pubseekpos(pos, std::ios::in);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
stream->seekg(offset, std::ios::cur);
|
stream->seekg(offset, std::ios::cur);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user