mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
survive across gamedir changes
This commit is contained in:
parent
447a3e8254
commit
323052bd2b
4 changed files with 51 additions and 11 deletions
|
@ -298,8 +298,11 @@ struct channel_s *SND_AllocChannel (void);
|
||||||
void SND_ChannelStop (channel_t *chan);
|
void SND_ChannelStop (channel_t *chan);
|
||||||
|
|
||||||
/** Scan channels looking for stopped channels.
|
/** Scan channels looking for stopped channels.
|
||||||
|
\param wait if true, wait for the channels to be done. if false, force the
|
||||||
|
channels to be done. true is for threaded, false for
|
||||||
|
non-threaded.
|
||||||
*/
|
*/
|
||||||
void SND_ScanChannels (void);
|
void SND_ScanChannels (int wait);
|
||||||
|
|
||||||
/** Disable ambient sounds.
|
/** Disable ambient sounds.
|
||||||
\todo not used, remove?
|
\todo not used, remove?
|
||||||
|
|
|
@ -37,6 +37,9 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "QF/bspfile.h"
|
#include "QF/bspfile.h"
|
||||||
|
@ -92,7 +95,7 @@ SND_AllocChannel (void)
|
||||||
while (*free) {
|
while (*free) {
|
||||||
if (!(*free)->sfx) // free channel
|
if (!(*free)->sfx) // free channel
|
||||||
break;
|
break;
|
||||||
if ((*free)->done) // mixer is finished with this channel
|
if ((*free)->done) // mixer is finished with this channel
|
||||||
break;
|
break;
|
||||||
if (!(*free)->stop)
|
if (!(*free)->stop)
|
||||||
Sys_Error ("SND_AllocChannel: bogus channel free list");
|
Sys_Error ("SND_AllocChannel: bogus channel free list");
|
||||||
|
@ -135,20 +138,46 @@ SND_ChannelStop (channel_t *chan)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SND_ScanChannels (void)
|
SND_ScanChannels (int wait)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
channel_t *ch;
|
channel_t *ch;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (i = 0; i < MAX_CHANNELS; i++) {
|
if (wait) {
|
||||||
ch = &snd_channels[i];
|
Sys_DPrintf ("scanning channels...\n");
|
||||||
if (ch->sfx && ch->stop && !ch->done) {
|
do {
|
||||||
ch->done = 1;
|
count = 0;
|
||||||
count++;
|
for (i = 0; i < MAX_CHANNELS; i++) {
|
||||||
|
ch = &snd_channels[i];
|
||||||
|
if (!ch->sfx || ch->done)
|
||||||
|
continue;
|
||||||
|
ch->stop = 1;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
Sys_DPrintf ("count = %d\n", count);
|
||||||
|
#ifdef HAVE_USLEEP
|
||||||
|
usleep (1000);
|
||||||
|
#endif
|
||||||
|
} while (count);
|
||||||
|
Sys_DPrintf ("scanning done.\n");
|
||||||
|
for (i = 0; i < MAX_CHANNELS; i++) {
|
||||||
|
ch = &snd_channels[i];
|
||||||
|
if (!ch->sfx)
|
||||||
|
continue;
|
||||||
|
ch->sfx->release (ch->sfx);
|
||||||
|
ch->sfx = 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < MAX_CHANNELS; i++) {
|
||||||
|
ch = &snd_channels[i];
|
||||||
|
if (ch->sfx && ch->stop && !ch->done) {
|
||||||
|
ch->done = 1;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//printf ("count: %d\n", count);
|
||||||
}
|
}
|
||||||
//printf ("count: %d\n", count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -204,6 +204,7 @@ static void
|
||||||
s_stop_all_sounds (void)
|
s_stop_all_sounds (void)
|
||||||
{
|
{
|
||||||
SND_StopAllSounds ();
|
SND_StopAllSounds ();
|
||||||
|
SND_ScanChannels (0);
|
||||||
s_clear_buffer ();
|
s_clear_buffer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +280,7 @@ s_update (const vec3_t origin, const vec3_t forward, const vec3_t right,
|
||||||
|
|
||||||
// mix some sound
|
// mix some sound
|
||||||
s_update_ ();
|
s_update_ ();
|
||||||
SND_ScanChannels ();
|
SND_ScanChannels (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -56,6 +56,13 @@ static jack_port_t *jack_out[2];
|
||||||
static dma_t _snd_shm;
|
static dma_t _snd_shm;
|
||||||
static float *output[2];
|
static float *output[2];
|
||||||
|
|
||||||
|
static void
|
||||||
|
s_stop_all_sounds (void)
|
||||||
|
{
|
||||||
|
SND_StopAllSounds ();
|
||||||
|
SND_ScanChannels (1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
s_extra_update (void)
|
s_extra_update (void)
|
||||||
{
|
{
|
||||||
|
@ -209,7 +216,7 @@ static snd_render_funcs_t plugin_info_render_funcs = {
|
||||||
SND_StopSound,
|
SND_StopSound,
|
||||||
SND_PrecacheSound,
|
SND_PrecacheSound,
|
||||||
SND_SetListener,
|
SND_SetListener,
|
||||||
SND_StopAllSounds,
|
s_stop_all_sounds,
|
||||||
s_extra_update,
|
s_extra_update,
|
||||||
SND_LocalSound,
|
SND_LocalSound,
|
||||||
s_block_sound,
|
s_block_sound,
|
||||||
|
|
Loading…
Reference in a new issue