Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#12971) Fix SDL_mixer plugin
Home

[Freeciv-Dev] (PR#12971) Fix SDL_mixer plugin

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12971) Fix SDL_mixer plugin
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 3 May 2005 10:22:31 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12971 >

The SDL_mixer sound plugin has a problem with a strange delay before
playing sounds. The attached patch miraculously fixes this problem for me.
Please test it and see if it fixes it for you.

Code shamelessly ripped from Wesnoth :)

  - Per

Index: client/audio_sdl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/audio_sdl.c,v
retrieving revision 1.8
diff -u -r1.8 audio_sdl.c
--- client/audio_sdl.c  3 Feb 2005 23:56:43 -0000       1.8
+++ client/audio_sdl.c  3 May 2005 17:14:54 -0000
@@ -32,6 +32,15 @@
   const char *tag;
 };
 
+/* Sounds don't sound good on Windows unless the buffer size is 4k,
+ * but this seems to cause strange behaviour on other systems,
+ * such as a delay before playing the sound. */
+#ifdef WIN32_NATIVE
+const size_t buf_size = 4096;
+#else
+const size_t buf_size = 1024;
+#endif
+
 static Mix_Music *mus = NULL;
 static struct sample samples[MIX_CHANNELS];
 
@@ -194,7 +203,7 @@
     return FALSE;
   }
 
-  if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
+  if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, buf_size) < 0) {
     freelog(LOG_ERROR, "Error calling Mix_OpenAudio");
     /* try something else */
     quit_sdl_audio();

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12971) Fix SDL_mixer plugin, Per I. Mathisen <=