Fix the OGG codec code to deal with OGGs in

pak files
This commit is contained in:
Eric Wasylishen 2011-01-19 16:04:03 -07:00
parent 1276aa62cd
commit 01556256fa
3 changed files with 7 additions and 4 deletions

View File

@ -226,6 +226,8 @@ snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec)
stream->codec = codec;
stream->file = hnd;
stream->length = length;
stream->startpos = Sys_FileTell(hnd);
return stream;
}

View File

@ -44,6 +44,7 @@ typedef struct snd_stream_s
snd_info_t info;
int length;
int pos;
int startpos;
void *ptr;
} snd_stream_t;

View File

@ -127,7 +127,7 @@ int S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence)
{
// set the file position in the actual file with the Q3 function
errno = 0;
Sys_FileSeek(stream->file, (long) offset);
Sys_FileSeek(stream->file, (long) stream->startpos + (long) offset);
// something has gone wrong, so we return here
if(errno != 0)
@ -144,7 +144,7 @@ int S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence)
{
// set the file position in the actual file with the Q3 function
errno = 0;
Sys_FileSeek(stream->file, (long) stream->pos + (long) offset);
Sys_FileSeek(stream->file, (long) stream->startpos + (long) stream->pos + (long) offset);
// something has gone wrong, so we return here
if(errno != 0)
@ -164,7 +164,7 @@ int S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence)
// set the file position in the actual file with the Q3 function
errno = 0;
Sys_FileSeek(stream->file, (long) stream->length + (long) offset);
Sys_FileSeek(stream->file, (long) stream->startpos + (long) stream->length + (long) offset);
// something has gone wrong, so we return here
if(errno != 0)
@ -214,7 +214,7 @@ long S_OGG_Callback_tell(void *datasource)
// snd_stream_t in the generic pointer
stream = (snd_stream_t *) datasource;
return (long) Sys_FileTell(stream->file);
return (long) Sys_FileTell(stream->file) - (long) stream->startpos;
}
// the callback structure