mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-18 23:41:38 +00:00
Erweitere Vorbis-Unterstützung:
- Support für Big-Endian Pamps (läuft yQ2 auf sowas überhaupt?) - Unterstützung für 22khz Vorbis-Dateien (ermöglicht es die Wave-Dateien aus den Pags in Vorbis zu konvertieren, wenn man denn drauf steht.) - Unterstützung für Mono-Dateien (Sinnvoll für Handhelds) Patch von: Ozkan Sezer
This commit is contained in:
parent
b282f41093
commit
4b6c561acc
2 changed files with 29 additions and 4 deletions
|
@ -25,6 +25,11 @@
|
|||
#ifndef CL_SOUND_VORBIS_H
|
||||
#define CL_SOUND_VORBIS_H
|
||||
|
||||
/* The OGG codec can return the samples in a number
|
||||
of different formats, we use the standard signed
|
||||
short format. */
|
||||
#define OGG_SAMPLEWIDTH 2
|
||||
|
||||
#define OGG_DIR "music"
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -40,6 +40,7 @@ extern cvar_t *fs_basedir; /* Path to "music". */
|
|||
|
||||
qboolean ogg_first_init = true; /* First initialization flag. */
|
||||
qboolean ogg_started = false; /* Initialization flag. */
|
||||
int ogg_bigendian = 0;
|
||||
byte *ogg_buffer; /* File buffer. */
|
||||
char **ogg_filelist; /* List of Ogg Vorbis files. */
|
||||
char ovBuf [ 4096 ]; /* Buffer for sound. */
|
||||
|
@ -53,6 +54,7 @@ cvar_t *ogg_playlist; /* Playlist. */
|
|||
cvar_t *ogg_sequence; /* Sequence play indicator. */
|
||||
cvar_t *ogg_volume; /* Music volume. */
|
||||
OggVorbis_File ovFile; /* Ogg Vorbis file. */
|
||||
vorbis_info *ogg_info; /* Ogg Vorbis file information */
|
||||
|
||||
/*
|
||||
* Initialize the Ogg Vorbis subsystem.
|
||||
|
@ -78,6 +80,11 @@ OGG_Init ( void )
|
|||
return;
|
||||
}
|
||||
|
||||
if (bigendien == true)
|
||||
{
|
||||
ogg_bigendian = 1;
|
||||
}
|
||||
|
||||
/* Cvars. */
|
||||
ogg_autoplay = Cvar_Get( "ogg_autoplay", "?", CVAR_ARCHIVE );
|
||||
ogg_check = Cvar_Get( "ogg_check", "0", CVAR_ARCHIVE );
|
||||
|
@ -123,6 +130,7 @@ OGG_Init ( void )
|
|||
srand( time( NULL ) );
|
||||
ogg_buffer = NULL;
|
||||
ogg_curfile = -1;
|
||||
ogg_info = NULL;
|
||||
ogg_status = STOP;
|
||||
ogg_first_init = false;
|
||||
}
|
||||
|
@ -376,7 +384,7 @@ OGG_LoadPlaylist ( char *playlist )
|
|||
qboolean
|
||||
OGG_Open ( ogg_seek_t type, int offset )
|
||||
{
|
||||
int size; /* File size. */
|
||||
int size; /* File size. */
|
||||
int pos; /* Absolute position. */
|
||||
int res; /* Error indicator. */
|
||||
|
||||
|
@ -446,6 +454,17 @@ OGG_Open ( ogg_seek_t type, int offset )
|
|||
{
|
||||
Com_Printf( "OGG_Open: '%s' is not a valid Ogg Vorbis file (error %i).\n", ogg_filelist [ pos ], res );
|
||||
FS_FreeFile( ogg_buffer );
|
||||
ogg_buffer = NULL;
|
||||
return ( false );
|
||||
}
|
||||
|
||||
ogg_info = ov_info(&ovFile, 0);
|
||||
if (!ogg_info)
|
||||
{
|
||||
Com_Printf( "OGG_Open: Unable to get stream information for %s.\n", ogg_filelist [ pos ] );
|
||||
ov_clear( &ovFile );
|
||||
FS_FreeFile( ogg_buffer );
|
||||
ogg_buffer = NULL;
|
||||
return ( false );
|
||||
}
|
||||
|
||||
|
@ -463,7 +482,7 @@ OGG_Open ( ogg_seek_t type, int offset )
|
|||
qboolean
|
||||
OGG_OpenName ( char *filename )
|
||||
{
|
||||
char *name; /* File name. */
|
||||
char *name; /* File name. */
|
||||
int i; /* Loop counter. */
|
||||
|
||||
/* If the track name is '00' stop playback */
|
||||
|
@ -504,8 +523,8 @@ OGG_Read ( void )
|
|||
int res; /* Number of bytes read. */
|
||||
|
||||
/* Read and resample. */
|
||||
res = ov_read( &ovFile, ovBuf, sizeof ( ovBuf ), 0, 2, 1, &ovSection );
|
||||
S_RawSamplesVol( res >> 2, 44100, 2, 2, (byte *) ovBuf, ogg_volume->value );
|
||||
res = ov_read( &ovFile, ovBuf, sizeof ( ovBuf ), ogg_bigendian, OGG_SAMPLEWIDTH, 1, &ovSection );
|
||||
S_RawSamplesVol( res >> ogg_info->channels, ogg_info->rate, OGG_SAMPLEWIDTH, ogg_info->channels, (byte *) ovBuf, ogg_volume->value );
|
||||
|
||||
/* Check for end of file. */
|
||||
if ( res == 0 )
|
||||
|
@ -563,6 +582,7 @@ OGG_Stop ( void )
|
|||
|
||||
ov_clear( &ovFile );
|
||||
ogg_status = STOP;
|
||||
ogg_info = NULL;
|
||||
|
||||
if ( ogg_buffer != NULL )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue