X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsound.c;h=cb788e7e573769a7efeec3e8ff1fbeaec7692fc3;hp=4831248c86d2b9abc1ef56cf9ad0cd885ebc06c3;hb=8d71e6fb8309bd90ce5f2900d84c686b17950492;hpb=2176d1de29652bc9e8db1baa283fdc1c4e99e674 diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 4831248c..cb788e7e 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 */ @@ -219,10 +221,10 @@ static void Mixer_PlayMusicChannel() if (mixer[audio.music_channel].type != MUS_TYPE_WAV) { - /* Mix_VolumeMusic() must be called _after_ Mix_PlayMusic() -- - this looks like a bug in the SDL_mixer library */ - Mix_PlayMusic(mixer[audio.music_channel].data_ptr, -1); + // use short fade-in to prevent "plop" sound for certain music files + // (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); } } @@ -242,6 +244,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 +263,8 @@ static void Mixer_FadeMusicChannel() Mixer_FadeChannel(audio.music_channel); Mix_FadeOutMusic(SOUND_FADING_INTERVAL); + + setString(¤tly_playing_music_filename, NULL); } static void Mixer_UnFadeChannel(int channel) @@ -322,6 +328,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 +705,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;