X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=snd_main.c;h=e435485e48e6de75d263bc2d49de8331eb60774e;hb=cb8da6be6eae56b5f9818f1eff49573c7a476fcd;hp=614b16879dcb0dffc8578f0f4a09b19a4eec7dd8;hpb=9fde8925b467809f91376ba9e6008f39dbe0d2d6;p=xonotic%2Fdarkplaces.git diff --git a/snd_main.c b/snd_main.c index 614b1687..e435485e 100644 --- a/snd_main.c +++ b/snd_main.c @@ -23,10 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "snd_main.h" #include "snd_ogg.h" -#include "snd_modplug.h" #include "csprogs.h" #include "cl_collision.h" +#ifdef CONFIG_CD #include "cdaudio.h" +#endif #define SND_MIN_SPEED 8000 @@ -50,24 +51,24 @@ static const speakerlayout_t snd_speakerlayouts[] = { "surround71", 8, { - {0, 45, 0.2, 0.2, 0.5}, // front left - {1, 315, 0.2, 0.2, 0.5}, // front right - {2, 135, 0.2, 0.2, 0.5}, // rear left - {3, 225, 0.2, 0.2, 0.5}, // rear right - {4, 0, 0.2, 0.2, 0.5}, // front center + {0, 45, 0.2f, 0.2f, 0.5f}, // front left + {1, 315, 0.2f, 0.2f, 0.5f}, // front right + {2, 135, 0.2f, 0.2f, 0.5f}, // rear left + {3, 225, 0.2f, 0.2f, 0.5f}, // rear right + {4, 0, 0.2f, 0.2f, 0.5f}, // front center {5, 0, 0, 0, 0}, // lfe (we don't have any good lfe sound sources and it would take some filtering work to generate them (and they'd probably still be wrong), so... no lfe) - {6, 90, 0.2, 0.2, 0.5}, // side left - {7, 180, 0.2, 0.2, 0.5}, // side right + {6, 90, 0.2f, 0.2f, 0.5f}, // side left + {7, 180, 0.2f, 0.2f, 0.5f}, // side right } }, { "surround51", 6, { - {0, 45, 0.2, 0.2, 0.5}, // front left - {1, 315, 0.2, 0.2, 0.5}, // front right - {2, 135, 0.2, 0.2, 0.5}, // rear left - {3, 225, 0.2, 0.2, 0.5}, // rear right - {4, 0, 0.2, 0.2, 0.5}, // front center + {0, 45, 0.2f, 0.2f, 0.5f}, // front left + {1, 315, 0.2f, 0.2f, 0.5f}, // front right + {2, 135, 0.2f, 0.2f, 0.5f}, // rear left + {3, 225, 0.2f, 0.2f, 0.5f}, // rear right + {4, 0, 0.2f, 0.2f, 0.5f}, // front center {5, 0, 0, 0, 0}, // lfe (we don't have any good lfe sound sources and it would take some filtering work to generate them (and they'd probably still be wrong), so... no lfe) {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, @@ -78,10 +79,10 @@ static const speakerlayout_t snd_speakerlayouts[] = // channel of its own "surround40", 4, { - {0, 45, 0.3, 0.3, 0.8}, // front left - {1, 315, 0.3, 0.3, 0.8}, // front right - {2, 135, 0.3, 0.3, 0.8}, // rear left - {3, 225, 0.3, 0.3, 0.8}, // rear right + {0, 45, 0.3f, 0.3f, 0.8f}, // front left + {1, 315, 0.3f, 0.3f, 0.8f}, // front right + {2, 135, 0.3f, 0.3f, 0.8f}, // rear left + {3, 225, 0.3f, 0.3f, 0.8f}, // rear right {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, @@ -93,8 +94,8 @@ static const speakerlayout_t snd_speakerlayouts[] = // channel of its own "stereo", 2, { - {0, 90, 0.5, 0.5, 1}, // side left - {1, 270, 0.5, 0.5, 1}, // side right + {0, 90, 0.5f, 0.5f, 1}, // side left + {1, 270, 0.5f, 0.5f, 1}, // side right {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, @@ -326,7 +327,7 @@ static void S_SoundList_f (void) { unsigned int size; - size = sfx->memsize; + size = (unsigned int)sfx->memsize; Con_Printf ("%c%c%c(%5iHz %2db %6s) %8i : %s\n", (sfx->loopstart < sfx->total_length) ? 'L' : ' ', (sfx->flags & SFXFLAG_STREAMED) ? 'S' : ' ', @@ -915,7 +916,6 @@ void S_Init(void) memset(channels, 0, MAX_CHANNELS * sizeof(channel_t)); OGG_OpenLibrary (); - ModPlug_OpenLibrary (); } @@ -929,7 +929,6 @@ Shutdown and free all resources void S_Terminate (void) { S_Shutdown (); - ModPlug_CloseLibrary (); OGG_CloseLibrary (); // Free all SFXs @@ -1494,7 +1493,7 @@ static void SND_Spatialize_WithSfx(channel_t *ch, qboolean isstatic, sfx_t *sfx) if (snd_spatialization_occlusion.integer) { if(snd_spatialization_occlusion.integer & 1) - if(listener_pvs) + if(listener_pvs && cl.worldmodel) { int cluster = cl.worldmodel->brush.PointInLeaf(cl.worldmodel, ch->origin)->clusterindex; if(cluster >= 0 && cluster < 8 * listener_pvsbytes && !CHECKPVSBIT(listener_pvs, cluster)) @@ -1677,7 +1676,7 @@ static void S_PlaySfxOnChannel (sfx_t *sfx, channel_t *target_chan, unsigned int int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed) { channel_t *target_chan, *check, *ch; - int ch_idx, startpos; + int ch_idx, startpos, i; if (snd_renderbuffer == NULL || sfx == NULL || nosound.integer) return -1; @@ -1693,6 +1692,9 @@ int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, ve { S_SetChannelVolume(ch_idx, fvol); S_SetChannelSpeed(ch_idx, fspeed); + for(i = 1; i > 0 && (i <= flags || i <= (int) channels[ch_idx].flags); i <<= 1) + if((flags ^ channels[ch_idx].flags) & i) + S_SetChannelFlag(ch_idx, i, (flags & i) != 0); ch->distfade = attenuation / snd_soundradius.value; SND_Spatialize(ch, false); return ch_idx; @@ -1765,17 +1767,17 @@ void S_StopChannel (unsigned int channel_ind, qboolean lockmutex, qboolean frees ch = &channels[channel_ind]; sfx = ch->sfx; - if (ch->sfx != NULL) + if (sfx != NULL) { if (sfx->fetcher != NULL && sfx->fetcher->stopchannel != NULL) sfx->fetcher->stopchannel(ch); ch->fetcher_data = NULL; ch->sfx = NULL; + if (freesfx) + S_FreeSfx(sfx, true); } if (lockmutex && !simsound) SndSys_UnlockRenderBuffer(); - if (freesfx) - S_FreeSfx(sfx, true); } @@ -1818,8 +1820,10 @@ void S_StopAllSounds (void) if (snd_renderbuffer == NULL) return; +#ifdef CONFIG_CD // stop CD audio because it may be using a faketrack CDAudio_Stop(); +#endif if (simsound || SndSys_LockRenderBuffer ()) {