projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
moved drawing cave tile for BD engine to separate function
[rocksndiamonds.git]
/
src
/
libgame
/
sound.c
diff --git
a/src/libgame/sound.c
b/src/libgame/sound.c
index 2b1ccd873560fe89e5bdee24dc68601eefd25d5f..5f497c386c56c6dda9088ecfd87940cd3bcfd36c 100644
(file)
--- a/
src/libgame/sound.c
+++ b/
src/libgame/sound.c
@@
-141,6
+141,15
@@
static MusicInfo *getMusicInfoEntryFromMusicID(int);
// mixer functions
// ----------------------------------------------------------------------------
// mixer functions
// ----------------------------------------------------------------------------
+static void Mixer_ChannelFinished(int channel)
+{
+ if (!mixer[channel].active)
+ return;
+
+ mixer[channel].active = FALSE;
+ mixer_active_channels--;
+}
+
void Mixer_InitChannels(void)
{
int i;
void Mixer_InitChannels(void)
{
int i;
@@
-148,6
+157,8
@@
void Mixer_InitChannels(void)
for (i = 0; i < audio.num_channels; i++)
mixer[i].active = FALSE;
mixer_active_channels = 0;
for (i = 0; i < audio.num_channels; i++)
mixer[i].active = FALSE;
mixer_active_channels = 0;
+
+ Mix_ChannelFinished(Mixer_ChannelFinished);
}
static void Mixer_ResetChannelExpiration(int channel)
}
static void Mixer_ResetChannelExpiration(int channel)
@@
-247,13
+258,7
@@
static void Mixer_PlayMusicChannel(void)
static void Mixer_StopChannel(int channel)
{
static void Mixer_StopChannel(int channel)
{
- if (!mixer[channel].active)
- return;
-
Mix_HaltChannel(channel);
Mix_HaltChannel(channel);
-
- mixer[channel].active = FALSE;
- mixer_active_channels--;
}
static void Mixer_StopMusicChannel(void)
}
static void Mixer_StopMusicChannel(void)
@@
-519,6
+524,17
@@
void StartMixer(void)
(int)sqrt((float)(SOUND_MAX_LEFT2RIGHT * SOUND_MAX_LEFT2RIGHT - i * i));
}
(int)sqrt((float)(SOUND_MAX_LEFT2RIGHT * SOUND_MAX_LEFT2RIGHT - i * i));
}
+boolean isSoundPlaying(int nr)
+{
+ int i;
+
+ for (i = audio.first_sound_channel; i < audio.num_channels; i++)
+ if (mixer[i].active && mixer[i].nr == nr)
+ return TRUE;
+
+ return FALSE;
+}
+
// THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS
// ============================================================================
// THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS
// ============================================================================
@@
-587,6
+603,14
@@
static void *Load_WAV_or_MOD(char *filename)
return NULL;
}
return NULL;
}
+static int compareMusicInfo(const void *object1, const void *object2)
+{
+ const MusicInfo *mi1 = *((MusicInfo **)object1);
+ const MusicInfo *mi2 = *((MusicInfo **)object2);
+
+ return strcmp(mi1->source_filename, mi2->source_filename);
+}
+
static void LoadCustomMusic_NoConf(void)
{
static boolean draw_init_text = TRUE; // only draw at startup
static void LoadCustomMusic_NoConf(void)
{
static boolean draw_init_text = TRUE; // only draw at startup
@@
-664,6
+688,9
@@
static void LoadCustomMusic_NoConf(void)
closeDirectory(dir);
closeDirectory(dir);
+ // sort music files by filename
+ qsort(Music_NoConf, num_music_noconf, sizeof(MusicInfo *), compareMusicInfo);
+
draw_init_text = FALSE;
}
draw_init_text = FALSE;
}
@@
-679,6
+706,11
@@
int getMusicListSize(void)
music_info->num_dynamic_file_list_entries);
}
music_info->num_dynamic_file_list_entries);
}
+int getMusicListSize_NoConf(void)
+{
+ return num_music_noconf;
+}
+
struct FileInfo *getSoundListEntry(int pos)
{
int num_sounds = getSoundListSize();
struct FileInfo *getSoundListEntry(int pos)
{
int num_sounds = getSoundListSize();