]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
OGG_FreeSfx and WAV_FreeSfx no longer reference sfx_t
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Aug 2007 13:26:58 +0000 (13:26 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Aug 2007 13:26:58 +0000 (13:26 +0000)
OGG_FetchEnd no longer uses a pointer pointer

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7550 d7cf8633-e32d-0410-b094-e92efae38249

snd_main.c
snd_main.h
snd_ogg.c
snd_wav.c

index f5991953792951d75922b3c45ad7d2b1d98d9400..ce790b3441afc68e05822e6968cbc605623ca78f 100644 (file)
@@ -874,7 +874,7 @@ void S_FreeSfx (sfx_t *sfx, qboolean force)
 
        // Free it
        if (sfx->fetcher != NULL && sfx->fetcher->free != NULL)
 
        // Free it
        if (sfx->fetcher != NULL && sfx->fetcher->free != NULL)
-               sfx->fetcher->free (sfx);
+               sfx->fetcher->free (sfx->fetcher_data);
        Mem_Free (sfx);
 }
 
        Mem_Free (sfx);
 }
 
@@ -1248,12 +1248,13 @@ void S_StopChannel (unsigned int channel_ind)
                {
                        snd_fetcher_endsb_t fetcher_endsb = sfx->fetcher->endsb;
                        if (fetcher_endsb != NULL)
                {
                        snd_fetcher_endsb_t fetcher_endsb = sfx->fetcher->endsb;
                        if (fetcher_endsb != NULL)
-                               fetcher_endsb (&ch->fetcher_data);
+                               fetcher_endsb (ch->fetcher_data);
                }
 
                // Remove the lock it holds
                S_UnlockSfx (sfx);
 
                }
 
                // Remove the lock it holds
                S_UnlockSfx (sfx);
 
+               ch->fetcher_data = NULL;
                ch->sfx = NULL;
        }
 }
                ch->sfx = NULL;
        }
 }
index eb4f4fb19c27407f03291392f94959d625047098..3b53b62a90ffe15036c37b3bc93b41746bb3e5db 100644 (file)
@@ -97,8 +97,8 @@ typedef struct channel_s
 // Sound fetching functions
 // "start" is both an input and output parameter: it returns the actual start time of the sound buffer
 typedef const snd_buffer_t* (*snd_fetcher_getsb_t) (void *sfxfetcher, void **chfetcherpointer, unsigned int *start, unsigned int nbsampleframes);
 // Sound fetching functions
 // "start" is both an input and output parameter: it returns the actual start time of the sound buffer
 typedef const snd_buffer_t* (*snd_fetcher_getsb_t) (void *sfxfetcher, void **chfetcherpointer, unsigned int *start, unsigned int nbsampleframes);
-typedef void (*snd_fetcher_endsb_t) (void **chfetcherpointer);
-typedef void (*snd_fetcher_free_t) (sfx_t* sfx);
+typedef void (*snd_fetcher_endsb_t) (void *chfetcherdata);
+typedef void (*snd_fetcher_free_t) (void *sfxfetcherdata);
 typedef const snd_format_t* (*snd_fetcher_getfmt_t) (sfx_t* sfx);
 struct snd_fetcher_s
 {
 typedef const snd_format_t* (*snd_fetcher_getfmt_t) (sfx_t* sfx);
 struct snd_fetcher_s
 {
index b8ab271fa9cd78b4118773632c43f2ef0e5ddafe..28ccab1b9b38048ee194921a2ecf426fbcf33849 100644 (file)
--- a/snd_ogg.c
+++ b/snd_ogg.c
@@ -567,9 +567,9 @@ static const snd_buffer_t* OGG_FetchSound (void *sfxfetcher, void **chfetcherpoi
 OGG_FetchEnd
 ====================
 */
 OGG_FetchEnd
 ====================
 */
-static void OGG_FetchEnd (void **chfetcherpointer)
+static void OGG_FetchEnd (void *chfetcherdata)
 {
 {
-       ogg_stream_perchannel_t* per_ch = (ogg_stream_perchannel_t *)*chfetcherpointer;
+       ogg_stream_perchannel_t* per_ch = (ogg_stream_perchannel_t *)chfetcherdata;
 
        if (per_ch != NULL)
        {
 
        if (per_ch != NULL)
        {
@@ -578,7 +578,6 @@ static void OGG_FetchEnd (void **chfetcherpointer)
 
                Mem_Free (per_ch);
        }
 
                Mem_Free (per_ch);
        }
-       *chfetcherpointer = NULL;
 }
 
 
 }
 
 
@@ -587,20 +586,15 @@ static void OGG_FetchEnd (void **chfetcherpointer)
 OGG_FreeSfx
 ====================
 */
 OGG_FreeSfx
 ====================
 */
-static void OGG_FreeSfx (sfx_t* sfx)
+static void OGG_FreeSfx (void *sfxfetcherdata)
 {
 {
-       ogg_stream_persfx_t* per_sfx = (ogg_stream_persfx_t *)sfx->fetcher_data;
+       ogg_stream_persfx_t* per_sfx = (ogg_stream_persfx_t *)sfxfetcherdata;
 
        // Free the Ogg Vorbis file
        Mem_Free(per_sfx->file);
 
        // Free the Ogg Vorbis file
        Mem_Free(per_sfx->file);
-       sfx->memsize -= per_sfx->filesize;
 
        // Free the stream structure
        Mem_Free(per_sfx);
 
        // Free the stream structure
        Mem_Free(per_sfx);
-       sfx->memsize -= sizeof (*per_sfx);
-
-       sfx->fetcher_data = NULL;
-       sfx->fetcher = NULL;
 }
 
 
 }
 
 
index 8495518e3cdce82898e20535168a360b6193b044..7ce6b2744d3b164ecfd0e0a7a038a1d17f5bd32c 100644 (file)
--- a/snd_wav.c
+++ b/snd_wav.c
@@ -234,16 +234,11 @@ static const snd_buffer_t* WAV_FetchSound (void *sfxfetcher, void **chfetcherpoi
 WAV_FreeSfx
 ====================
 */
 WAV_FreeSfx
 ====================
 */
-static void WAV_FreeSfx (sfx_t* sfx)
+static void WAV_FreeSfx (void *sfxfetcherdata)
 {
 {
-       snd_buffer_t* sb = (snd_buffer_t *)sfx->fetcher_data;
-
+       snd_buffer_t* sb = (snd_buffer_t *)sfxfetcherdata;
        // Free the sound buffer
        // Free the sound buffer
-       sfx->memsize -= (sb->maxframes * sb->format.channels * sb->format.width) + sizeof (*sb) - sizeof (sb->samples);
        Mem_Free(sb);
        Mem_Free(sb);
-
-       sfx->fetcher_data = NULL;
-       sfx->fetcher = NULL;
 }
 
 /*
 }
 
 /*