]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_dma.c
Added sound support to the NetBSD port. Most of the code comes from the original...
[xonotic/darkplaces.git] / snd_dma.c
index 1523b46f76722e3c00e1e29ada252391add9dfd6..5fa7234f0d5bb7d5194b7f79b735d8eb09daf629 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -25,6 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "winquake.h"
 #endif
 
+#include "ogg.h"
+
+
 void S_Play(void);
 void S_PlayVol(void);
 void S_Play2(void);
@@ -42,7 +45,6 @@ int total_channels;
 
 int snd_blocked = 0;
 static qboolean snd_ambient = 1;
-//qboolean snd_initialized = false;
 cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0"};
 
 // pointer should go away
@@ -258,6 +260,8 @@ void S_Init(void)
 
        total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS;   // no statics
        memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
+
+       OGG_OpenLibrary ();
 }
 
 
@@ -470,7 +474,7 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
        int             ch_idx;
        int             skip;
 
-       if (!sound_started || !sfx || nosound.integer)
+       if (!sound_started || !sfx || !sfx->sfxcache || nosound.integer)
                return;
 
        vol = fvol*255;
@@ -489,8 +493,9 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
        target_chan->entchannel = entchannel;
        SND_Spatialize(target_chan, false);
 
-       if (!target_chan->leftvol && !target_chan->rightvol)
-               return;         // not audible at all
+       // LordHavoc: spawn the sound anyway because the player might teleport to it
+       //if (!target_chan->leftvol && !target_chan->rightvol)
+       //      return;         // not audible at all
 
 // new channel
        sc = S_LoadSound (sfx, true);
@@ -578,7 +583,7 @@ void S_ClearBuffer(void)
 
                reps = 0;
 
-               while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pData, &dwSize, NULL, NULL, 0)) != DS_OK)
+               while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, (LPVOID*)&pData, &dwSize, NULL, NULL, 0)) != DS_OK)
                {
                        if (hresult != DSERR_BUFFERLOST)
                        {
@@ -812,12 +817,8 @@ void GetSoundtime(void)
 
 // it is possible to miscount buffers if it has wrapped twice between
 // calls to S_Update.  Oh well.
-#ifdef __sun__
-       soundtime = SNDDMA_GetSamples();
-#else
        samplepos = SNDDMA_GetDMAPos();
 
-
        if (samplepos < oldsamplepos)
        {
                buffers++;                                      // buffer wrapped
@@ -832,7 +833,6 @@ void GetSoundtime(void)
        oldsamplepos = samplepos;
 
        soundtime = buffers*fullsamples + samplepos/shm->channels;
-#endif
 }
 
 void IN_Accumulate (void);