2004-08-23 00:15:46 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
|
|
|
|
#ifdef AVAIL_OGGVORBIS
|
2014-02-13 23:54:57 +00:00
|
|
|
#define OV_EXCLUDE_STATIC_CALLBACKS
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2006-07-08 22:45:07 +00:00
|
|
|
#ifdef __MORPHOS__
|
2007-06-20 00:02:54 +00:00
|
|
|
#include <exec/exec.h>
|
|
|
|
#include <libraries/vorbisfile.h>
|
2006-07-08 22:45:07 +00:00
|
|
|
|
2007-06-20 00:02:54 +00:00
|
|
|
#include <proto/exec.h>
|
|
|
|
#include <proto/vorbisfile.h>
|
2007-10-20 15:53:39 +00:00
|
|
|
#else
|
2007-06-20 00:02:54 +00:00
|
|
|
#include <vorbis/vorbisfile.h>
|
2006-07-08 22:45:07 +00:00
|
|
|
#endif
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-10-24 01:32:10 +00:00
|
|
|
#ifdef LIBVORBISFILE_STATIC
|
|
|
|
#define p_ov_open_callbacks ov_open_callbacks
|
2007-06-20 00:02:54 +00:00
|
|
|
#define p_ov_clear ov_clear
|
|
|
|
#define p_ov_info ov_info
|
|
|
|
#define p_ov_comment ov_comment
|
|
|
|
#define p_ov_pcm_total ov_pcm_total
|
2015-07-27 08:21:34 +00:00
|
|
|
#define p_ov_time_total ov_time_total
|
2007-06-20 00:02:54 +00:00
|
|
|
#define p_ov_read ov_read
|
2012-02-27 12:23:15 +00:00
|
|
|
#define p_ov_pcm_seek ov_pcm_seek
|
2006-07-08 22:45:07 +00:00
|
|
|
#else
|
2012-10-24 01:32:10 +00:00
|
|
|
#if defined(__MORPHOS__)
|
|
|
|
|
|
|
|
#define oggvorbislibrary VorbisFileBase
|
|
|
|
struct Library *VorbisFileBase;
|
|
|
|
|
|
|
|
#else
|
|
|
|
dllhandle_t *oggvorbislibrary;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __MORPHOS__
|
|
|
|
#define p_ov_open_callbacks(a, b, c, d, e) ov_open_callbacks(a, b, c, d, &e)
|
|
|
|
#define p_ov_clear ov_clear
|
|
|
|
#define p_ov_info ov_info
|
|
|
|
#define p_ov_comment ov_comment
|
|
|
|
#define p_ov_pcm_total ov_pcm_total
|
2015-07-27 08:21:34 +00:00
|
|
|
#define p_ov_time_total ov_time_total
|
2012-10-24 01:32:10 +00:00
|
|
|
#define p_ov_read ov_read
|
|
|
|
#define p_ov_pcm_seek ov_pcm_seek
|
|
|
|
#else
|
|
|
|
int (VARGS *p_ov_open_callbacks) (void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
|
|
|
|
int (VARGS *p_ov_clear)(OggVorbis_File *vf);
|
|
|
|
vorbis_info *(VARGS *p_ov_info)(OggVorbis_File *vf,int link);
|
|
|
|
vorbis_comment *(VARGS *p_ov_comment) (OggVorbis_File *vf,int link);
|
|
|
|
ogg_int64_t (VARGS *p_ov_pcm_total)(OggVorbis_File *vf,int i);
|
2015-07-27 08:21:34 +00:00
|
|
|
double (VARGS *p_ov_time_total)(OggVorbis_File *vf,int i);
|
|
|
|
long (VARGS *p_ov_read)(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream);
|
2012-10-24 01:32:10 +00:00
|
|
|
int (VARGS *p_ov_pcm_seek)(OggVorbis_File *vf,ogg_int64_t pos);
|
|
|
|
#endif
|
2006-07-08 22:45:07 +00:00
|
|
|
#endif
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned char *start; //file positions
|
|
|
|
unsigned long length;
|
|
|
|
unsigned long pos;
|
2005-03-29 15:01:57 +00:00
|
|
|
int srcspeed;
|
2012-02-27 12:23:15 +00:00
|
|
|
int srcchannels;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2018-09-23 19:35:24 +00:00
|
|
|
qboolean nopurge;
|
2004-08-23 00:15:46 +00:00
|
|
|
qboolean failed;
|
|
|
|
|
2012-10-24 02:59:31 +00:00
|
|
|
char *tempbuffer;
|
2012-02-27 12:23:15 +00:00
|
|
|
int tempbufferbytes;
|
|
|
|
|
|
|
|
char *decodedbuffer;
|
|
|
|
int decodedbufferbytes;
|
|
|
|
int decodedbytestart;
|
|
|
|
int decodedbytecount;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2018-03-05 11:34:20 +00:00
|
|
|
quintptr_t pcmtotal;
|
|
|
|
float timetotal;
|
2004-08-23 00:15:46 +00:00
|
|
|
OggVorbis_File vf;
|
|
|
|
|
|
|
|
sfx_t *s;
|
|
|
|
} ovdecoderbuffer_t;
|
|
|
|
|
2018-09-23 19:35:24 +00:00
|
|
|
static float QDECL OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf, char *name, size_t namesize)
|
2015-07-14 14:47:00 +00:00
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *dec = sfx->decoder.buf;
|
|
|
|
if (!dec)
|
2015-07-27 08:21:34 +00:00
|
|
|
return -1;
|
2018-03-05 11:34:20 +00:00
|
|
|
|
2023-07-26 19:12:55 +00:00
|
|
|
// if (dec->pcmtotal == 0)
|
|
|
|
// dec->pcmtotal = p_ov_pcm_total(&dec->vf, -1);
|
|
|
|
// if (dec->timetotal < 0)
|
|
|
|
// dec->timetotal = p_ov_time_total(&dec->vf, -1);
|
2018-03-05 11:34:20 +00:00
|
|
|
|
2015-07-14 14:47:00 +00:00
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
buf->data = NULL; //you're not meant to actually be using the data here
|
|
|
|
buf->soundoffset = 0;
|
2018-03-05 11:34:20 +00:00
|
|
|
buf->length = dec->pcmtotal;
|
2015-07-14 14:47:00 +00:00
|
|
|
buf->numchannels = dec->srcchannels;
|
|
|
|
buf->speed = dec->srcspeed;
|
2020-04-29 10:43:22 +00:00
|
|
|
buf->format = QAF_S16;
|
2015-07-14 14:47:00 +00:00
|
|
|
}
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
vorbis_comment *c = p_ov_comment(&dec->vf, -1);
|
|
|
|
int i;
|
|
|
|
const char *artist = NULL;
|
|
|
|
const char *title = NULL;
|
|
|
|
for (i = 0; i < c->comments; i++)
|
|
|
|
{
|
|
|
|
if (!strncmp(c->user_comments[i], "ARTIST=", 7))
|
|
|
|
artist = c->user_comments[i]+7;
|
|
|
|
else if (!strncmp(c->user_comments[i], "TITLE=", 6))
|
|
|
|
title = c->user_comments[i]+6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (artist && title)
|
|
|
|
Q_snprintfz(name, namesize, "%s - %s", artist, title);
|
|
|
|
else if (title)
|
|
|
|
Q_snprintfz(name, namesize, "%s", title);
|
|
|
|
}
|
2018-03-05 11:34:20 +00:00
|
|
|
return dec->timetotal;
|
2015-07-14 14:47:00 +00:00
|
|
|
}
|
|
|
|
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
static sfxcache_t *QDECL OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssamplepos_t start, int length)
|
2012-10-24 02:59:31 +00:00
|
|
|
{
|
2005-03-29 15:01:57 +00:00
|
|
|
extern int snd_speed;
|
2008-05-11 14:38:19 +00:00
|
|
|
extern cvar_t snd_linearresample_stream;
|
2006-07-08 22:45:07 +00:00
|
|
|
int bigendianp = bigendian;
|
2005-03-29 15:01:57 +00:00
|
|
|
int current_section = 0;
|
2004-11-17 18:10:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
ovdecoderbuffer_t *dec = sfx->decoder.buf;
|
2004-08-23 00:15:46 +00:00
|
|
|
int bytesread;
|
2004-11-17 18:10:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
int outspeed = snd_speed;
|
|
|
|
|
2005-11-30 01:20:53 +00:00
|
|
|
// Con_Printf("Minlength = %03i ", minlength);
|
2005-05-26 12:55:34 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
start *= 2*dec->srcchannels;
|
|
|
|
length *= 2*dec->srcchannels;
|
|
|
|
|
2017-11-05 13:15:08 +00:00
|
|
|
if (length)
|
2012-10-08 04:36:10 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
if (start < dec->decodedbytestart)
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
// Con_Printf("Rewound to %i\n", start);
|
|
|
|
dec->failed = false;
|
|
|
|
|
|
|
|
//check pos
|
|
|
|
if (p_ov_pcm_seek(&dec->vf, start * (dec->srcspeed/(2.0*dec->srcchannels*outspeed))) == 0)
|
|
|
|
{
|
|
|
|
/*something rewound, purge clear the buffer*/
|
|
|
|
dec->decodedbytecount = 0;
|
|
|
|
dec->decodedbytestart = start;
|
|
|
|
}
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
}
|
2012-10-08 04:36:10 +00:00
|
|
|
|
2017-11-05 13:15:08 +00:00
|
|
|
/* if (start > dec->decodedbytestart + dec->decodedbytecount)
|
2007-06-20 00:02:54 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
dec->decodedbytestart = start;
|
2017-11-05 13:15:08 +00:00
|
|
|
p_ov_pcm_seek(&dec->vf, (dec->decodedbytestart * dec->srcspeed) / outspeed);
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2017-11-05 13:15:08 +00:00
|
|
|
*/
|
2018-09-23 19:35:24 +00:00
|
|
|
if (dec->decodedbytecount > outspeed*8 && !dec->nopurge)
|
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
/*everything is okay, but our buffer is getting needlessly large.
|
|
|
|
keep anything after the 'new' position, but discard all before that
|
|
|
|
trim shouldn't be able to go negative
|
|
|
|
*/
|
|
|
|
int trim = start - dec->decodedbytestart;
|
|
|
|
if (trim < 0)
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
{
|
|
|
|
dec->decodedbytecount = 0;
|
|
|
|
dec->decodedbytestart = start;
|
2017-11-05 13:15:08 +00:00
|
|
|
// Con_Printf("trim < 0\n");
|
|
|
|
}
|
|
|
|
else if (trim > dec->decodedbytecount)
|
|
|
|
{
|
|
|
|
if (0==p_ov_pcm_seek(&dec->vf, start * (dec->srcspeed/(2.0*dec->srcchannels*outspeed))))
|
|
|
|
{
|
|
|
|
dec->decodedbytecount = 0;
|
|
|
|
dec->decodedbytestart = start;
|
|
|
|
}
|
|
|
|
// Con_Printf("trim > count\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Con_Printf("trim retain\n");
|
|
|
|
//FIXME: retain an extra half-second for dual+ sound devices running slightly out of sync
|
|
|
|
memmove(dec->decodedbuffer, dec->decodedbuffer + trim, dec->decodedbytecount - trim);
|
|
|
|
dec->decodedbytecount -= trim;
|
|
|
|
dec->decodedbytestart += trim;
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
}
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2012-10-08 04:36:10 +00:00
|
|
|
|
2017-11-05 13:15:08 +00:00
|
|
|
for (;;)
|
2005-05-26 12:55:34 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
if (dec->failed || start+length <= dec->decodedbytestart + dec->decodedbytecount)
|
|
|
|
break;
|
2012-02-27 12:23:15 +00:00
|
|
|
|
2023-07-26 19:12:55 +00:00
|
|
|
if (dec->decodedbufferbytes < start+length - dec->decodedbytestart + 4096 && !dec->nopurge) //expand if needed. 4096 seems to be the recommended size.
|
2007-06-20 00:02:54 +00:00
|
|
|
{
|
2023-07-26 19:12:55 +00:00
|
|
|
// Con_Printf("Expand buffer for %s\n", sfx->name);
|
2019-09-03 12:33:14 +00:00
|
|
|
dec->decodedbufferbytes = (start+length - dec->decodedbytestart) + max(outspeed, 4096); //over allocate, because we can.
|
2017-11-05 13:15:08 +00:00
|
|
|
dec->decodedbuffer = BZ_Realloc(dec->decodedbuffer, dec->decodedbufferbytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (outspeed == dec->srcspeed)
|
|
|
|
{
|
|
|
|
bytesread = p_ov_read(&dec->vf, dec->decodedbuffer+dec->decodedbytecount, (start+length) - (dec->decodedbytestart+dec->decodedbytecount), bigendianp, 2, 1, ¤t_section);
|
|
|
|
if (bytesread <= 0)
|
2008-05-11 14:38:19 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
if (bytesread != 0) //0==eof
|
|
|
|
{
|
|
|
|
dec->failed = true;
|
|
|
|
Con_Printf("ogg decoding failed %i\n", bytesread);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (start >= dec->decodedbytestart+dec->decodedbytecount)
|
|
|
|
return NULL; //let the mixer know that we hit the end
|
2015-09-02 03:12:25 +00:00
|
|
|
break;
|
2008-05-11 14:38:19 +00:00
|
|
|
}
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2017-11-05 13:15:08 +00:00
|
|
|
else
|
2005-03-29 15:01:57 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
double scale = dec->srcspeed / (double)outspeed;
|
2019-09-03 12:33:14 +00:00
|
|
|
int decodesize = dec->decodedbufferbytes-dec->decodedbytecount; //bytes available
|
|
|
|
decodesize /= 2*dec->srcchannels; //convert bytes to frames
|
|
|
|
decodesize = floor(decodesize * scale); //round down, so that the SND_ResampleStream won't overflow the target buffer.
|
|
|
|
decodesize *= 2*dec->srcchannels; //convert from frames back to bytes
|
2017-11-05 13:15:08 +00:00
|
|
|
if (decodesize > dec->tempbufferbytes)
|
|
|
|
{
|
|
|
|
dec->tempbuffer = BZ_Realloc(dec->tempbuffer, decodesize);
|
|
|
|
dec->tempbufferbytes = decodesize;
|
|
|
|
}
|
2008-05-11 14:38:19 +00:00
|
|
|
|
2017-11-05 13:15:08 +00:00
|
|
|
bytesread = p_ov_read(&dec->vf, dec->tempbuffer, decodesize, bigendianp, 2, 1, ¤t_section);
|
2008-05-11 14:38:19 +00:00
|
|
|
|
2017-11-05 13:15:08 +00:00
|
|
|
if (bytesread <= 0)
|
2008-11-09 22:29:28 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
if (bytesread != 0) //0==eof
|
|
|
|
{
|
|
|
|
dec->failed = true;
|
|
|
|
Con_Printf("ogg decoding failed %i\n", bytesread);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (start >= dec->decodedbytestart+dec->decodedbytecount)
|
|
|
|
return NULL; //let the mixer know that we hit the end
|
|
|
|
break;
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
2017-11-05 13:15:08 +00:00
|
|
|
|
|
|
|
SND_ResampleStream(dec->tempbuffer,
|
|
|
|
dec->srcspeed,
|
|
|
|
2,
|
|
|
|
dec->srcchannels,
|
|
|
|
bytesread / (2 * dec->srcchannels),
|
|
|
|
dec->decodedbuffer+dec->decodedbytecount,
|
|
|
|
outspeed,
|
|
|
|
2,
|
|
|
|
dec->srcchannels,
|
|
|
|
snd_linearresample_stream.ival);
|
2019-09-03 12:33:14 +00:00
|
|
|
bytesread /= 2*dec->srcchannels; //convert bytes to frames
|
|
|
|
bytesread = bytesread / scale; //calculate the same ammount that SND_ResampleStream will have splurged (we should probably make the output count explicit).
|
|
|
|
bytesread *= 2*dec->srcchannels; //convert frames to bytes
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 13:15:08 +00:00
|
|
|
dec->decodedbytecount += bytesread;
|
2005-03-29 15:01:57 +00:00
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
}
|
2004-11-17 18:10:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
buf->data = dec->decodedbuffer;
|
|
|
|
buf->soundoffset = dec->decodedbytestart / (2 * dec->srcchannels);
|
2015-04-21 04:12:00 +00:00
|
|
|
buf->length = dec->decodedbytecount / (2 * dec->srcchannels);
|
2012-02-27 12:23:15 +00:00
|
|
|
buf->numchannels = dec->srcchannels;
|
|
|
|
buf->speed = snd_speed;
|
2020-04-29 10:43:22 +00:00
|
|
|
buf->format = QAF_S16;
|
2004-11-17 18:10:46 +00:00
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
return buf;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2016-02-15 06:01:17 +00:00
|
|
|
/*static void OV_CanceledDecoder(void *ctx, void *data, size_t a, size_t b)
|
2015-07-14 14:47:00 +00:00
|
|
|
{
|
|
|
|
sfx_t *s = ctx;
|
|
|
|
if (s->loadstate != SLS_LOADING)
|
|
|
|
s->loadstate = SLS_NOTLOADED;
|
2016-02-15 06:01:17 +00:00
|
|
|
}*/
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
static void QDECL OV_CancelDecoder(sfx_t *s)
|
2018-09-23 19:35:24 +00:00
|
|
|
{ //called when the sound is unloaded. the entire thing is going away.
|
2005-03-29 15:01:57 +00:00
|
|
|
ovdecoderbuffer_t *dec;
|
2015-07-14 14:47:00 +00:00
|
|
|
s->loadstate = SLS_FAILED;
|
2005-03-29 15:01:57 +00:00
|
|
|
|
2012-07-05 19:42:36 +00:00
|
|
|
dec = s->decoder.buf;
|
|
|
|
s->decoder.buf = NULL;
|
2014-09-12 13:14:51 +00:00
|
|
|
s->decoder.purge = NULL;
|
|
|
|
s->decoder.ended = NULL;
|
2015-07-14 14:47:00 +00:00
|
|
|
s->decoder.querydata = NULL;
|
2012-07-05 19:42:36 +00:00
|
|
|
s->decoder.decodedata = NULL;
|
2005-03-29 15:01:57 +00:00
|
|
|
p_ov_clear (&dec->vf); //close the decoder
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
if (dec->tempbuffer)
|
2008-05-11 14:38:19 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
BZ_Free(dec->tempbuffer);
|
2012-07-05 19:42:36 +00:00
|
|
|
dec->tempbufferbytes = 0;
|
2008-05-11 14:38:19 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 19:42:36 +00:00
|
|
|
BZ_Free(dec->decodedbuffer);
|
|
|
|
dec->decodedbuffer = NULL;
|
2005-03-29 15:01:57 +00:00
|
|
|
|
2012-07-05 19:42:36 +00:00
|
|
|
BZ_Free(dec);
|
2015-07-14 14:47:00 +00:00
|
|
|
|
|
|
|
//due to the nature of message passing, we can get into a state where the main thread is going to flag us as loaded when we have already failed.
|
|
|
|
//that is bad.
|
|
|
|
//so post a message to the main thread to override it, just in case.
|
2016-02-15 06:01:17 +00:00
|
|
|
// COM_AddWork(WG_MAIN, OV_CanceledDecoder, s, NULL, SLS_NOTLOADED, 0);
|
2015-04-21 04:12:00 +00:00
|
|
|
s->loadstate = SLS_NOTLOADED;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2018-09-23 19:35:24 +00:00
|
|
|
static void QDECL OV_ClearDecoder(sfx_t *s)
|
|
|
|
{ //called when the sound is no longer playing.
|
|
|
|
ovdecoderbuffer_t *dec;
|
|
|
|
dec = s->decoder.buf;
|
|
|
|
if (dec->nopurge)
|
|
|
|
{
|
|
|
|
/* BZ_Free(dec->tempbuffer);
|
|
|
|
dec->tempbuffer = NULL;
|
|
|
|
dec->tempbufferbytes = 0;
|
|
|
|
|
|
|
|
BZ_Free(dec->decodedbuffer);
|
|
|
|
dec->decodedbuffer = NULL;
|
|
|
|
dec->decodedbufferbytes = 0;
|
|
|
|
dec->decodedbytestart = 0;
|
|
|
|
dec->decodedbytecount = 0;
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
OV_CancelDecoder(s);
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static size_t VARGS read_func (void *ptr, size_t size, size_t nmemb, void *datasource)
|
2012-10-24 02:59:31 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
|
|
|
int spare = buffer->length - buffer->pos;
|
|
|
|
|
|
|
|
if (size*nmemb > spare)
|
|
|
|
nmemb = spare / size;
|
|
|
|
memcpy(ptr, &buffer->start[buffer->pos], size*nmemb);
|
|
|
|
buffer->pos += size*nmemb;
|
|
|
|
return nmemb;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static int VARGS seek_func (void *datasource, ogg_int64_t offset, int whence)
|
2012-10-24 02:59:31 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
|
|
|
switch(whence)
|
|
|
|
{
|
|
|
|
case SEEK_SET:
|
|
|
|
buffer->pos = offset;
|
|
|
|
break;
|
|
|
|
case SEEK_END:
|
|
|
|
buffer->pos = buffer->length+offset;
|
|
|
|
break;
|
|
|
|
case SEEK_CUR:
|
|
|
|
buffer->pos+=offset;
|
|
|
|
break;
|
2012-10-24 02:59:31 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static int VARGS close_func (void *datasource)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
2005-03-29 15:01:57 +00:00
|
|
|
BZ_Free(buffer->start);
|
2004-08-23 00:15:46 +00:00
|
|
|
buffer->start=0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static long VARGS tell_func (void *datasource)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
|
|
|
return buffer->pos;
|
|
|
|
}
|
|
|
|
static ov_callbacks callbacks = {
|
|
|
|
read_func,
|
|
|
|
seek_func,
|
|
|
|
close_func,
|
|
|
|
tell_func,
|
|
|
|
};
|
2015-07-14 14:47:00 +00:00
|
|
|
static qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdecoderbuffer_t *buffer)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-10-24 01:32:10 +00:00
|
|
|
#ifndef LIBVORBISFILE_STATIC
|
2005-04-16 16:21:27 +00:00
|
|
|
static qboolean tried;
|
2012-05-10 12:55:14 +00:00
|
|
|
#ifndef __MORPHOS__
|
2012-02-27 12:23:15 +00:00
|
|
|
static dllfunction_t funcs[] =
|
|
|
|
{
|
|
|
|
{(void*)&p_ov_open_callbacks, "ov_open_callbacks"},
|
|
|
|
{(void*)&p_ov_comment, "ov_comment"},
|
|
|
|
{(void*)&p_ov_pcm_total, "ov_pcm_total"},
|
2015-07-27 08:21:34 +00:00
|
|
|
{(void*)&p_ov_time_total, "ov_time_total"},
|
2012-02-27 12:23:15 +00:00
|
|
|
{(void*)&p_ov_clear, "ov_clear"},
|
|
|
|
{(void*)&p_ov_info, "ov_info"},
|
|
|
|
{(void*)&p_ov_read, "ov_read"},
|
|
|
|
{(void*)&p_ov_pcm_seek, "ov_pcm_seek"},
|
|
|
|
{NULL}
|
|
|
|
};
|
2012-05-10 12:55:14 +00:00
|
|
|
#endif
|
2012-02-27 12:23:15 +00:00
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
if (!oggvorbislibrary && !tried)
|
2006-07-08 22:45:07 +00:00
|
|
|
#if defined(__MORPHOS__)
|
|
|
|
{
|
|
|
|
VorbisFileBase = OpenLibrary("vorbisfile.library", 2);
|
|
|
|
if (!VorbisFileBase)
|
|
|
|
{
|
|
|
|
Con_Printf("Unable to open vorbisfile.library version 2\n");
|
|
|
|
}
|
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
#elif defined(_WIN32)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
oggvorbislibrary = Sys_LoadLibrary("vorbisfile", funcs);
|
2007-06-20 00:02:54 +00:00
|
|
|
if (!oggvorbislibrary)
|
2012-02-27 12:23:15 +00:00
|
|
|
oggvorbislibrary = Sys_LoadLibrary("libvorbisfile", funcs);
|
2012-10-24 02:59:31 +00:00
|
|
|
|
|
|
|
if (!oggvorbislibrary)
|
|
|
|
{
|
|
|
|
oggvorbislibrary = Sys_LoadLibrary("libvorbisfile-3", funcs);
|
|
|
|
if (!oggvorbislibrary)
|
|
|
|
oggvorbislibrary = Sys_LoadLibrary("libvorbisfile", funcs);
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!oggvorbislibrary)
|
2012-10-24 02:59:31 +00:00
|
|
|
Con_Printf("Couldn't load DLL: \"vorbisfile.dll\" or \"libvorbisfile-3\".\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
#else
|
2005-04-18 03:21:16 +00:00
|
|
|
{
|
2016-11-02 08:01:21 +00:00
|
|
|
oggvorbislibrary = Sys_LoadLibrary("libvorbisfile.so.3", funcs);
|
|
|
|
if (!oggvorbislibrary)
|
|
|
|
oggvorbislibrary = Sys_LoadLibrary("libvorbisfile", funcs);
|
2005-04-18 03:21:16 +00:00
|
|
|
if (!oggvorbislibrary)
|
2012-02-27 12:23:15 +00:00
|
|
|
Con_Printf("Couldn't load library: \"libvorbisfile\".\n");
|
2005-04-18 03:21:16 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-08 22:45:07 +00:00
|
|
|
tried = true;
|
|
|
|
|
2006-03-12 05:23:18 +00:00
|
|
|
if (!oggvorbislibrary)
|
2007-06-20 00:02:54 +00:00
|
|
|
{
|
|
|
|
Con_Printf("ogg vorbis library is not loaded.\n");
|
2006-03-12 05:23:18 +00:00
|
|
|
return false;
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2012-10-24 01:32:10 +00:00
|
|
|
#endif
|
2006-03-12 05:23:18 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
buffer->start = start;
|
|
|
|
buffer->length = length;
|
|
|
|
buffer->pos = 0;
|
|
|
|
if (p_ov_open_callbacks(buffer, &buffer->vf, NULL, 0, callbacks))
|
|
|
|
{
|
2015-09-02 03:12:25 +00:00
|
|
|
Con_Printf("Input %s does not appear to be an Ogg Vorbis bitstream.\n", buffer->s->name);
|
2004-08-23 00:15:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-03-29 15:01:57 +00:00
|
|
|
/* Print the comments plus a few lines about the bitstream we're
|
2004-08-23 00:15:46 +00:00
|
|
|
decoding */
|
|
|
|
{
|
2005-04-16 16:21:27 +00:00
|
|
|
// char **ptr=p_ov_comment(&buffer->vf,-1)->user_comments;
|
2004-08-23 00:15:46 +00:00
|
|
|
vorbis_info *vi=p_ov_info(&buffer->vf,-1);
|
2005-03-29 15:01:57 +00:00
|
|
|
|
|
|
|
if (vi->channels < 1 || vi->channels > 2)
|
|
|
|
{
|
|
|
|
p_ov_clear (&buffer->vf);
|
2015-09-02 03:12:25 +00:00
|
|
|
Con_Printf("Input %s has %i channels.\n", buffer->s->name, vi->channels);
|
2005-03-29 15:01:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
buffer->srcchannels = vi->channels;
|
2005-03-29 15:01:57 +00:00
|
|
|
buffer->srcspeed = vi->rate;
|
2005-04-16 16:21:27 +00:00
|
|
|
/*
|
2004-08-23 00:15:46 +00:00
|
|
|
while(*ptr){
|
|
|
|
Con_Printf("%s\n",*ptr);
|
2005-04-16 16:21:27 +00:00
|
|
|
ptr++;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
Con_Printf("\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
|
|
|
|
Con_Printf("\nDecoded length: %ld samples\n",
|
|
|
|
(long)p_ov_pcm_total(&buffer->vf,-1));
|
|
|
|
Con_Printf("Encoded by: %s\n\n",p_ov_comment(&buffer->vf,-1)->vendor);
|
2005-04-16 16:21:27 +00:00
|
|
|
*/ }
|
2012-02-27 12:23:15 +00:00
|
|
|
buffer->tempbuffer = NULL;
|
|
|
|
buffer->tempbufferbytes = 0;
|
2005-11-30 01:20:53 +00:00
|
|
|
|
|
|
|
buffer->start = BZ_Malloc(length);
|
|
|
|
memcpy(buffer->start, start, length);
|
|
|
|
|
2023-07-26 19:12:55 +00:00
|
|
|
buffer->pcmtotal = p_ov_pcm_total(&buffer->vf, -1);
|
|
|
|
buffer->timetotal = buffer->pcmtotal / (float)buffer->srcspeed;
|
|
|
|
|
|
|
|
if (buffer->timetotal < 5) //short sounds might as well remain cached.
|
|
|
|
buffer->nopurge = true;
|
2018-03-05 11:34:20 +00:00
|
|
|
|
2023-07-26 19:12:55 +00:00
|
|
|
if (buffer->nopurge)
|
|
|
|
{ //waste more memory upfront to avoid reallocs later.
|
|
|
|
buffer->decodedbufferbytes = buffer->pcmtotal;
|
|
|
|
buffer->decodedbufferbytes += 4096; //ogg vorbis apparently lies/fails sometimes.
|
|
|
|
buffer->decodedbufferbytes *= (double)snd_speed / buffer->srcspeed; //from src rate to dst rate
|
|
|
|
buffer->decodedbufferbytes *= 2*buffer->srcchannels; //convert from frames to bytes.
|
|
|
|
buffer->decodedbufferbytes += 4096; //just general paranoia.
|
|
|
|
buffer->decodedbuffer = BZ_Realloc(buffer->decodedbuffer, buffer->decodedbufferbytes);
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-09-23 19:35:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
qboolean QDECL S_LoadOVSound (sfx_t *s, qbyte *data, size_t datalen, int sndspeed, qboolean forcedecode)
|
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *buffer;
|
|
|
|
|
|
|
|
if (datalen < 4 || strncmp(data, "OggS", 4))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
buffer = Z_Malloc(sizeof(ovdecoderbuffer_t));
|
|
|
|
|
|
|
|
buffer->decodedbytestart = 0;
|
|
|
|
buffer->decodedbytecount = 0;
|
|
|
|
buffer->nopurge = forcedecode;
|
|
|
|
buffer->s = s;
|
|
|
|
s->decoder.buf = buffer;
|
|
|
|
s->loopstart = -1;
|
|
|
|
|
|
|
|
if (!OV_StartDecode(data, datalen, buffer))
|
|
|
|
{
|
|
|
|
if (buffer->decodedbuffer)
|
|
|
|
{
|
|
|
|
BZ_Free(buffer->decodedbuffer);
|
|
|
|
buffer->decodedbuffer = NULL;
|
|
|
|
}
|
|
|
|
buffer->decodedbufferbytes = 0;
|
|
|
|
buffer->decodedbytestart = 0;
|
|
|
|
buffer->decodedbytecount = 0;
|
|
|
|
Z_Free(s->decoder.buf);
|
|
|
|
s->decoder.buf = NULL;
|
|
|
|
s->loadstate = SLS_FAILED; //failed!
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
s->decoder.decodedata = OV_DecodeSome;
|
|
|
|
s->decoder.querydata = OV_Query;
|
|
|
|
s->decoder.purge = OV_CancelDecoder;
|
|
|
|
s->decoder.ended = OV_ClearDecoder;
|
|
|
|
|
|
|
|
s->decoder.decodedata(s, NULL, 0, 100);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
#endif
|
|
|
|
|