Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6824/src Modified Files: sound.c winsndlib.c Log Message: Fixed changing volume in-game with SDL. Index: winsndlib.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/winsndlib.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- winsndlib.c 21 Apr 2006 12:00:07 -0000 1.3 +++ winsndlib.c 29 May 2006 00:18:09 -0000 1.4 @@ -52,8 +52,8 @@ /* Sound cache size */ #define MAXBYTES (256*1024*10) -int caps_vol = 0; /* can control volume */ -int caps_lr = 0; /* has separate volume control for each channel */ +static int caps_vol = 0; /* can control volume */ +static int caps_lr = 0; /* has separate volume control for each channel */ /* Macro to create DWORD from HIWORD and LOWORD */ #define MAKEDWORD(a, b) ((DWORD) (((WORD) (a)) | ((DWORD) ((WORD) (b))) << 16)) @@ -315,7 +315,6 @@ static PCMWAVEFORMAT lastfmt; struct sound *snd; DWORD err; - WAVEOUTCAPS caps; #ifdef DEBUG LineToConsole ("Request to play sound %s\n", name); @@ -361,24 +360,7 @@ waveOutPrepareHeader (hw, &snd->hdr, sizeof (WAVEHDR)); waveOutWrite (hw, &snd->hdr, sizeof (WAVEHDR)); - /* Now let's see whether our device supports volume control */ - waveOutGetDevCaps (WAVE_MAPPER, &caps, sizeof (WAVEOUTCAPS)); - if (caps.dwSupport & WAVECAPS_VOLUME) - caps_vol = 1; - if (caps.dwSupport & WAVECAPS_LRVOLUME) - caps_lr = 1; - - /* Now let's see whether volume is balanced or not */ - if (caps_lr) - { - DWORD curvol; - - waveOutGetVolume (hw, &curvol); - - if (LOWORD(curvol) != HIWORD(curvol)) - waveOutSetVolume (hw, MAKEDWORD(LOWORD(curvol), LOWORD(curvol))); - } - + CheckVolumeSettings(); return 0; } return -1; @@ -449,4 +431,28 @@ waveOutSetVolume (hw, MAKEDWORD(HIWORD(curvol), LOWORD(curvol) - 0x1111)); break; } +} + +void +CheckVolumeSettings () +{ + WAVEOUTCAPS caps; + + /* Let's see whether our device supports volume control */ + waveOutGetDevCaps (WAVE_MAPPER, &caps, sizeof (WAVEOUTCAPS)); + if (caps.dwSupport & WAVECAPS_VOLUME) + caps_vol = 1; + if (caps.dwSupport & WAVECAPS_LRVOLUME) + caps_lr = 1; + + /* Now let's see whether volume is balanced or not */ + if (caps_lr) + { + DWORD curvol; + waveOutGetVolume (hw, &curvol); + + if (LOWORD(curvol) != HIWORD(curvol)) + waveOutSetVolume (hw, MAKEDWORD(LOWORD(curvol), LOWORD(curvol))); + } + return; } \ No newline at end of file Index: sound.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- sound.c 24 May 2006 01:14:39 -0000 1.12 +++ sound.c 29 May 2006 00:18:09 -0000 1.13 @@ -186,6 +186,8 @@ LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError()); } sound_toggle = 1; + /* See if volume is adjustable */ + CheckVolumeSettings (); /* Default of 8 channels not enough */ Mix_AllocateChannels(16); }