From 499cd48e839c282307e9b06d16bddcc16afc827b Mon Sep 17 00:00:00 2001 From: MoeMod Server #2 <824395314@qq.com> Date: Sun, 25 Dec 2022 02:47:10 +0800 Subject: [PATCH] filesystem: fix lseek for mpg123 --- engine/common/soundlib/snd_mp3.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/engine/common/soundlib/snd_mp3.c b/engine/common/soundlib/snd_mp3.c index 4b66664d..16e142f6 100644 --- a/engine/common/soundlib/snd_mp3.c +++ b/engine/common/soundlib/snd_mp3.c @@ -105,6 +105,16 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, fs_offset_t filesi return true; } +/* +================= +FS_SeekEx +================= +*/ +fs_offset_t FS_SeekEx( file_t *file, fs_offset_t offset, int whence ) +{ + return FS_Seek( file, offset, whence ) == -1 ? -1 : FS_Tell( file ); +} + /* ================= Stream_OpenMPG @@ -138,7 +148,7 @@ stream_t *Stream_OpenMPG( const char *filename ) if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg )); // trying to open stream and read header - if( !open_mpeg_stream( mpeg, file, (void*)FS_Read, (void*)FS_Seek, &sc )) + if( !open_mpeg_stream( mpeg, file, (void*)FS_Read, (void*)FS_SeekEx, &sc )) { Con_DPrintf( S_ERROR "Stream_OpenMPG: failed to load (%s): %s\n", filename, get_error( mpeg )); close_decoder( mpeg );