X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=snd_main.h;h=ec097d22d795e7bb92db06f41fd77dce70616804;hb=4ee3e3c6cf65e316a2caa9a1cd4a12297980c253;hp=2df365408e323dec050c279c7104eb309d1acea1;hpb=30334016020f54bb93999010bed118f5605b06bd;p=xonotic%2Fdarkplaces.git diff --git a/snd_main.h b/snd_main.h index 2df36540..ec097d22 100644 --- a/snd_main.h +++ b/snd_main.h @@ -24,14 +24,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sound.h" -typedef struct +typedef struct sfxbuffer_s { - size_t length; - size_t offset; - qbyte data[4]; // variable sized + unsigned int length; + unsigned int offset; + unsigned char data[4]; // variable sized } sfxbuffer_t; -typedef struct +typedef struct snd_format_s { unsigned int speed; unsigned int width; @@ -50,7 +50,7 @@ struct sfx_s { char name[MAX_QPATH]; sfx_t *next; - mempool_t *mempool; + size_t memsize; // total memory used (including sfx_t and fetcher data) int locks; // One lock is automatically granted while the sfx is // playing (and removed when stopped). Locks can also be // added by S_PrecacheSound and S_ServerSounds. @@ -59,30 +59,35 @@ struct sfx_s unsigned int flags; // cf SFXFLAG_* defines snd_format_t format; int loopstart; - size_t total_length; + unsigned int total_length; const snd_fetcher_t *fetcher; void *fetcher_data; // Per-sfx data for the sound fetching functions }; -typedef struct +typedef struct dma_s { snd_format_t format; + int sampleframes; // frames in buffer (frame = samples for all speakers) int samples; // mono samples in buffer int samplepos; // in mono samples unsigned char *buffer; int bufferlength; // used only by certain drivers } dma_t; -typedef struct +// maximum supported speakers constant +#define SND_LISTENERS 8 + +typedef struct channel_s { + int pad[8]; sfx_t *sfx; // sfx number + int pad2[8]; unsigned int flags; // cf CHANNELFLAG_* defines int master_vol; // 0-255 master volume - int leftvol; // 0-255 volume - int rightvol; // 0-255 volume - size_t end; // end time in global paintsamples - size_t lastptime; // last time this channel was painted - size_t pos; // sample position in sfx + short listener_volume[SND_LISTENERS]; // 0-255 volume per speaker + int end; // end time in global paintsamples + int lastptime; // last time this channel was painted + int pos; // sample position in sfx int entnum; // to allow overriding a specific sound int entchannel; vec3_t origin; // origin of sound effect @@ -91,11 +96,13 @@ typedef struct } channel_t; typedef const sfxbuffer_t* (*snd_fetcher_getsb_t) (channel_t* ch, unsigned int start, unsigned int nbsamples); -typedef void (*snd_fetcher_end_t) (channel_t* ch); +typedef void (*snd_fetcher_endsb_t) (channel_t* ch); +typedef void (*snd_fetcher_free_t) (sfx_t* sfx); struct snd_fetcher_s { snd_fetcher_getsb_t getsb; - snd_fetcher_end_t end; + snd_fetcher_endsb_t endsb; + snd_fetcher_free_t free; }; void S_PaintChannels(int endtime); @@ -112,7 +119,6 @@ void SNDDMA_Submit(void); void SNDDMA_Shutdown(void); qboolean S_LoadSound (sfx_t *s, qboolean complain); -void S_UnloadSound(sfx_t *s); void S_LockSfx (sfx_t *sfx); void S_UnlockSfx (sfx_t *sfx); @@ -120,10 +126,8 @@ void S_UnlockSfx (sfx_t *sfx); void *S_LockBuffer(void); void S_UnlockBuffer(void); -extern size_t ResampleSfx (const qbyte *in_data, size_t in_length, const snd_format_t* in_format, qbyte *out_data, const char* sfxname); +extern size_t ResampleSfx (const unsigned char *in_data, size_t in_length, const snd_format_t* in_format, unsigned char *out_data, const char* sfxname); -// ==================================================================== -// User-setable variables // ==================================================================== // 0 to NUM_AMBIENTS - 1 = water, etc @@ -145,5 +149,7 @@ extern cvar_t snd_streaming; extern int snd_blocked; +extern mempool_t *snd_mempool; + #endif