Alex.
Retired
- Joined
 - Aug 24, 2005
 
- Messages
 - 4,616
 
I have the following function being called at every game loop, to set the sound volume of the SDL mixer music:
	
	
	
		
The volume control works flawlessly, I even have a printout of it on the screen, and it ranges from 0 to 128. However, after 1 or 2 minutes of game play, the music volume goes all the way to the top, by itself - the variable holding the volume didn't change, as it still displays the same number on the screen that it displayed before going up. When I press the volup or voldown buttons, the music volume changes back to its respective size.
I'm really confused, as this happens even if I don't press any keys at all
- Alex
				
			
		Code:
	
	#define VOLUME_STEP 2
void adjustVolume(void)
{
	int volume = status.volume;
	SDL_JoystickUpdate();
	buttons.volup = SDL_JoystickGetButton(joystick, GP2X_BUTTON_VOLUP);
	buttons.voldown = SDL_JoystickGetButton(joystick, GP2X_BUTTON_VOLDOWN);
	if(buttons.volup) {
		status.volume += VOLUME_STEP;
		if(status.volume > MIX_MAX_VOLUME) status.volume = MIX_MAX_VOLUME;
	}
	if(buttons.voldown) {
		status.volume -= VOLUME_STEP;
		if(status.volume < 0) status.volume = 0;
	}
	if(status.volume != volume) Mix_VolumeMusic(status.volume);
}
	The volume control works flawlessly, I even have a printout of it on the screen, and it ranges from 0 to 128. However, after 1 or 2 minutes of game play, the music volume goes all the way to the top, by itself - the variable holding the volume didn't change, as it still displays the same number on the screen that it displayed before going up. When I press the volup or voldown buttons, the music volume changes back to its respective size.
I'm really confused, as this happens even if I don't press any keys at all
- Alex
	