]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_main.h
- SFXs no longer allocate mempools, they use the sound mempool directly.
[xonotic/darkplaces.git] / snd_main.h
index c6b80c22d9c19be3d68e942bc043811d0267e03d..0eea61ada550ff99a6d3e04be5906f79965d2402 100644 (file)
@@ -26,8 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 typedef struct
 {
-       int             length;
-       int             offset;
+       unsigned int    length;
+       unsigned int    offset;
        qbyte   data[4];        // variable sized
 } sfxbuffer_t;
 
@@ -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,7 +59,7 @@ struct sfx_s
        unsigned int            flags;                  // cf SFXFLAG_* defines
        snd_format_t            format;
        int                                     loopstart;
-       int                                     total_length;
+       unsigned int            total_length;
        const snd_fetcher_t     *fetcher;
        void                            *fetcher_data;  // Per-sfx data for the sound fetching functions
 };
@@ -91,11 +91,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 +114,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);
@@ -122,8 +123,6 @@ 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);
 
-// ====================================================================
-// User-setable variables
 // ====================================================================
 
 // 0 to NUM_AMBIENTS - 1 = water, etc
@@ -145,5 +144,7 @@ extern cvar_t snd_streaming;
 
 extern int snd_blocked;
 
+extern mempool_t *snd_mempool;
+
 
 #endif