made soundchannels a persistent var

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2606 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-09-15 02:49:19 +00:00
parent 5811c51c1a
commit eb170f21d3
2 changed files with 25 additions and 8 deletions
+1 -3
View File
@@ -122,10 +122,8 @@ void writeinitcfg()
fprintf(f, "stencilbits %d\n", stencilbits);
fprintf(f, "fsaa %d\n", fsaa);
fprintf(f, "vsync %d\n", vsync);
extern int fullscreen, audio, soundchannels;
fprintf(f, "fullscreen %d\n", fullscreen > 0 ? 1 : 0);
extern int audio;
fprintf(f, "audio %d\n", audio > 0 ? 1 : 0);
fprintf(f, "soundchannels %d\n", soundchannels);
fclose(f);
}
+24 -5
View File
@@ -273,18 +273,29 @@ struct source
// AC sound scheduler, manages available sound sources
// under load it uses priority and distance information to reassign its resources
VARF(soundchannels, 4, 32, 1024, initwarning("sound configuration", INIT_RESET, CHANGE_SOUND));
extern int soundchannels;
struct sourcescheduler
{
vector<source *> sources;
sourcescheduler() {}
void init()
{
sources.setsize(0);
sources.reserve(soundchannels);
loopi(soundchannels)
int newchannels = soundchannels - sources.length();
if(newchannels < 0)
{
loopv(sources)
{
source *src = sources[i];
if(src->locked) continue;
sources.remove(i--);
delete src;
if(sources.length() <= soundchannels) break;
}
}
else loopi(newchannels)
{
source *src = new source();
if(src->valid) sources.add(src);
@@ -294,6 +305,7 @@ struct sourcescheduler
break;
}
}
}
void reset()
@@ -393,6 +405,12 @@ struct sourcescheduler
if(!src) return;
src->unlock();
if(sources.length() >= soundchannels)
{
sources.removeobj(src);
delete src;
}
}
void printstats()
@@ -406,6 +424,7 @@ struct sourcescheduler
// scheduler instance
sourcescheduler scheduler;
VARFP(soundchannels, 4, 32, 1024, scheduler.init());
// binding of sounds to the 3D world