]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sound.h
Lots of str[n]cat, str[n]cpy, and [v]sprintf have been replaced by strlcat, strlcpy...
[xonotic/darkplaces.git] / sound.h
diff --git a/sound.h b/sound.h
index c1e24d387b5095d2a6063613412aa793a8f7846a..7fd841ded43dc871e549ac345a5fcbbf73ce1cd3 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
 
 This program 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.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
@@ -31,12 +31,6 @@ typedef struct
        int right;
 } portable_samplepair_t;
 
-typedef struct sfx_s
-{
-       char    name[MAX_QPATH];
-       cache_user_t    cache;
-} sfx_t;
-
 typedef struct
 {
        int     length;
@@ -44,9 +38,17 @@ typedef struct
        int     speed;
        int     width;
        int     stereo;
-       byte    data[1];                // variable sized
+       qbyte   data[1];                // variable sized
 } sfxcache_t;
 
+typedef struct sfx_s
+{
+       char    name[MAX_QPATH];
+       mempool_t       *mempool;
+       sfxcache_t      *sfxcache;
+       int silentlymissing; // true if missing and loaded with complain = false
+} sfx_t;
+
 typedef struct
 {
        qboolean                gamealive;
@@ -64,6 +66,7 @@ typedef struct
 typedef struct
 {
        sfx_t   *sfx;                   // sfx number
+       int             forceloop;              // force looping even if the sound is not looped
        int             leftvol;                // 0-255 volume
        int             rightvol;               // 0-255 volume
        int             end;                    // end time in global paintsamples
@@ -89,6 +92,8 @@ typedef struct
 void S_Init (void);
 void S_Startup (void);
 void S_Shutdown (void);
+void S_Open (void);
+void S_Close (void);
 void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,  float attenuation);
 void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
 void S_StopSound (int entnum, int entchannel);
@@ -97,7 +102,7 @@ void S_ClearBuffer (void);
 void S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
 void S_ExtraUpdate (void);
 
-sfx_t *S_PrecacheSound (char *sample);
+sfx_t *S_PrecacheSound (char *sample, int complain);
 void S_TouchSound (char *sample);
 void S_ClearPrecache (void);
 void S_BeginPrecaching (void);
@@ -109,7 +114,7 @@ void S_InitPaintChannels (void);
 channel_t *SND_PickChannel(int entnum, int entchannel);
 
 // spatializes a channel
-void SND_Spatialize(channel_t *ch);
+void SND_Spatialize(channel_t *ch, int isstatic);
 
 // initializes cycling through a DMA buffer and returns information on it
 qboolean SNDDMA_Init(void);
@@ -130,12 +135,12 @@ void SNDDMA_Shutdown(void);
 #define        MAX_DYNAMIC_CHANNELS    128
 
 
-extern channel_t   channels[MAX_CHANNELS];
+extern channel_t channels[MAX_CHANNELS];
 // 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds
 // MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc
 // MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds
 
-extern int                     total_channels;
+extern int total_channels;
 
 //
 // Fake dma is a synchronous faking of the DMA progress used for
@@ -143,9 +148,10 @@ extern     int                     total_channels;
 // number of times S_Update() is called per second.
 //
 
-extern qboolean                fakedma;
-extern int                     fakedma_updates;
-extern int             paintedtime;
+extern qboolean fakedma;
+extern int fakedma_updates;
+extern int paintedtime;
+extern int soundtime;
 extern vec3_t listener_origin;
 extern vec3_t listener_forward;
 extern vec3_t listener_right;
@@ -154,18 +160,20 @@ extern volatile dma_t *shm;
 extern volatile dma_t sn;
 extern vec_t sound_nominal_clip_dist;
 
-extern cvar_t loadas8bit;
-extern cvar_t bgmvolume;
-extern cvar_t volume;
+extern cvar_t loadas8bit;
+extern cvar_t bgmvolume;
+extern cvar_t volume;
+extern cvar_t snd_swapstereo;
 
+extern qboolean cdaudioinitialized;
 extern qboolean        snd_initialized;
 
-extern int             snd_blocked;
+extern int snd_blocked;
 
 void S_LocalSound (char *s);
-sfxcache_t *S_LoadSound (sfx_t *s);
+sfxcache_t *S_LoadSound (sfx_t *s, int complain);
 
-wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength);
+wavinfo_t GetWavinfo (char *name, qbyte *wav, int wavlength);
 
 void SND_InitScaletable (void);
 void SNDDMA_Submit(void);
@@ -173,4 +181,23 @@ void SNDDMA_Submit(void);
 void S_AmbientOff (void);
 void S_AmbientOn (void);
 
+void *S_LockBuffer(void);
+void S_UnlockBuffer(void);
+
+// add some data to the tail of the rawsamples queue
+void S_RawSamples_Enqueue(short *samples, unsigned int length);
+// read and remove some data from the head of the rawsamples queue
+void S_RawSamples_Dequeue(int *samples, unsigned int length);
+// empty the rawsamples queue
+void S_RawSamples_ClearQueue(void);
+// returns how much more data the queue wants, or 0 if it is already full enough
+int S_RawSamples_QueueWantsMore(void);
+
+// resamples one sound buffer into another, while changing the length
+void S_ResampleBuffer16Stereo(short *input, int inputlength, short *output, int outputlength);
+
+// returns the rate that the rawsamples system is running at
+int S_RawSamples_SampleRate(void);
+
 #endif
+