mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-13 00:34:11 +00:00
Q3 code integrated, almost compiles except
for some ogg link error
This commit is contained in:
parent
474dde2a87
commit
7162fd4029
7 changed files with 99 additions and 67 deletions
|
@ -60,7 +60,16 @@ Select an appropriate codec for a file based on its extension
|
||||||
*/
|
*/
|
||||||
static snd_codec_t *S_FindCodecForFile(const char *filename)
|
static snd_codec_t *S_FindCodecForFile(const char *filename)
|
||||||
{
|
{
|
||||||
char *ext = S_FileExtension(filename);
|
int i;
|
||||||
|
char filenameLowercase[MAX_QPATH];
|
||||||
|
strncpy(filenameLowercase, filename, MAX_QPATH);
|
||||||
|
filenameLowercase[MAX_QPATH-1] = '\0';
|
||||||
|
for (i=0; i<MAX_QPATH; i++)
|
||||||
|
{
|
||||||
|
filenameLowercase[i] = tolower(filenameLowercase[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ext = S_FileExtension(filenameLowercase);
|
||||||
snd_codec_t *codec = codecs;
|
snd_codec_t *codec = codecs;
|
||||||
|
|
||||||
if(!ext)
|
if(!ext)
|
||||||
|
@ -71,13 +80,18 @@ static snd_codec_t *S_FindCodecForFile(const char *filename)
|
||||||
char fn[MAX_QPATH];
|
char fn[MAX_QPATH];
|
||||||
|
|
||||||
// there is no extension so we do not need to subtract 4 chars
|
// there is no extension so we do not need to subtract 4 chars
|
||||||
Q_strncpyz(fn, filename, MAX_QPATH);
|
strncpy(fn, filenameLowercase, MAX_QPATH);
|
||||||
COM_DefaultExtension(fn, MAX_QPATH, codec->ext);
|
fn[MAX_QPATH-1] = '\0';
|
||||||
|
COM_DefaultExtension(fn, codec->ext);
|
||||||
|
|
||||||
// Check it exists
|
// Check it exists
|
||||||
if(FS_ReadFile(fn, NULL) != -1)
|
int handle;
|
||||||
|
if (Sys_FileOpenRead(fn, &handle) > 0)
|
||||||
|
{
|
||||||
|
Sys_FileClose(handle);
|
||||||
return codec;
|
return codec;
|
||||||
|
}
|
||||||
|
|
||||||
// Nope. Next!
|
// Nope. Next!
|
||||||
codec = codec->next;
|
codec = codec->next;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +102,7 @@ static snd_codec_t *S_FindCodecForFile(const char *filename)
|
||||||
|
|
||||||
while(codec)
|
while(codec)
|
||||||
{
|
{
|
||||||
if(!Q_stricmp(ext, codec->ext))
|
if(0 == strcmp(ext, codec->ext))
|
||||||
return codec;
|
return codec;
|
||||||
codec = codec->next;
|
codec = codec->next;
|
||||||
}
|
}
|
||||||
|
@ -144,12 +158,12 @@ void *S_CodecLoad(const char *filename, snd_info_t *info)
|
||||||
codec = S_FindCodecForFile(filename);
|
codec = S_FindCodecForFile(filename);
|
||||||
if(!codec)
|
if(!codec)
|
||||||
{
|
{
|
||||||
Com_Printf("Unknown extension for %s\n", filename);
|
Con_Printf("Unknown extension for %s\n", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(fn, filename, sizeof(fn));
|
strncpy(fn, filename, sizeof(fn));
|
||||||
COM_DefaultExtension(fn, sizeof(fn), codec->ext);
|
COM_DefaultExtension(fn, codec->ext);
|
||||||
|
|
||||||
return codec->load(fn, info);
|
return codec->load(fn, info);
|
||||||
}
|
}
|
||||||
|
@ -167,12 +181,12 @@ snd_stream_t *S_CodecOpenStream(const char *filename)
|
||||||
codec = S_FindCodecForFile(filename);
|
codec = S_FindCodecForFile(filename);
|
||||||
if(!codec)
|
if(!codec)
|
||||||
{
|
{
|
||||||
Com_Printf("Unknown extension for %s\n", filename);
|
Con_Printf("Unknown extension for %s\n", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(fn, filename, sizeof(fn));
|
strncpy(fn, filename, sizeof(fn));
|
||||||
COM_DefaultExtension(fn, sizeof(fn), codec->ext);
|
COM_DefaultExtension(fn, codec->ext);
|
||||||
|
|
||||||
return codec->open(fn);
|
return codec->open(fn);
|
||||||
}
|
}
|
||||||
|
@ -198,14 +212,14 @@ S_CodecUtilOpen
|
||||||
snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec)
|
snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec)
|
||||||
{
|
{
|
||||||
snd_stream_t *stream;
|
snd_stream_t *stream;
|
||||||
fileHandle_t hnd;
|
int hnd;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
// Try to open the file
|
// Try to open the file
|
||||||
length = FS_FOpenFileRead(filename, &hnd, qtrue);
|
length = Sys_FileOpenRead(filename, &hnd);
|
||||||
if(!hnd)
|
if(hnd == -1)
|
||||||
{
|
{
|
||||||
Com_Printf("Can't read sound file %s\n", filename);
|
Con_Printf("Can't read sound file %s\n", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +227,7 @@ snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec)
|
||||||
stream = Z_Malloc(sizeof(snd_stream_t));
|
stream = Z_Malloc(sizeof(snd_stream_t));
|
||||||
if(!stream)
|
if(!stream)
|
||||||
{
|
{
|
||||||
FS_FCloseFile(hnd);
|
Sys_FileClose(hnd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +245,7 @@ S_CodecUtilClose
|
||||||
*/
|
*/
|
||||||
void S_CodecUtilClose(snd_stream_t **stream)
|
void S_CodecUtilClose(snd_stream_t **stream)
|
||||||
{
|
{
|
||||||
FS_FCloseFile((*stream)->file);
|
Sys_FileClose((*stream)->file);
|
||||||
Z_Free(*stream);
|
Z_Free(*stream);
|
||||||
*stream = NULL;
|
*stream = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef struct snd_codec_s snd_codec_t;
|
||||||
typedef struct snd_stream_s
|
typedef struct snd_stream_s
|
||||||
{
|
{
|
||||||
snd_codec_t *codec;
|
snd_codec_t *codec;
|
||||||
FILE *file;
|
int file; // handle
|
||||||
snd_info_t info;
|
snd_info_t info;
|
||||||
int length;
|
int length;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
|
@ -88,7 +88,7 @@ size_t S_OGG_Callback_read(void *ptr, size_t size, size_t nmemb, void *datasourc
|
||||||
byteSize = nmemb * size;
|
byteSize = nmemb * size;
|
||||||
|
|
||||||
// read it with the Q3 function FS_Read()
|
// read it with the Q3 function FS_Read()
|
||||||
bytesRead = FS_Read(ptr, byteSize, stream->file);
|
bytesRead = Sys_FileRead(stream->file, ptr, byteSize);
|
||||||
|
|
||||||
// update the file position
|
// update the file position
|
||||||
stream->pos += bytesRead;
|
stream->pos += bytesRead;
|
||||||
|
@ -128,12 +128,13 @@ int S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence)
|
||||||
case SEEK_SET :
|
case SEEK_SET :
|
||||||
{
|
{
|
||||||
// set the file position in the actual file with the Q3 function
|
// set the file position in the actual file with the Q3 function
|
||||||
retVal = FS_Seek(stream->file, (long) offset, FS_SEEK_SET);
|
errno = 0;
|
||||||
|
Sys_FileSeek(stream->file, (long) offset);
|
||||||
|
|
||||||
// something has gone wrong, so we return here
|
// something has gone wrong, so we return here
|
||||||
if(retVal < 0)
|
if(errno != 0)
|
||||||
{
|
{
|
||||||
return retVal;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep track of file position
|
// keep track of file position
|
||||||
|
@ -144,12 +145,13 @@ int S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence)
|
||||||
case SEEK_CUR :
|
case SEEK_CUR :
|
||||||
{
|
{
|
||||||
// set the file position in the actual file with the Q3 function
|
// set the file position in the actual file with the Q3 function
|
||||||
retVal = FS_Seek(stream->file, (long) offset, FS_SEEK_CUR);
|
errno = 0;
|
||||||
|
Sys_FileSeek(stream->file, (long) stream->pos + (long) offset);
|
||||||
|
|
||||||
// something has gone wrong, so we return here
|
// something has gone wrong, so we return here
|
||||||
if(retVal < 0)
|
if(errno != 0)
|
||||||
{
|
{
|
||||||
return retVal;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep track of file position
|
// keep track of file position
|
||||||
|
@ -163,12 +165,13 @@ int S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence)
|
||||||
// so we use the file length and FS_SEEK_SET
|
// so we use the file length and FS_SEEK_SET
|
||||||
|
|
||||||
// set the file position in the actual file with the Q3 function
|
// set the file position in the actual file with the Q3 function
|
||||||
retVal = FS_Seek(stream->file, (long) stream->length + (long) offset, FS_SEEK_SET);
|
errno = 0;
|
||||||
|
Sys_FileSeek(stream->file, (long) stream->length + (long) offset);
|
||||||
|
|
||||||
// something has gone wrong, so we return here
|
// something has gone wrong, so we return here
|
||||||
if(retVal < 0)
|
if(errno != 0)
|
||||||
{
|
{
|
||||||
return retVal;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep track of file position
|
// keep track of file position
|
||||||
|
@ -213,7 +216,7 @@ long S_OGG_Callback_tell(void *datasource)
|
||||||
// snd_stream_t in the generic pointer
|
// snd_stream_t in the generic pointer
|
||||||
stream = (snd_stream_t *) datasource;
|
stream = (snd_stream_t *) datasource;
|
||||||
|
|
||||||
return (long) FS_FTell(stream->file);
|
return (long) Sys_FileTell(stream->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the callback structure
|
// the callback structure
|
||||||
|
|
|
@ -24,15 +24,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
#include "snd_codec.h"
|
#include "snd_codec.h"
|
||||||
|
|
||||||
|
#define PAD(x,y) (((x)+(y)-1) & ~((y)-1))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
FGetLittleLong
|
FGetLittleLong
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
static int FGetLittleLong( fileHandle_t f ) {
|
static int FGetLittleLong( int handle ) {
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
FS_Read( &v, sizeof(v), f );
|
Sys_FileRead( handle, &v, sizeof(v) );
|
||||||
|
|
||||||
return LittleLong( v);
|
return LittleLong( v);
|
||||||
}
|
}
|
||||||
|
@ -42,10 +44,10 @@ static int FGetLittleLong( fileHandle_t f ) {
|
||||||
FGetLittleShort
|
FGetLittleShort
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
static short FGetLittleShort( fileHandle_t f ) {
|
static short FGetLittleShort( int handle ) {
|
||||||
short v;
|
short v;
|
||||||
|
|
||||||
FS_Read( &v, sizeof(v), f );
|
Sys_FileRead( handle, &v, sizeof(v) );
|
||||||
|
|
||||||
return LittleShort( v);
|
return LittleShort( v);
|
||||||
}
|
}
|
||||||
|
@ -55,19 +57,19 @@ static short FGetLittleShort( fileHandle_t f ) {
|
||||||
S_ReadChunkInfo
|
S_ReadChunkInfo
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
static int S_ReadChunkInfo(fileHandle_t f, char *name)
|
static int S_ReadChunkInfo(int handle, char *name)
|
||||||
{
|
{
|
||||||
int len, r;
|
int len, r;
|
||||||
|
|
||||||
name[4] = 0;
|
name[4] = 0;
|
||||||
|
|
||||||
r = FS_Read(name, 4, f);
|
r = Sys_FileRead(handle, name, 4);
|
||||||
if(r != 4)
|
if(r != 4)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
len = FGetLittleLong(f);
|
len = FGetLittleLong(handle);
|
||||||
if( len < 0 ) {
|
if( len < 0 ) {
|
||||||
Com_Printf( S_COLOR_YELLOW "WARNING: Negative chunk length\n" );
|
Con_Printf( "WARNING: Negative chunk length\n" );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,11 +83,11 @@ S_FindRIFFChunk
|
||||||
Returns the length of the data in the chunk, or -1 if not found
|
Returns the length of the data in the chunk, or -1 if not found
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
static int S_FindRIFFChunk( fileHandle_t f, char *chunk ) {
|
static int S_FindRIFFChunk( int handle, char *chunk ) {
|
||||||
char name[5];
|
char name[5];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
while( ( len = S_ReadChunkInfo(f, name) ) >= 0 )
|
while( ( len = S_ReadChunkInfo(handle, name) ) >= 0 )
|
||||||
{
|
{
|
||||||
// If this is the right chunk, return
|
// If this is the right chunk, return
|
||||||
if( !Q_strncmp( name, chunk, 4 ) )
|
if( !Q_strncmp( name, chunk, 4 ) )
|
||||||
|
@ -94,7 +96,7 @@ static int S_FindRIFFChunk( fileHandle_t f, char *chunk ) {
|
||||||
len = PAD( len, 2 );
|
len = PAD( len, 2 );
|
||||||
|
|
||||||
// Not the right chunk - skip it
|
// Not the right chunk - skip it
|
||||||
FS_Seek( f, len, FS_SEEK_CUR );
|
Sys_FileSeekRelative( handle, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -128,7 +130,7 @@ static void S_ByteSwapRawSamples( int samples, int width, int s_channels, const
|
||||||
S_ReadRIFFHeader
|
S_ReadRIFFHeader
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
static qboolean S_ReadRIFFHeader(fileHandle_t file, snd_info_t *info)
|
static qboolean S_ReadRIFFHeader( int file, snd_info_t *info)
|
||||||
{
|
{
|
||||||
char dump[16];
|
char dump[16];
|
||||||
int wav_format;
|
int wav_format;
|
||||||
|
@ -136,13 +138,13 @@ static qboolean S_ReadRIFFHeader(fileHandle_t file, snd_info_t *info)
|
||||||
int fmtlen = 0;
|
int fmtlen = 0;
|
||||||
|
|
||||||
// skip the riff wav header
|
// skip the riff wav header
|
||||||
FS_Read(dump, 12, file);
|
Sys_FileRead(file, dump, 12);
|
||||||
|
|
||||||
// Scan for the format chunk
|
// Scan for the format chunk
|
||||||
if((fmtlen = S_FindRIFFChunk(file, "fmt ")) < 0)
|
if((fmtlen = S_FindRIFFChunk(file, "fmt ")) < 0)
|
||||||
{
|
{
|
||||||
Com_Printf( S_COLOR_RED "ERROR: Couldn't find \"fmt\" chunk\n");
|
Con_Printf( "ERROR: Couldn't find \"fmt\" chunk\n");
|
||||||
return qfalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the parameters
|
// Save the parameters
|
||||||
|
@ -155,8 +157,8 @@ static qboolean S_ReadRIFFHeader(fileHandle_t file, snd_info_t *info)
|
||||||
|
|
||||||
if( bits < 8 )
|
if( bits < 8 )
|
||||||
{
|
{
|
||||||
Com_Printf( S_COLOR_RED "ERROR: Less than 8 bit sound is not supported\n");
|
Con_Printf( "ERROR: Less than 8 bit sound is not supported\n");
|
||||||
return qfalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->width = bits / 8;
|
info->width = bits / 8;
|
||||||
|
@ -166,18 +168,18 @@ static qboolean S_ReadRIFFHeader(fileHandle_t file, snd_info_t *info)
|
||||||
if(fmtlen > 16)
|
if(fmtlen > 16)
|
||||||
{
|
{
|
||||||
fmtlen -= 16;
|
fmtlen -= 16;
|
||||||
FS_Seek( file, fmtlen, FS_SEEK_CUR );
|
Sys_FileSeekRelative( file, fmtlen );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan for the data chunk
|
// Scan for the data chunk
|
||||||
if( (info->size = S_FindRIFFChunk(file, "data")) < 0)
|
if( (info->size = S_FindRIFFChunk(file, "data")) < 0)
|
||||||
{
|
{
|
||||||
Com_Printf( S_COLOR_RED "ERROR: Couldn't find \"data\" chunk\n");
|
Con_Printf( "ERROR: Couldn't find \"data\" chunk\n");
|
||||||
return qfalse;
|
return false;
|
||||||
}
|
}
|
||||||
info->samples = (info->size / info->width) / info->channels;
|
info->samples = (info->size / info->width) / info->channels;
|
||||||
|
|
||||||
return qtrue;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WAV codec
|
// WAV codec
|
||||||
|
@ -198,14 +200,14 @@ S_WAV_CodecLoad
|
||||||
*/
|
*/
|
||||||
void *S_WAV_CodecLoad(const char *filename, snd_info_t *info)
|
void *S_WAV_CodecLoad(const char *filename, snd_info_t *info)
|
||||||
{
|
{
|
||||||
fileHandle_t file;
|
int file;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
|
|
||||||
// Try to open the file
|
// Try to open the file
|
||||||
FS_FOpenFileRead(filename, &file, qtrue);
|
Sys_FileOpenRead(filename, &file);
|
||||||
if(!file)
|
if(file == -1)
|
||||||
{
|
{
|
||||||
Com_Printf( S_COLOR_RED "ERROR: Could not open \"%s\"\n",
|
Con_Printf( "ERROR: Could not open \"%s\"\n",
|
||||||
filename);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -213,8 +215,8 @@ void *S_WAV_CodecLoad(const char *filename, snd_info_t *info)
|
||||||
// Read the RIFF header
|
// Read the RIFF header
|
||||||
if(!S_ReadRIFFHeader(file, info))
|
if(!S_ReadRIFFHeader(file, info))
|
||||||
{
|
{
|
||||||
FS_FCloseFile(file);
|
Sys_FileClose(file);
|
||||||
Com_Printf( S_COLOR_RED "ERROR: Incorrect/unsupported format in \"%s\"\n",
|
Con_Printf( "ERROR: Incorrect/unsupported format in \"%s\"\n",
|
||||||
filename);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -223,18 +225,18 @@ void *S_WAV_CodecLoad(const char *filename, snd_info_t *info)
|
||||||
buffer = Z_Malloc(info->size);
|
buffer = Z_Malloc(info->size);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
{
|
{
|
||||||
FS_FCloseFile(file);
|
Sys_FileClose(file);
|
||||||
Com_Printf( S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n",
|
Con_Printf( "ERROR: Out of memory reading \"%s\"\n",
|
||||||
filename);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read, byteswap
|
// Read, byteswap
|
||||||
FS_Read(buffer, info->size, file);
|
Sys_FileRead(file, buffer, info->size);
|
||||||
S_ByteSwapRawSamples(info->samples, info->width, info->channels, (byte *)buffer);
|
S_ByteSwapRawSamples(info->samples, info->width, info->channels, (byte *)buffer);
|
||||||
|
|
||||||
// Close and return
|
// Close and return
|
||||||
FS_FCloseFile(file);
|
Sys_FileClose(file);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +290,7 @@ int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
|
||||||
bytes = remaining;
|
bytes = remaining;
|
||||||
stream->pos += bytes;
|
stream->pos += bytes;
|
||||||
samples = (bytes / stream->info.width) / stream->info.channels;
|
samples = (bytes / stream->info.width) / stream->info.channels;
|
||||||
FS_Read(buffer, bytes, stream->file);
|
Sys_FileRead(stream->file, buffer, bytes);
|
||||||
S_ByteSwapRawSamples(samples, stream->info.width, stream->info.channels, buffer);
|
S_ByteSwapRawSamples(samples, stream->info.width, stream->info.channels, buffer);
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,13 +627,13 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
|
||||||
intVolume = 256 * volume;
|
intVolume = 256 * volume;
|
||||||
|
|
||||||
if ( s_rawend[stream] < soundtime ) {
|
if ( s_rawend[stream] < soundtime ) {
|
||||||
Com_DPrintf( "S_Base_RawSamples: resetting minimum: %i < %i\n", s_rawend[stream], soundtime );
|
Con_DPrintf( "S_Base_RawSamples: resetting minimum: %i < %i\n", s_rawend[stream], soundtime );
|
||||||
s_rawend[stream] = soundtime;
|
s_rawend[stream] = soundtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
scale = (float)rate / shm->speed;
|
scale = (float)rate / shm->speed;
|
||||||
|
|
||||||
//Com_Printf ("%i < %i < %i\n", soundtime, s_paintedtime, s_rawend[stream]);
|
//Con_Printf ("%i < %i < %i\n", soundtime, s_paintedtime, s_rawend[stream]);
|
||||||
if (s_channels == 2 && width == 2)
|
if (s_channels == 2 && width == 2)
|
||||||
{
|
{
|
||||||
if (scale == 1.0)
|
if (scale == 1.0)
|
||||||
|
@ -705,7 +705,7 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( s_rawend[stream] > soundtime + MAX_RAW_SAMPLES ) {
|
if ( s_rawend[stream] > soundtime + MAX_RAW_SAMPLES ) {
|
||||||
Com_DPrintf( "S_Base_RawSamples: overflowed %i > %i\n", s_rawend[stream], soundtime );
|
Con_DPrintf( "S_Base_RawSamples: overflowed %i > %i\n", s_rawend[stream], soundtime );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,7 +979,7 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
|
||||||
if ( !loop || !loop[0] ) {
|
if ( !loop || !loop[0] ) {
|
||||||
loop = intro;
|
loop = intro;
|
||||||
}
|
}
|
||||||
Com_DPrintf( "S_StartBackgroundTrack( %s, %s )\n", intro, loop );
|
Con_DPrintf( "S_StartBackgroundTrack( %s, %s )\n", intro, loop );
|
||||||
|
|
||||||
if(!*intro)
|
if(!*intro)
|
||||||
{
|
{
|
||||||
|
@ -990,7 +990,8 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
|
||||||
if( !loop ) {
|
if( !loop ) {
|
||||||
s_backgroundLoop[0] = 0;
|
s_backgroundLoop[0] = 0;
|
||||||
} else {
|
} else {
|
||||||
Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) );
|
strncpy( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) );
|
||||||
|
s_backgroundLoop[MAX_QPATH-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// close the background track, but DON'T reset s_rawend
|
// close the background track, but DON'T reset s_rawend
|
||||||
|
@ -1004,12 +1005,12 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
|
||||||
// Open stream
|
// Open stream
|
||||||
s_backgroundStream = S_CodecOpenStream(intro);
|
s_backgroundStream = S_CodecOpenStream(intro);
|
||||||
if(!s_backgroundStream) {
|
if(!s_backgroundStream) {
|
||||||
Com_Printf( "WARNING: couldn't open music file %s\n", intro );
|
Con_Printf( "WARNING: couldn't open music file %s\n", intro );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
|
if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
|
||||||
Com_Printf( "WARNING: music file %s is not 22k stereo\n", intro );
|
Con_Printf( "WARNING: music file %s is not 22k stereo\n", intro );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,11 @@ int Sys_FileOpenRead (const char *path, int *hndl);
|
||||||
int Sys_FileOpenWrite (const char *path);
|
int Sys_FileOpenWrite (const char *path);
|
||||||
void Sys_FileClose (int handle);
|
void Sys_FileClose (int handle);
|
||||||
void Sys_FileSeek (int handle, int position);
|
void Sys_FileSeek (int handle, int position);
|
||||||
|
void Sys_FileSeekRelative (int handle, int position);
|
||||||
int Sys_FileRead (int handle, void *dest, int count);
|
int Sys_FileRead (int handle, void *dest, int count);
|
||||||
int Sys_FileWrite (int handle,const void *data, int count);
|
int Sys_FileWrite (int handle,const void *data, int count);
|
||||||
int Sys_FileTime (const char *path);
|
int Sys_FileTime (const char *path);
|
||||||
|
int Sys_FileTell (int handle);
|
||||||
void Sys_mkdir (const char *path);
|
void Sys_mkdir (const char *path);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -114,6 +114,11 @@ void Sys_FileSeek (int handle, int position)
|
||||||
fseek (sys_handles[handle], position, SEEK_SET);
|
fseek (sys_handles[handle], position, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sys_FileSeekRelative (int handle, int position)
|
||||||
|
{
|
||||||
|
fseek (sys_handles[handle], position, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
int Sys_FileRead (int handle, void *dest, int count)
|
int Sys_FileRead (int handle, void *dest, int count)
|
||||||
{
|
{
|
||||||
return fread (dest, 1, count, sys_handles[handle]);
|
return fread (dest, 1, count, sys_handles[handle]);
|
||||||
|
@ -139,6 +144,11 @@ int Sys_FileTime (const char *path)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Sys_FileTell (int handle)
|
||||||
|
{
|
||||||
|
return ftell(sys_handles[handle]);
|
||||||
|
}
|
||||||
|
|
||||||
void Sys_Init (void)
|
void Sys_Init (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue