X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsound.c;h=8371b9b5cd879d02b56fabe8ab4487faa2da3fe3;hb=ae22060f6dbc84e9fe7f4ea6a8d2e29cc9c311dd;hp=e860ba5ad443acd63e2669618d3f7c5e04c0872d;hpb=f3f6052659f82f865215a70ce3c3e9e207bf0ea0;p=rocksndiamonds.git diff --git a/src/libgame/sound.c b/src/libgame/sound.c index e860ba5a..8371b9b5 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -116,6 +116,8 @@ static MusicInfo **Music_NoConf = NULL; static int num_music_noconf = 0; static int stereo_volume[SOUND_MAX_LEFT2RIGHT + 1]; +static char *currently_playing_music_filename = NULL; + /* ========================================================================= */ /* THE STUFF BELOW IS ONLY USED BY THE SOUND SERVER CHILD PROCESS */ @@ -223,6 +225,16 @@ static void Mixer_PlayMusicChannel() // (this may happen when switching on music while playing the game) Mix_VolumeMusic(mixer[audio.music_channel].volume); Mix_FadeInMusic(mixer[audio.music_channel].data_ptr, -1, 100); + +#if defined(PLATFORM_WIN32) + // playing MIDI music is broken since Windows Vista, as it sets the volume + // for MIDI music also for all other sounds and music, which cannot be set + // back to normal unless playing MIDI music again with that desired volume + // (more details: https://www.artsoft.org/forum/viewtopic.php?f=7&t=2253) + // => workaround: always play MIDI music with maximum volume + if (Mix_GetMusicType(NULL) == MUS_MID) + Mix_VolumeMusic(SOUND_MAX_VOLUME); +#endif } } @@ -242,6 +254,8 @@ static void Mixer_StopMusicChannel() Mixer_StopChannel(audio.music_channel); Mix_HaltMusic(); + + setString(¤tly_playing_music_filename, NULL); } static void Mixer_FadeChannel(int channel) @@ -259,6 +273,18 @@ static void Mixer_FadeMusicChannel() Mixer_FadeChannel(audio.music_channel); Mix_FadeOutMusic(SOUND_FADING_INTERVAL); + +#if defined(PLATFORM_WIN32) + // playing MIDI music is broken since Windows Vista, as it sets the volume + // for MIDI music also for all other sounds and music, which cannot be set + // back to normal unless playing MIDI music again with that desired volume + // (more details: https://www.artsoft.org/forum/viewtopic.php?f=7&t=2253) + // => workaround: never fade MIDI music to lower volume, but just stop it + if (Mix_GetMusicType(NULL) == MUS_MID) + Mixer_StopMusicChannel(); +#endif + + setString(¤tly_playing_music_filename, NULL); } static void Mixer_UnFadeChannel(int channel) @@ -322,6 +348,9 @@ static void Mixer_InsertSound(SoundControl snd_ctrl) mixer[audio.music_channel] = snd_ctrl; Mixer_PlayMusicChannel(); + setString(¤tly_playing_music_filename, + getBaseNamePtr(snd_info->source_filename)); + return; } @@ -696,6 +725,11 @@ static MusicInfo *getMusicInfoEntryFromMusicID(int pos) return mus_info[list_pos]; } +char *getCurrentlyPlayingMusicFilename() +{ + return currently_playing_music_filename; +} + int getSoundListPropertyMappingSize() { return sound_info->num_property_mapping_entries;