engine: soundlib: libmpg: fix the inconsistent use of offset types in lseek()
This commit is contained in:
parent
27f7d2c8d2
commit
caf14c1b7c
4 changed files with 19 additions and 12 deletions
|
@ -87,7 +87,7 @@ int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavin
|
||||||
|
|
||||||
if( !mh || !sc ) return 0;
|
if( !mh || !sc ) return 0;
|
||||||
|
|
||||||
ret = mpg123_replace_reader_handle( mh, (void *)f_read, (void *)f_seek, NULL );
|
ret = mpg123_replace_reader_handle( mh, f_read, f_seek, NULL );
|
||||||
if( ret != MPG123_OK )
|
if( ret != MPG123_OK )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,15 @@ typedef struct
|
||||||
int playtime; // stream size in milliseconds
|
int playtime; // stream size in milliseconds
|
||||||
} wavinfo_t;
|
} wavinfo_t;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER // a1ba: MSVC6 don't have ssize_t
|
||||||
|
typedef long mpg_ssize_t;
|
||||||
|
#else
|
||||||
|
typedef ssize_t mpg_ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
// custom stdio
|
// custom stdio
|
||||||
typedef long (*pfread)( void *handle, void *buf, size_t count );
|
typedef mpg_ssize_t (*pfread)( void *handle, void *buf, size_t count );
|
||||||
typedef long (*pfseek)( void *handle, long offset, int whence );
|
typedef fs_offset_t (*pfseek)( void *handle, fs_offset_t offset, int whence );
|
||||||
|
|
||||||
extern void *create_decoder( int *error );
|
extern void *create_decoder( int *error );
|
||||||
extern int feed_mpeg_header( void *mpg, const byte *data, long bufsize, long streamsize, wavinfo_t *sc );
|
extern int feed_mpeg_header( void *mpg, const byte *data, long bufsize, long streamsize, wavinfo_t *sc );
|
||||||
|
|
|
@ -32,6 +32,7 @@ typedef struct mpg123_handle_s mpg123_handle_t;
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "fmt123.h"
|
#include "fmt123.h"
|
||||||
#include STDINT_H
|
#include STDINT_H
|
||||||
|
#include "xash3d_types.h"
|
||||||
|
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
@ -50,7 +51,7 @@ typedef unsigned char byte;
|
||||||
typedef unsigned short word;
|
typedef unsigned short word;
|
||||||
typedef unsigned long ulong;
|
typedef unsigned long ulong;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
typedef long mpg_off_t;
|
typedef fs_offset_t mpg_off_t;
|
||||||
|
|
||||||
#ifdef _MSC_VER // a1ba: MSVC6 don't have ssize_t
|
#ifdef _MSC_VER // a1ba: MSVC6 don't have ssize_t
|
||||||
typedef long mpg_ssize_t;
|
typedef long mpg_ssize_t;
|
||||||
|
|
|
@ -291,14 +291,14 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, fs_offset_t filesi
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static fs_offset_t FS_SeekMpg( void *file, fs_offset_t offset, int whence )
|
||||||
=================
|
|
||||||
FS_SeekEx
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
static 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 );
|
return g_fsapi.Seek((file_t *)file, offset, whence ) == -1 ? -1 : g_fsapi.Tell((file_t *)file );
|
||||||
|
}
|
||||||
|
|
||||||
|
static mpg_ssize_t FS_ReadMpg( void *file, void *buf, size_t count )
|
||||||
|
{
|
||||||
|
return g_fsapi.Read((file_t *)file, buf, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -334,7 +334,7 @@ stream_t *Stream_OpenMPG( const char *filename )
|
||||||
if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg ));
|
if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg ));
|
||||||
|
|
||||||
// trying to open stream and read header
|
// trying to open stream and read header
|
||||||
if( !open_mpeg_stream( mpeg, file, (void*)FS_Read, (void*)FS_SeekEx, &sc ))
|
if( !open_mpeg_stream( mpeg, file, FS_ReadMpg, FS_SeekMpg, &sc ))
|
||||||
{
|
{
|
||||||
Con_DPrintf( S_ERROR "Stream_OpenMPG: failed to load (%s): %s\n", filename, get_error( mpeg ));
|
Con_DPrintf( S_ERROR "Stream_OpenMPG: failed to load (%s): %s\n", filename, get_error( mpeg ));
|
||||||
close_decoder( mpeg );
|
close_decoder( mpeg );
|
||||||
|
|
Loading…
Add table
Reference in a new issue