2012-04-09 19:12:12 +00:00
# include "quakedef.h"
# include <ppapi/c/ppb_core.h>
# include <ppapi/c/ppb_audio.h>
# include <ppapi/c/ppb_audio_config.h>
extern PPB_Core * ppb_core ;
extern PPB_Audio * audio_interface ;
extern PPB_AudioConfig * audioconfig_interface ;
extern PP_Instance pp_instance ;
2014-08-15 02:20:41 +00:00
extern int S_GetMixerTime ( soundcardinfo_t * sc ) ;
2012-04-09 19:12:12 +00:00
2017-02-22 00:16:43 +00:00
static void PPAPI_audio_callback ( void * sample_buffer , uint32_t len ,
# ifdef PPB_AUDIO_INTERFACE_1_1
PP_TimeDelta latency ,
# endif
void * user_data )
2012-04-09 19:12:12 +00:00
{
soundcardinfo_t * sc = user_data ;
unsigned int framesz ;
if ( sc )
{
2014-08-15 02:20:41 +00:00
int curtime = S_GetMixerTime ( sc ) ;
2012-04-09 19:12:12 +00:00
framesz = sc - > sn . numchannels * sc - > sn . samplebits / 8 ;
//might as well dump it directly...
sc - > sn . buffer = sample_buffer ;
sc - > sn . samples = len / ( sc - > sn . samplebits / 8 ) ;
S_PaintChannels ( sc , curtime + ( len / framesz ) ) ;
sc - > sn . samples = 0 ;
sc - > sn . buffer = NULL ;
sc - > snd_sent + = len ;
}
}
static void PPAPI_Shutdown ( soundcardinfo_t * sc )
{
audio_interface - > StopPlayback ( ( PP_Resource ) sc - > handle ) ;
ppb_core - > ReleaseResource ( ( PP_Resource ) sc - > handle ) ;
}
static unsigned int PPAPI_GetDMAPos ( soundcardinfo_t * sc )
{
sc - > sn . samplepos = sc - > snd_sent / ( sc - > sn . samplebits / 8 ) ;
return sc - > sn . samplepos ;
}
static void PPAPI_UnlockBuffer ( soundcardinfo_t * sc , void * buffer )
{
}
static void * PPAPI_LockBuffer ( soundcardinfo_t * sc , unsigned int * sampidx )
{
* sampidx = 0 ;
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
return sc - > sn . buffer ;
2012-04-09 19:12:12 +00:00
}
static void PPAPI_Submit ( soundcardinfo_t * sc , int start , int end )
{
}
int PPAPI_InitCard ( soundcardinfo_t * sc , int cardnum )
{
PP_Resource config ;
int framecount ;
/*I'm not aware of any limits on the number of 'devices' we can create, but virtual devices on the same physical device are utterly pointless, so don't load more than one*/
if ( cardnum ! = 0 )
return 2 ;
/*the docs say only two sample rates are allowed*/
if ( sc - > sn . speed < = 44100 )
sc - > sn . speed = 44100 ;
else
sc - > sn . speed = 48000 ;
/*we can't choose these two settings*/
sc - > sn . samplebits = 16 ;
sc - > sn . numchannels = 2 ;
2013-03-12 23:09:25 +00:00
# ifdef PPB_AUDIO_CONFIG_INTERFACE_1_1
framecount = audioconfig_interface - > RecommendSampleFrameCount ( pp_instance , sc - > sn . speed , 2048 ) ;
# else
2012-04-09 19:12:12 +00:00
framecount = audioconfig_interface - > RecommendSampleFrameCount ( sc - > sn . speed , 2048 ) ;
2013-03-12 23:09:25 +00:00
# endif
2012-04-09 19:12:12 +00:00
/*the callback paints directly into the caller's buffer, so we don't need a separate 'dma' buffer*/
sc - > selfpainting = true ;
sc - > sn . samples = 0 ; /*framecount*/
sc - > sn . buffer = NULL ;
sc - > snd_sent = 0 ;
sc - > sn . samplepos = 0 ;
sc - > Submit = PPAPI_Submit ;
sc - > GetDMAPos = PPAPI_GetDMAPos ;
sc - > Lock = PPAPI_LockBuffer ;
sc - > Unlock = PPAPI_UnlockBuffer ;
sc - > Shutdown = PPAPI_Shutdown ;
config = audioconfig_interface - > CreateStereo16Bit ( pp_instance , sc - > sn . speed , framecount ) ;
if ( config )
{
sc - > handle = ( void * ) audio_interface - > Create ( pp_instance , config , PPAPI_audio_callback , sc ) ;
ppb_core - > ReleaseResource ( config ) ;
if ( sc - > handle )
{
if ( audio_interface - > StartPlayback ( ( PP_Resource ) sc - > handle ) )
return 1 ;
}
}
return 0 ;
}
int ( * pPPAPI_InitCard ) ( soundcardinfo_t * sc , int cardnum ) = & PPAPI_InitCard ;