Merge branch 'master' into sdl2
Conflicts: Makefile code/renderercommon/qgl.h code/renderergl1/tr_local.h code/sdl/sdl_glimp.c
This commit is contained in:
commit
d9d52f0306
427 changed files with 66082 additions and 14083 deletions
|
@ -1158,7 +1158,6 @@ redump:
|
|||
if (cinTable[currentHandle].numQuads == -1) {
|
||||
readQuadInfo( framedata );
|
||||
setupQuad( 0, 0 );
|
||||
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
|
||||
cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds()*com_timescale->value;
|
||||
}
|
||||
if (cinTable[currentHandle].numQuads != 1) cinTable[currentHandle].numQuads = 0;
|
||||
|
@ -1226,7 +1225,6 @@ redump:
|
|||
|
||||
static void RoQ_init( void )
|
||||
{
|
||||
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
|
||||
cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds()*com_timescale->value;
|
||||
|
||||
cinTable[currentHandle].RoQPlayed = 24;
|
||||
|
@ -1358,12 +1356,10 @@ e_status CIN_RunCinematic (int handle)
|
|||
return cinTable[currentHandle].status;
|
||||
}
|
||||
|
||||
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
|
||||
thisTime = CL_ScaledMilliseconds()*com_timescale->value;
|
||||
if (cinTable[currentHandle].shader && (abs(thisTime - cinTable[currentHandle].lastTime))>100) {
|
||||
cinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime;
|
||||
}
|
||||
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
|
||||
cinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value) - cinTable[currentHandle].startTime)*3)/100);
|
||||
|
||||
start = cinTable[currentHandle].startTime;
|
||||
|
@ -1372,7 +1368,6 @@ e_status CIN_RunCinematic (int handle)
|
|||
{
|
||||
RoQInterrupt();
|
||||
if (start != cinTable[currentHandle].startTime) {
|
||||
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
|
||||
cinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value)
|
||||
- cinTable[currentHandle].startTime)*3)/100);
|
||||
start = cinTable[currentHandle].startTime;
|
||||
|
|
|
@ -53,8 +53,6 @@ typedef struct {
|
|||
vec4_t color;
|
||||
} console_t;
|
||||
|
||||
extern console_t con;
|
||||
|
||||
console_t con;
|
||||
|
||||
cvar_t *con_conspeed;
|
||||
|
@ -180,7 +178,9 @@ void Con_Dump_f (void)
|
|||
int l, x, i;
|
||||
short *line;
|
||||
fileHandle_t f;
|
||||
char buffer[1024];
|
||||
int bufferlen;
|
||||
char *buffer;
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
|
@ -188,12 +188,15 @@ void Con_Dump_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
Com_Printf ("Dumped console text to %s.\n", Cmd_Argv(1) );
|
||||
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
|
||||
COM_DefaultExtension( filename, sizeof( filename ), ".txt" );
|
||||
|
||||
f = FS_FOpenFileWrite( Cmd_Argv( 1 ) );
|
||||
Com_Printf ("Dumped console text to %s.\n", filename );
|
||||
|
||||
f = FS_FOpenFileWrite( filename );
|
||||
if (!f)
|
||||
{
|
||||
Com_Printf ("ERROR: couldn't open.\n");
|
||||
Com_Printf ("ERROR: couldn't open %s.\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -208,8 +211,16 @@ void Con_Dump_f (void)
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
bufferlen = con.linewidth + 3 * sizeof ( char );
|
||||
#else
|
||||
bufferlen = con.linewidth + 2 * sizeof ( char );
|
||||
#endif
|
||||
|
||||
buffer = Hunk_AllocateTempMemory( bufferlen );
|
||||
|
||||
// write the remaining lines
|
||||
buffer[con.linewidth] = 0;
|
||||
buffer[bufferlen-1] = 0;
|
||||
for ( ; l <= con.current ; l++)
|
||||
{
|
||||
line = con.text + (l%con.totallines)*con.linewidth;
|
||||
|
@ -222,10 +233,15 @@ void Con_Dump_f (void)
|
|||
else
|
||||
break;
|
||||
}
|
||||
strcat( buffer, "\n" );
|
||||
#ifdef _WIN32
|
||||
Q_strcat(buffer, bufferlen, "\r\n");
|
||||
#else
|
||||
Q_strcat(buffer, bufferlen, "\n");
|
||||
#endif
|
||||
FS_Write(buffer, strlen(buffer), f);
|
||||
}
|
||||
|
||||
Hunk_FreeTempMemory( buffer );
|
||||
FS_FCloseFile( f );
|
||||
}
|
||||
|
||||
|
@ -599,8 +615,6 @@ void Con_DrawNotify (void)
|
|||
|
||||
Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v,
|
||||
SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue, qtrue );
|
||||
|
||||
v += BIGCHAR_HEIGHT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ void CL_cURL_PerformDownload(void)
|
|||
}
|
||||
FS_FCloseFile(clc.download);
|
||||
if(msg->msg == CURLMSG_DONE && msg->data.result == CURLE_OK) {
|
||||
FS_SV_Rename(clc.downloadTempName, clc.downloadName);
|
||||
FS_SV_Rename(clc.downloadTempName, clc.downloadName, qfalse);
|
||||
clc.downloadRestart = qtrue;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -808,7 +808,7 @@ int Key_StringToKeynum( char *str ) {
|
|||
return -1;
|
||||
}
|
||||
if ( !str[1] ) {
|
||||
return str[0];
|
||||
return tolower( str[0] );
|
||||
}
|
||||
|
||||
// check for hex code
|
||||
|
@ -1001,9 +1001,9 @@ void Key_Bind_f (void)
|
|||
if (c == 2)
|
||||
{
|
||||
if (keys[b].binding)
|
||||
Com_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), keys[b].binding );
|
||||
Com_Printf ("\"%s\" = \"%s\"\n", Key_KeynumToString(b), keys[b].binding );
|
||||
else
|
||||
Com_Printf ("\"%s\" is not bound\n", Cmd_Argv(1) );
|
||||
Com_Printf ("\"%s\" is not bound\n", Key_KeynumToString(b) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1142,13 +1142,13 @@ void CL_PlayDemo_f( void ) {
|
|||
Com_Error( ERR_DROP, "couldn't open %s", name);
|
||||
return;
|
||||
}
|
||||
Q_strncpyz( clc.demoName, Cmd_Argv(1), sizeof( clc.demoName ) );
|
||||
Q_strncpyz( clc.demoName, arg, sizeof( clc.demoName ) );
|
||||
|
||||
Con_Close();
|
||||
|
||||
clc.state = CA_CONNECTED;
|
||||
clc.demoplaying = qtrue;
|
||||
Q_strncpyz( clc.servername, Cmd_Argv(1), sizeof( clc.servername ) );
|
||||
Q_strncpyz( clc.servername, arg, sizeof( clc.servername ) );
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if(protocol <= com_legacyprotocol->integer)
|
||||
|
|
|
@ -252,7 +252,7 @@ void CL_ParseSnapshot( msg_t *msg ) {
|
|||
// The frame that the server did the delta from
|
||||
// is too old, so we can't reconstruct it properly.
|
||||
Com_Printf ("Delta frame too old.\n");
|
||||
} else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES-128 ) {
|
||||
} else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES - MAX_SNAPSHOT_ENTITIES ) {
|
||||
Com_Printf ("Delta parseEntitiesNum too old.\n");
|
||||
} else {
|
||||
newSnap.valid = qtrue; // valid delta parse
|
||||
|
@ -637,7 +637,7 @@ void CL_ParseDownload ( msg_t *msg ) {
|
|||
clc.download = 0;
|
||||
|
||||
// rename the file
|
||||
FS_SV_Rename ( clc.downloadTempName, clc.downloadName );
|
||||
FS_SV_Rename ( clc.downloadTempName, clc.downloadName, qfalse );
|
||||
}
|
||||
|
||||
// send intentions now
|
||||
|
|
|
@ -146,7 +146,7 @@ static int LAN_AddServer(int source, const char *name, const char *address) {
|
|||
break;
|
||||
}
|
||||
if (servers && *count < max) {
|
||||
NET_StringToAdr( address, &adr, NA_IP );
|
||||
NET_StringToAdr( address, &adr, NA_UNSPEC );
|
||||
for ( i = 0; i < *count; i++ ) {
|
||||
if (NET_CompareAdr(servers[i].adr, adr)) {
|
||||
break;
|
||||
|
@ -190,7 +190,7 @@ static void LAN_RemoveServer(int source, const char *addr) {
|
|||
}
|
||||
if (servers) {
|
||||
netadr_t comp;
|
||||
NET_StringToAdr( addr, &comp, NA_IP );
|
||||
NET_StringToAdr( addr, &comp, NA_UNSPEC );
|
||||
for (i = 0; i < *count; i++) {
|
||||
if (NET_CompareAdr( comp, servers[i].adr)) {
|
||||
int j = i;
|
||||
|
@ -750,7 +750,7 @@ intptr_t CL_UISystemCalls( intptr_t *args ) {
|
|||
return 0;
|
||||
|
||||
case UI_CVAR_CREATE:
|
||||
Cvar_Get( VMA(1), VMA(2), args[3] );
|
||||
Cvar_Register( NULL, VMA(1), VMA(2), args[3] );
|
||||
return 0;
|
||||
|
||||
case UI_CVAR_INFOSTRINGBUFFER:
|
||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "../qcommon/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
#include "../renderer/tr_public.h"
|
||||
#include "../renderercommon/tr_public.h"
|
||||
#include "../ui/ui_public.h"
|
||||
#include "keys.h"
|
||||
#include "snd_public.h"
|
||||
|
@ -87,7 +87,7 @@ typedef struct {
|
|||
// the parseEntities array must be large enough to hold PACKET_BACKUP frames of
|
||||
// entities, so that when a delta compressed message arives from the server
|
||||
// it can be un-deltad from the original
|
||||
#define MAX_PARSE_ENTITIES 2048
|
||||
#define MAX_PARSE_ENTITIES ( PACKET_BACKUP * MAX_SNAPSHOT_ENTITIES )
|
||||
|
||||
extern int g_console_field_width;
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ void S_AdpcmEncodeSound( sfx_t *sfx, short *samples ) {
|
|||
newchunk = SND_malloc();
|
||||
if (sfx->soundData == NULL) {
|
||||
sfx->soundData = newchunk;
|
||||
} else {
|
||||
} else if (chunk != NULL) {
|
||||
chunk->next = newchunk;
|
||||
}
|
||||
chunk = newchunk;
|
||||
|
|
|
@ -124,6 +124,10 @@ void S_CodecInit()
|
|||
{
|
||||
codecs = NULL;
|
||||
|
||||
#ifdef USE_CODEC_OPUS
|
||||
S_CodecRegister(&opus_codec);
|
||||
#endif
|
||||
|
||||
#ifdef USE_CODEC_VORBIS
|
||||
S_CodecRegister(&ogg_codec);
|
||||
#endif
|
||||
|
|
|
@ -95,4 +95,13 @@ void S_OGG_CodecCloseStream(snd_stream_t *stream);
|
|||
int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
|
||||
#endif // USE_CODEC_VORBIS
|
||||
|
||||
// Ogg Opus codec
|
||||
#ifdef USE_CODEC_OPUS
|
||||
extern snd_codec_t opus_codec;
|
||||
void *S_OggOpus_CodecLoad(const char *filename, snd_info_t *info);
|
||||
snd_stream_t *S_OggOpus_CodecOpenStream(const char *filename);
|
||||
void S_OggOpus_CodecCloseStream(snd_stream_t *stream);
|
||||
int S_OggOpus_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
|
||||
#endif // USE_CODEC_OPUS
|
||||
|
||||
#endif // !_SND_CODEC_H_
|
||||
|
|
452
code/client/snd_codec_opus.c
Normal file
452
code/client/snd_codec_opus.c
Normal file
|
@ -0,0 +1,452 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
|
||||
Copyright (C) 2005-2006 Joerg Dietrich <dietrich_joerg@gmx.de>
|
||||
|
||||
This file is part of Quake III Arena source code.
|
||||
|
||||
Quake III Arena source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Quake III Arena source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Quake III Arena source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// Ogg Opus support is enabled by this define
|
||||
#ifdef USE_CODEC_OPUS
|
||||
|
||||
// includes for the Q3 sound system
|
||||
#include "client.h"
|
||||
#include "snd_codec.h"
|
||||
|
||||
// includes for the Ogg Opus codec
|
||||
#include <errno.h>
|
||||
#include <opusfile.h>
|
||||
|
||||
// samples are 16 bit
|
||||
#define OPUS_SAMPLEWIDTH 2
|
||||
|
||||
// Q3 Ogg Opus codec
|
||||
snd_codec_t opus_codec =
|
||||
{
|
||||
"opus",
|
||||
S_OggOpus_CodecLoad,
|
||||
S_OggOpus_CodecOpenStream,
|
||||
S_OggOpus_CodecReadStream,
|
||||
S_OggOpus_CodecCloseStream,
|
||||
NULL
|
||||
};
|
||||
|
||||
// callbacks for opusfile
|
||||
|
||||
// fread() replacement
|
||||
int S_OggOpus_Callback_read(void *datasource, unsigned char *ptr, int size )
|
||||
{
|
||||
snd_stream_t *stream;
|
||||
int bytesRead = 0;
|
||||
|
||||
// check if input is valid
|
||||
if(!ptr)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!size)
|
||||
{
|
||||
// It's not an error, caller just wants zero bytes!
|
||||
errno = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (size < 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!datasource)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// we use a snd_stream_t in the generic pointer to pass around
|
||||
stream = (snd_stream_t *) datasource;
|
||||
|
||||
// read it with the Q3 function FS_Read()
|
||||
bytesRead = FS_Read(ptr, size, stream->file);
|
||||
|
||||
// update the file position
|
||||
stream->pos += bytesRead;
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
// fseek() replacement
|
||||
int S_OggOpus_Callback_seek(void *datasource, opus_int64 offset, int whence)
|
||||
{
|
||||
snd_stream_t *stream;
|
||||
int retVal = 0;
|
||||
|
||||
// check if input is valid
|
||||
if(!datasource)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// snd_stream_t in the generic pointer
|
||||
stream = (snd_stream_t *) datasource;
|
||||
|
||||
// we must map the whence to its Q3 counterpart
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET :
|
||||
{
|
||||
// set the file position in the actual file with the Q3 function
|
||||
retVal = FS_Seek(stream->file, (long) offset, FS_SEEK_SET);
|
||||
|
||||
// something has gone wrong, so we return here
|
||||
if(retVal < 0)
|
||||
{
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// keep track of file position
|
||||
stream->pos = (int) offset;
|
||||
break;
|
||||
}
|
||||
|
||||
case SEEK_CUR :
|
||||
{
|
||||
// set the file position in the actual file with the Q3 function
|
||||
retVal = FS_Seek(stream->file, (long) offset, FS_SEEK_CUR);
|
||||
|
||||
// something has gone wrong, so we return here
|
||||
if(retVal < 0)
|
||||
{
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// keep track of file position
|
||||
stream->pos += (int) offset;
|
||||
break;
|
||||
}
|
||||
|
||||
case SEEK_END :
|
||||
{
|
||||
// Quake 3 seems to have trouble with FS_SEEK_END
|
||||
// so we use the file length and FS_SEEK_SET
|
||||
|
||||
// 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);
|
||||
|
||||
// something has gone wrong, so we return here
|
||||
if(retVal < 0)
|
||||
{
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// keep track of file position
|
||||
stream->pos = stream->length + (int) offset;
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
{
|
||||
// unknown whence, so we return an error
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// stream->pos shouldn't be smaller than zero or bigger than the filesize
|
||||
stream->pos = (stream->pos < 0) ? 0 : stream->pos;
|
||||
stream->pos = (stream->pos > stream->length) ? stream->length : stream->pos;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// fclose() replacement
|
||||
int S_OggOpus_Callback_close(void *datasource)
|
||||
{
|
||||
// we do nothing here and close all things manually in S_OggOpus_CodecCloseStream()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ftell() replacement
|
||||
opus_int64 S_OggOpus_Callback_tell(void *datasource)
|
||||
{
|
||||
snd_stream_t *stream;
|
||||
|
||||
// check if input is valid
|
||||
if(!datasource)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// snd_stream_t in the generic pointer
|
||||
stream = (snd_stream_t *) datasource;
|
||||
|
||||
return (opus_int64) FS_FTell(stream->file);
|
||||
}
|
||||
|
||||
// the callback structure
|
||||
const OpusFileCallbacks S_OggOpus_Callbacks =
|
||||
{
|
||||
&S_OggOpus_Callback_read,
|
||||
&S_OggOpus_Callback_seek,
|
||||
&S_OggOpus_Callback_tell,
|
||||
&S_OggOpus_Callback_close
|
||||
};
|
||||
|
||||
/*
|
||||
=================
|
||||
S_OggOpus_CodecOpenStream
|
||||
=================
|
||||
*/
|
||||
snd_stream_t *S_OggOpus_CodecOpenStream(const char *filename)
|
||||
{
|
||||
snd_stream_t *stream;
|
||||
|
||||
// Opus codec control structure
|
||||
OggOpusFile *of;
|
||||
|
||||
// some variables used to get informations about the file
|
||||
const OpusHead *opusInfo;
|
||||
ogg_int64_t numSamples;
|
||||
|
||||
// check if input is valid
|
||||
if(!filename)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Open the stream
|
||||
stream = S_CodecUtilOpen(filename, &opus_codec);
|
||||
if(!stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// open the codec with our callbacks and stream as the generic pointer
|
||||
of = op_open_callbacks(stream, &S_OggOpus_Callbacks, NULL, 0, NULL );
|
||||
if (!of)
|
||||
{
|
||||
S_CodecUtilClose(&stream);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// the stream must be seekable
|
||||
if(!op_seekable(of))
|
||||
{
|
||||
op_free(of);
|
||||
|
||||
S_CodecUtilClose(&stream);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get the info about channels and rate
|
||||
opusInfo = op_head(of, -1);
|
||||
if(!opusInfo)
|
||||
{
|
||||
op_free(of);
|
||||
|
||||
S_CodecUtilClose(&stream);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(opusInfo->stream_count != 1)
|
||||
{
|
||||
op_free(of);
|
||||
|
||||
S_CodecUtilClose(&stream);
|
||||
|
||||
Com_Printf("Only Ogg Opus files with one stream are support\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(opusInfo->channel_count != 1 && opusInfo->channel_count != 2)
|
||||
{
|
||||
op_free(of);
|
||||
|
||||
S_CodecUtilClose(&stream);
|
||||
|
||||
Com_Printf("Only mono and stereo Ogg Opus files are supported\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get the number of sample-frames in the file
|
||||
numSamples = op_pcm_total(of, -1);
|
||||
|
||||
// fill in the info-structure in the stream
|
||||
stream->info.rate = 48000;
|
||||
stream->info.width = OPUS_SAMPLEWIDTH;
|
||||
stream->info.channels = opusInfo->channel_count;
|
||||
stream->info.samples = numSamples;
|
||||
stream->info.size = stream->info.samples * stream->info.channels * stream->info.width;
|
||||
stream->info.dataofs = 0;
|
||||
|
||||
// We use stream->pos for the file pointer in the compressed ogg file
|
||||
stream->pos = 0;
|
||||
|
||||
// We use the generic pointer in stream for the opus codec control structure
|
||||
stream->ptr = of;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
S_OggOpus_CodecCloseStream
|
||||
=================
|
||||
*/
|
||||
void S_OggOpus_CodecCloseStream(snd_stream_t *stream)
|
||||
{
|
||||
// check if input is valid
|
||||
if(!stream)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// let the opus codec cleanup its stuff
|
||||
op_free((OggOpusFile *) stream->ptr);
|
||||
|
||||
// close the stream
|
||||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
S_OggOpus_CodecReadStream
|
||||
=================
|
||||
*/
|
||||
int S_OggOpus_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
|
||||
{
|
||||
// buffer handling
|
||||
int samplesRead, samplesLeft, c;
|
||||
opus_int16 *bufPtr;
|
||||
|
||||
// check if input is valid
|
||||
if(!(stream && buffer))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(bytes <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
samplesRead = 0;
|
||||
samplesLeft = bytes / stream->info.channels / stream->info.width;
|
||||
bufPtr = buffer;
|
||||
|
||||
if(samplesLeft <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cycle until we have the requested or all available bytes read
|
||||
while(-1)
|
||||
{
|
||||
// read some samples from the opus codec
|
||||
c = op_read((OggOpusFile *) stream->ptr, bufPtr + samplesRead * stream->info.channels, samplesLeft * stream->info.channels, NULL);
|
||||
|
||||
// no more samples are left
|
||||
if(c <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
samplesRead += c;
|
||||
samplesLeft -= c;
|
||||
|
||||
// we have enough samples
|
||||
if(samplesLeft <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return samplesRead * stream->info.channels * stream->info.width;
|
||||
}
|
||||
|
||||
/*
|
||||
=====================================================================
|
||||
S_OggOpus_CodecLoad
|
||||
|
||||
We handle S_OggOpus_CodecLoad as a special case of the streaming functions
|
||||
where we read the whole stream at once.
|
||||
======================================================================
|
||||
*/
|
||||
void *S_OggOpus_CodecLoad(const char *filename, snd_info_t *info)
|
||||
{
|
||||
snd_stream_t *stream;
|
||||
byte *buffer;
|
||||
int bytesRead;
|
||||
|
||||
// check if input is valid
|
||||
if(!(filename && info))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// open the file as a stream
|
||||
stream = S_OggOpus_CodecOpenStream(filename);
|
||||
if(!stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// copy over the info
|
||||
info->rate = stream->info.rate;
|
||||
info->width = stream->info.width;
|
||||
info->channels = stream->info.channels;
|
||||
info->samples = stream->info.samples;
|
||||
info->size = stream->info.size;
|
||||
info->dataofs = stream->info.dataofs;
|
||||
|
||||
// allocate a buffer
|
||||
// this buffer must be free-ed by the caller of this function
|
||||
buffer = Hunk_AllocateTempMemory(info->size);
|
||||
if(!buffer)
|
||||
{
|
||||
S_OggOpus_CodecCloseStream(stream);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// fill the buffer
|
||||
bytesRead = S_OggOpus_CodecReadStream(stream, info->size, buffer);
|
||||
|
||||
// we don't even have read a single byte
|
||||
if(bytesRead <= 0)
|
||||
{
|
||||
Hunk_FreeTempMemory(buffer);
|
||||
S_OggOpus_CodecCloseStream(stream);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
S_OggOpus_CodecCloseStream(stream);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif // USE_CODEC_OPUS
|
|
@ -492,7 +492,7 @@ static qboolean S_Base_HearingThroughEntity( int entityNum, vec3_t origin )
|
|||
|
||||
if( listener_number == entityNum )
|
||||
{
|
||||
// FIXME: <tim@ngus.net> 28/02/06 This is an outrageous hack to detect
|
||||
// This is an outrageous hack to detect
|
||||
// whether or not the player is rendering in third person or not. We can't
|
||||
// ask the renderer because the renderer has no notion of entities and we
|
||||
// can't ask cgame since that would involve changing the API and hence mod
|
||||
|
@ -1452,7 +1452,6 @@ void S_UpdateBackgroundTrack( void ) {
|
|||
r = S_CodecReadStream(s_backgroundStream, fileBytes, raw);
|
||||
if(r < fileBytes)
|
||||
{
|
||||
fileBytes = r;
|
||||
fileSamples = r / (s_backgroundStream->info.width * s_backgroundStream->info.channels);
|
||||
}
|
||||
|
||||
|
|
|
@ -598,7 +598,7 @@ void S_PaintChannelFromMuLaw( channel_t *ch, sfx_t *sc, int count, int sampleOff
|
|||
samp[i].left += (data * leftvol)>>8;
|
||||
samp[i].right += (data * rightvol)>>8;
|
||||
samples++;
|
||||
if (samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) {
|
||||
if (chunk != NULL && samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) {
|
||||
chunk = chunk->next;
|
||||
samples = (byte *)chunk->sndChunk;
|
||||
}
|
||||
|
|
|
@ -656,7 +656,7 @@ static qboolean S_AL_HearingThroughEntity( int entityNum )
|
|||
|
||||
if( lastListenerNumber == entityNum )
|
||||
{
|
||||
// FIXME: <tim@ngus.net> 28/02/06 This is an outrageous hack to detect
|
||||
// This is an outrageous hack to detect
|
||||
// whether or not the player is rendering in third person or not. We can't
|
||||
// ask the renderer because the renderer has no notion of entities and we
|
||||
// can't ask cgame since that would involve changing the API and hence mod
|
||||
|
@ -2125,6 +2125,8 @@ static cvar_t *s_alCapture;
|
|||
#define ALDRIVER_DEFAULT "OpenAL32.dll"
|
||||
#elif defined(MACOS_X)
|
||||
#define ALDRIVER_DEFAULT "/System/Library/Frameworks/OpenAL.framework/OpenAL"
|
||||
#elif defined(__OpenBSD__)
|
||||
#define ALDRIVER_DEFAULT "libopenal.so"
|
||||
#else
|
||||
#define ALDRIVER_DEFAULT "libopenal.so.1"
|
||||
#endif
|
||||
|
@ -2496,8 +2498,6 @@ qboolean S_AL_Init( soundInterface_t *si )
|
|||
devicelist += curlen + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
devicelist = "";
|
||||
|
||||
s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
void daub4(float b[], unsigned long n, int isign)
|
||||
{
|
||||
float wksp[4097];
|
||||
float wksp[4097] = { 0.0f };
|
||||
float *a=b-1; // numerical recipies so a[1] = b[0]
|
||||
|
||||
unsigned long nh,nh1,i,j;
|
||||
|
@ -146,7 +146,7 @@ void encodeWavelet( sfx_t *sfx, short *packets) {
|
|||
newchunk = SND_malloc();
|
||||
if (sfx->soundData == NULL) {
|
||||
sfx->soundData = newchunk;
|
||||
} else {
|
||||
} else if (chunk != NULL) {
|
||||
chunk->next = newchunk;
|
||||
}
|
||||
chunk = newchunk;
|
||||
|
@ -215,7 +215,7 @@ void encodeMuLaw( sfx_t *sfx, short *packets) {
|
|||
newchunk = SND_malloc();
|
||||
if (sfx->soundData == NULL) {
|
||||
sfx->soundData = newchunk;
|
||||
} else {
|
||||
} else if (chunk != NULL) {
|
||||
chunk->next = newchunk;
|
||||
}
|
||||
chunk = newchunk;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue