mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-15 05:29:51 +01:00
engine: soundlib: show mpg123 errors in console
This commit is contained in:
parent
4beba75159
commit
cedc1e0eb2
@ -40,7 +40,7 @@ typedef long (*pfseek)( void *handle, long 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 );
|
||||||
extern int feed_mpeg_stream( void *mpg, const char *data, long bufsize, char *outbuf, size_t *outsize );
|
extern int feed_mpeg_stream( void *mpg, const byte *data, long bufsize, byte *outbuf, size_t *outsize );
|
||||||
extern int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavinfo_t *sc );
|
extern int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavinfo_t *sc );
|
||||||
extern int read_mpeg_stream(void *mpg, byte *outbuf, size_t *outsize );
|
extern int read_mpeg_stream(void *mpg, byte *outbuf, size_t *outsize );
|
||||||
extern int get_stream_pos( void *mpg );
|
extern int get_stream_pos( void *mpg );
|
||||||
|
@ -14,7 +14,7 @@ GNU General Public License for more details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "soundlib.h"
|
#include "soundlib.h"
|
||||||
#include "libmpg.h"
|
#include "libmpg/libmpg.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================================================================
|
=================================================================
|
||||||
@ -41,18 +41,12 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
if(( mpeg = create_decoder( &ret )) == NULL )
|
if(( mpeg = create_decoder( &ret )) == NULL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg ));
|
if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg ));
|
||||||
#endif
|
|
||||||
|
|
||||||
// trying to read header
|
// trying to read header
|
||||||
if( !feed_mpeg_header( mpeg, buffer, FRAME_SIZE, filesize, &sc ))
|
if( !feed_mpeg_header( mpeg, buffer, FRAME_SIZE, filesize, &sc ))
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
|
||||||
Con_DPrintf( S_ERROR "Sound_LoadMPG: failed to load (%s): %s\n", name, get_error( mpeg ));
|
Con_DPrintf( S_ERROR "Sound_LoadMPG: failed to load (%s): %s\n", name, get_error( mpeg ));
|
||||||
#else
|
|
||||||
Con_DPrintf( S_ERROR "Sound_LoadMPG: (%s) is probably corrupted\n", name );
|
|
||||||
#endif
|
|
||||||
close_decoder( mpeg );
|
close_decoder( mpeg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -84,7 +78,7 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
|
|
||||||
if( feed_mpeg_stream( mpeg, NULL, 0, out, &outsize ) != MP3_OK && outsize <= 0 )
|
if( feed_mpeg_stream( mpeg, NULL, 0, out, &outsize ) != MP3_OK && outsize <= 0 )
|
||||||
{
|
{
|
||||||
char *data = (char *)buffer + pos;
|
const byte *data = buffer + pos;
|
||||||
int bufsize;
|
int bufsize;
|
||||||
|
|
||||||
// if there are no bytes remainig so we can decompress the new frame
|
// if there are no bytes remainig so we can decompress the new frame
|
||||||
@ -135,23 +129,18 @@ stream_t *Stream_OpenMPG( const char *filename )
|
|||||||
// couldn't create decoder
|
// couldn't create decoder
|
||||||
if(( mpeg = create_decoder( &ret )) == NULL )
|
if(( mpeg = create_decoder( &ret )) == NULL )
|
||||||
{
|
{
|
||||||
Con_DPrintf( S_ERROR "Stream_OpenMPG: couldn't create decoder\n" );
|
Con_DPrintf( S_ERROR "Stream_OpenMPG: couldn't create decoder: %s\n", get_error( mpeg ) );
|
||||||
Mem_Free( stream );
|
Mem_Free( stream );
|
||||||
FS_Close( file );
|
FS_Close( file );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg ));
|
if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg ));
|
||||||
#endif
|
|
||||||
// trying to open stream and read header
|
// trying to open stream and read header
|
||||||
if( !open_mpeg_stream( mpeg, file, FS_Read, FS_Seek, &sc ))
|
if( !open_mpeg_stream( mpeg, file, (void*)FS_Read, (void*)FS_Seek, &sc ))
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
|
||||||
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 ));
|
||||||
#else
|
|
||||||
Con_DPrintf( S_ERROR "Stream_OpenMPG: (%s) is probably corrupted\n", filename );
|
|
||||||
#endif
|
|
||||||
close_decoder( mpeg );
|
close_decoder( mpeg );
|
||||||
Mem_Free( stream );
|
Mem_Free( stream );
|
||||||
FS_Close( file );
|
FS_Close( file );
|
||||||
@ -191,7 +180,7 @@ int Stream_ReadMPG( stream_t *stream, int needBytes, void *buffer )
|
|||||||
|
|
||||||
if( !stream->buffsize )
|
if( !stream->buffsize )
|
||||||
{
|
{
|
||||||
if( read_mpeg_stream( mpg, stream->temp, &stream->pos ) != MP3_OK )
|
if( read_mpeg_stream( mpg, (byte*)stream->temp, &stream->pos ) != MP3_OK )
|
||||||
break; // there was end of the stream
|
break; // there was end of the stream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user