mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 12:03:07 +01:00
make disable volume on focus lost not reset title music
This commit is contained in:
@@ -105,7 +105,6 @@ void start_title_music();
|
||||
void stop_ride_music();
|
||||
void stop_crowd_sound();
|
||||
void stop_title_music();
|
||||
void stop_raid_sound();
|
||||
void audio_init1();
|
||||
void audio_init2(int device);
|
||||
void audio_close();
|
||||
|
||||
@@ -448,6 +448,7 @@ void Channel::SetGroup(int group)
|
||||
Mixer::Mixer()
|
||||
{
|
||||
effectbuffer = 0;
|
||||
volume = 1;
|
||||
for (int i = 0; i < countof(css1sources); i++) {
|
||||
css1sources[i] = 0;
|
||||
}
|
||||
@@ -565,6 +566,11 @@ bool Mixer::LoadMusic(int pathid)
|
||||
}
|
||||
}
|
||||
|
||||
void Mixer::SetVolume(float volume)
|
||||
{
|
||||
Mixer::volume = volume;
|
||||
}
|
||||
|
||||
void SDLCALL Mixer::Callback(void* arg, uint8* stream, int length)
|
||||
{
|
||||
Mixer* mixer = (Mixer*)arg;
|
||||
@@ -671,7 +677,8 @@ void Mixer::MixChannel(Channel& channel, uint8* data, int length)
|
||||
mixlength = length - loaded;
|
||||
}
|
||||
|
||||
float volumeadjust = (gConfigSound.master_volume / 100.0f);
|
||||
float volumeadjust = volume;
|
||||
volumeadjust *= (gConfigSound.master_volume / 100.0f);
|
||||
if (channel.group == MIXER_GROUP_MUSIC) {
|
||||
volumeadjust *= (gConfigSound.music_volume / 100.0f);
|
||||
}
|
||||
@@ -897,3 +904,8 @@ void* Mixer_Play_Music(int pathid, int loop, int streaming)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Mixer_SetVolume(float volume)
|
||||
{
|
||||
gMixer.SetVolume(volume);
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ public:
|
||||
Channel* Play(Source& source, int loop, bool deleteondone, bool deletesourceondone);
|
||||
void Stop(Channel& channel);
|
||||
bool LoadMusic(int pathid);
|
||||
void SetVolume(float volume);
|
||||
|
||||
Source* css1sources[SOUND_MAXID];
|
||||
Source* musicsources[PATH_ID_END];
|
||||
@@ -185,6 +186,7 @@ private:
|
||||
uint8* effectbuffer;
|
||||
std::list<Channel*> channels;
|
||||
Source_Null source_null;
|
||||
float volume;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
@@ -209,6 +211,7 @@ unsigned long Mixer_Channel_GetOffset(void* channel);
|
||||
int Mixer_Channel_SetOffset(void* channel, unsigned long offset);
|
||||
void Mixer_Channel_SetGroup(void* channel, int group);
|
||||
void* Mixer_Play_Music(int pathid, int loop, int streaming);
|
||||
void Mixer_SetVolume(float volume);
|
||||
|
||||
static int DStoMixerVolume(int volume) { return (int)(SDL_MIX_MAXVOLUME * (SDL_pow(10, (float)volume / 2000))); };
|
||||
static float DStoMixerPan(int pan) { return (((float)pan + -DSBPAN_LEFT) / DSBPAN_RIGHT) / 2; };
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "../addresses.h"
|
||||
#include "../audio/audio.h"
|
||||
#include "../audio/mixer.h"
|
||||
#include "../config.h"
|
||||
#include "../cursors.h"
|
||||
#include "../drawing/drawing.h"
|
||||
@@ -406,10 +407,10 @@ void platform_process_messages()
|
||||
platform_resize(e.window.data1, e.window.data2);
|
||||
if (gConfigSound.audio_focus && gConfigSound.sound) {
|
||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
|
||||
unpause_sounds();
|
||||
Mixer_SetVolume(1);
|
||||
}
|
||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
|
||||
pause_sounds();
|
||||
Mixer_SetVolume(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user