if (mode & ERR_WARN && !options.verbose)
return;
-#if !defined(PLATFORM_UNIX)
+#if defined(PLATFORM_MSDOS)
newline = "\r\n";
if ((error = openErrorFile()) == NULL)
/* ========================================================================= */
-/* functions only needed for non-Unix (non-command-line) systems */
+/* functions only needed for non-Unix (non-command-line) systems */
+/* (MS-DOS only; SDL/Windows creates files "stdout.txt" and "stderr.txt") */
/* ========================================================================= */
-#if !defined(PLATFORM_UNIX)
+#if defined(PLATFORM_MSDOS)
-#define ERROR_FILENAME "error.out"
+#define ERROR_FILENAME "stderr.txt"
void initErrorFile()
{
- char *filename;
-
- InitUserDataDirectory();
-
- filename = getPath2(getUserDataDir(), ERROR_FILENAME);
- unlink(filename);
- free(filename);
+ unlink(ERROR_FILENAME);
}
FILE *openErrorFile()
{
- char *filename;
- FILE *error_file;
-
- filename = getPath2(getUserDataDir(), ERROR_FILENAME);
- error_file = fopen(filename, MODE_APPEND);
- free(filename);
-
- return error_file;
+ return fopen(ERROR_FILENAME, MODE_APPEND);
}
void dumpErrorFile()
{
- char *filename;
- FILE *error_file;
-
- filename = getPath2(getUserDataDir(), ERROR_FILENAME);
- error_file = fopen(filename, MODE_READ);
- free(filename);
+ FILE *error_file = fopen(ERROR_FILENAME, MODE_READ);
if (error_file != NULL)
{
int i, k;
#if 0
- printf("NEW SOUND %d HAS ARRIVED [%d]\n", snd_ctrl.nr, num_sounds);
-#endif
-
-#if 0
- printf("%d ACTIVE CHANNELS\n", mixer_active_channels);
+ printf("NEW SOUND %d ARRIVED [%d] [%d ACTIVE CHANNELS]\n",
+ snd_ctrl.nr, num_sounds, mixer_active_channels);
#endif
if (IS_MUSIC(snd_ctrl))
/* play music samples on a dedicated music channel */
if (IS_MUSIC(snd_ctrl))
{
-#if 0
- printf("PLAY MUSIC WITH VOLUME/STEREO %d/%d\n",
- snd_ctrl.volume, snd_ctrl.stereo_position);
-#endif
+ Mixer_StopMusicChannel();
mixer[audio.music_channel] = snd_ctrl;
Mixer_PlayMusicChannel();
of the channel's sound sample when compiling with the SDL mixer
library, we use the current playing time (in milliseconds) instead. */
+#if DEBUG
+ /* Channel sanity check -- this should normally not be needed */
+ if (mixer_active_channels ==
+ audio.num_channels - (mixer[audio.music_channel].active ? 0 : 1))
+ {
+ for (i=audio.first_sound_channel; i<audio.num_channels; i++)
+ {
+ if (!mixer[i].active)
+ {
+ Error(ERR_RETURN, "Mixer_InsertSound: Channel %d inactive", i);
+ Error(ERR_RETURN, "Mixer_InsertSound: This should never happen!");
+
+ mixer_active_channels--;
+ }
+ }
+ }
+#endif
+
if (mixer_active_channels ==
audio.num_channels - (mixer[audio.music_channel].active ? 0 : 1))
{
unsigned long playing_current = Counter();
int longest = 0, longest_nr = audio.first_sound_channel;
+ for (i=audio.first_sound_channel; i<audio.num_channels; i++)
+ {
+ Error(ERR_RETURN, "Mixer_InsertSound: %d [%d]: %ld (%ld)",
+ i, mixer[i].active, mixer[i].data_len, (long)mixer[i].data_ptr);
+ }
+
for (i=audio.first_sound_channel; i<audio.num_channels; i++)
{
int playing_time = playing_current - mixer[i].playing_starttime;
}
/* add the new sound to the mixer */
- for(i=0; i<audio.num_channels; i++)
+ for(i=audio.first_sound_channel; i<audio.num_channels; i++)
{
#if 0
printf("CHECKING CHANNEL %d FOR SOUND %d ...\n", i, snd_ctrl.nr);
#endif
- /*
- if (!mixer[i].active ||
- (IS_MUSIC(snd_ctrl) && i == audio.music_channel))
- */
- if ((i == audio.music_channel && IS_MUSIC(snd_ctrl)) ||
- (i != audio.music_channel && !mixer[i].active))
+ if (!mixer[i].active)
{
#if 0
printf("ADDING NEW SOUND %d TO MIXER\n", snd_ctrl.nr);
#endif
-#if 1
#if defined(AUDIO_UNIX_NATIVE)
if (snd_info->data_len == 0)
{
printf("THIS SHOULD NEVER HAPPEN! [snd_info->data_len == 0]\n");
}
#endif
-#endif
-
-#if 1
- if (IS_MUSIC(snd_ctrl) && i == audio.music_channel && mixer[i].active)
- {
- printf("THIS SHOULD NEVER HAPPEN! [adding music twice]\n");
-
-#if 1
- Mixer_StopChannel(i);
-#endif
- }
-#endif
mixer[i] = snd_ctrl;
Mixer_PlayChannel(i);