Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2002:
[Freeciv-Dev] [Patch] WinMM Sound patch
Home

[Freeciv-Dev] [Patch] WinMM Sound patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [Patch] WinMM Sound patch
From: Andreas Kemnade <akemnade@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Apr 2002 15:17:03 +0200

I have put together a small patch to add a sound plugin for the
windows multimedia system.

diff --exclude-from freeciv/diff_ignore -Nur /usr/src/cvs/freeciv/acconfig.h 
freeciv/acconfig.h
--- /usr/src/cvs/freeciv/acconfig.h     Wed Apr 24 13:57:12 2002
+++ freeciv/acconfig.h  Wed Apr 24 14:24:01 2002
@@ -61,7 +61,7 @@
 #undef OPTION_FILE_NAME
 #undef ESD
 #undef SDL
-
+#undef WINMM
 @BOTTOM@
 
 #endif /* FC_CONFIG_H */
diff --exclude-from freeciv/diff_ignore -Nur 
/usr/src/cvs/freeciv/client/Makefile.am freeciv/client/Makefile.am
--- /usr/src/cvs/freeciv/client/Makefile.am     Sat Apr 20 20:12:31 2002
+++ freeciv/client/Makefile.am  Wed Apr 24 14:23:46 2002
@@ -30,6 +30,10 @@
 SDL_FILES=audio_sdl.c audio_sdl.h
 endif
 
+if WINMM
+WINMM_FILES=audio_winmm.c audio_winmm.h
+endif
+
 EXTRA_DIST=    gui-mui/autogroupclass.c         \
                gui-mui/autogroupclass.h         \
                gui-mui/chatline.c               \
@@ -113,7 +117,7 @@
 
 ## Above, note -I../intl instead of -I$(top_srdir/intl) is deliberate.
 
-civclient_SOURCES = $(ESD_FILES) $(SDL_FILES) \
+civclient_SOURCES = $(ESD_FILES) $(SDL_FILES) $(WINMM_FILES) \
        attribute.h     \
        attribute.c     \
        citydlg_common.c \
diff --exclude-from freeciv/diff_ignore -Nur 
/usr/src/cvs/freeciv/client/audio.c freeciv/client/audio.c
--- /usr/src/cvs/freeciv/client/audio.c Wed Apr 24 00:51:22 2002
+++ freeciv/client/audio.c      Wed Apr 24 15:05:41 2002
@@ -34,6 +34,10 @@
 #include "audio_sdl.h"
 #endif
 
+#ifdef AUDIO_WINMM
+#include "audio_winmm.h"
+#endif
+
 #include "audio.h"
 
 #define MAX_NUM_PLUGINS        3
@@ -110,6 +114,9 @@
 #ifdef SDL
   audio_sdl_init();
 #endif
+#ifdef WINMM
+  audio_winmm_init();
+#endif
 }
 
 /**************************************************************************
@@ -158,7 +165,8 @@
     return;
   }
 
-  if (!audio_select_plugin("esd") && !audio_select_plugin("sdl")) {
+  if (!audio_select_plugin("esd") && !audio_select_plugin("sdl") 
+      && !audio_select_plugin("winmm")) {
     freelog(LOG_NORMAL,
            _("No real audio subsystem managed to initialize!"));
     freelog(LOG_NORMAL,
diff --exclude-from freeciv/diff_ignore -Nur 
/usr/src/cvs/freeciv/client/audio_winmm.c freeciv/client/audio_winmm.c
--- /usr/src/cvs/freeciv/client/audio_winmm.c   Thu Jan  1 01:00:00 1970
+++ freeciv/client/audio_winmm.c        Wed Apr 24 14:45:13 2002
@@ -0,0 +1,72 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <assert.h>
+#include <windows.h>
+#include <mmsystem.h>
+
+#include "log.h"
+#include "fcintl.h"
+#include "support.h"
+#include "audio.h"
+
+#include "audio_winmm.h"
+
+/**************************************************************************
+  Stop music
+**************************************************************************/
+static void stop()
+{
+  sndPlaySound(NULL,0);
+}
+
+/**************************************************************************
+  Wait
+**************************************************************************/
+static void wait()
+{
+  /* not implemented */
+}
+
+/**************************************************************************
+  Play sound sample
+**************************************************************************/
+static bool play(const char *const tag, const char *const fullpath,
+                 bool repeat)
+{
+  if (!fullpath)
+    return FALSE;
+  sndPlaySound(fullpath,SND_ASYNC | (repeat ? SND_LOOP : 0));
+} 
+
+/**************************************************************************
+  Initialize. Note that this function is called very early at the
+  client startup. So for example logging isn't available.
+**************************************************************************/
+void audio_winmm_init(void)
+{
+  struct audio_plugin self;
+  
+  sz_strlcpy(self.name, "winmm");
+  sz_strlcpy(self.descr, "WinMM plugin");
+  self.shutdown = stop;
+  self.stop = stop;
+  self.wait = wait;
+  self.play = play;
+  audio_add_plugin(&self);
+}
diff --exclude-from freeciv/diff_ignore -Nur 
/usr/src/cvs/freeciv/client/audio_winmm.h freeciv/client/audio_winmm.h
--- /usr/src/cvs/freeciv/client/audio_winmm.h   Thu Jan  1 01:00:00 1970
+++ freeciv/client/audio_winmm.h        Wed Apr 24 14:19:16 2002
@@ -0,0 +1,18 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__AUDIO_WINMM_H
+#define FC__AUDIO_WINMM_H
+
+void audio_winmm_init(void);
+
+#endif                          /* FC__AUDIO_WINMM_H */
diff --exclude-from freeciv/diff_ignore -Nur /usr/src/cvs/freeciv/configure.in 
freeciv/configure.in
--- /usr/src/cvs/freeciv/configure.in   Wed Apr 24 13:57:12 2002
+++ freeciv/configure.in        Wed Apr 24 14:49:03 2002
@@ -511,6 +511,13 @@
       AC_MSG_RESULT([no, install SDL_mixer first: 
http://www.libsdl.org/projects/SDL_mixer/index.html])
     fi
   fi
+  
+  dnl Add WinMM sound support to client
+  if test x"$MINGW32" = "xyes"; then
+    SOUND_LIBS="$SOUND_LIBS -lwinmm"
+    AC_DEFINE(WINMM)    
+    WINMM="yes"
+  fi
 
   gui_sources="gui-$client"
 fi
@@ -521,6 +528,7 @@
 AC_SUBST(SOUND_LIBS)
 AM_CONDITIONAL(ESD, test "$ESD" != "no")
 AM_CONDITIONAL(SDL, test "$SDL_mixer" = "yes")
+AM_CONDITIONAL(WINMM, test "$WINMM" = "yes")
 AM_CONDITIONAL(CLIENT_GUI_GTK, test "$gui_sources" = "gui-gtk")
 AM_CONDITIONAL(CLIENT_GUI_GTK_2_0, test "$gui_sources" = "gui-gtk-2.0")
 AM_CONDITIONAL(CLIENT_GUI_XAW, test "$gui_sources" = "gui-xaw")
Greetings
Andreas Kemnade

[Prev in Thread] Current Thread [Next in Thread]