diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-01-12 12:08:26 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-01-12 12:08:26 +0000 |
| commit | 1c1677f02300e5ab10bca9c74ce7f49d4605b9d6 (patch) | |
| tree | 1601d291fd6c531d5b8dcb6f0ca95829c31b0c76 /src/engine/client/ec_snd.c | |
| parent | 24e17b41a8a5d600e0f116bc059ba121ac21bad5 (diff) | |
| download | zcatch-1c1677f02300e5ab10bca9c74ce7f49d4605b9d6.tar.gz zcatch-1c1677f02300e5ab10bca9c74ce7f49d4605b9d6.zip | |
merged 0.3.3 changes over to trunk
Diffstat (limited to 'src/engine/client/ec_snd.c')
| -rw-r--r-- | src/engine/client/ec_snd.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/engine/client/ec_snd.c b/src/engine/client/ec_snd.c index 152eac53..49f050c9 100644 --- a/src/engine/client/ec_snd.c +++ b/src/engine/client/ec_snd.c @@ -55,6 +55,7 @@ static int center_x = 0; static int center_y = 0; static int mixing_rate = 48000; +static volatile int sound_volume = 100; void snd_set_channel(int cid, float vol, float pan) { @@ -135,10 +136,13 @@ static void mix(short *final_out, unsigned frames) { int mix_buffer[MAX_FRAMES*2] = {0}; int i, s; + int master_vol; /* aquire lock while we are mixing */ lock_wait(sound_lock); + master_vol = sound_volume; + for(i = 0; i < NUM_VOICES; i++) { if(voices[i].snd) @@ -208,12 +212,12 @@ static void mix(short *final_out, unsigned frames) } } + + /* release the lock */ lock_release(sound_lock); { - int master_vol = config.snd_volume; - /* clamp accumulated values */ /* TODO: this seams slow */ for(i = 0; i < frames; i++) @@ -283,6 +287,25 @@ int snd_init() err = Pa_StartStream(stream); sound_enabled = 1; + snd_update(); /* update the volume */ + return 0; +} + +int snd_update() +{ + /* update volume */ + int wanted_volume = config.snd_volume; + + if(!gfx_window_active() && config.snd_nonactive_mute) + wanted_volume = 0; + + if(wanted_volume != sound_volume) + { + lock_wait(sound_lock); + sound_volume = wanted_volume; + lock_release(sound_lock); + } + return 0; } |