tBasic libtool support added for sound plugins; the plugins themselves have been moved to the plugins/ subdirectory. - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 904d7522898cbfcba2d77d450d1bfa16b89f36f7
 (DIR) parent 217c1fe260a46fda3f4ed57b8402bcc753aa9c24
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Mon, 13 May 2002 15:51:20 +0000
       
       Basic libtool support added for sound plugins; the plugins themselves
       have been moved to the plugins/ subdirectory.
       
       
       Diffstat:
         A src/plugins/Makefile.am             |       6 ++++++
         A src/plugins/sound_esd.c             |     102 +++++++++++++++++++++++++++++++
         R src/sound_esd.h -> src/plugins/sou… |       0 
         A src/plugins/sound_sdl.c             |     121 +++++++++++++++++++++++++++++++
         R src/sound_sdl.h -> src/plugins/sou… |       0 
         R src/sound_winmm.c -> src/plugins/s… |       0 
         R src/sound_winmm.h -> src/plugins/s… |       0 
         D src/sound_esd.c                     |     102 -------------------------------
         D src/sound_sdl.c                     |     121 -------------------------------
       
       9 files changed, 229 insertions(+), 223 deletions(-)
       ---
 (DIR) diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
       t@@ -0,0 +1,6 @@
       +lib_LTLIBRARIES = libsound_esd.la libsound_sdl.la libsound_winmm.la
       +libsound_esd_la_SOURCES = sound_esd.c sound_esd.h
       +libsound_sdl_la_SOURCES = sound_sdl.c sound_sdl.h
       +libsound_winmm_la_SOURCES = sound_winmm.c sound_winmm.h
       +LIBS = @SOUND_LIBS@ @GLIB_CFLAGS@
       +INCLUDES = @SOUND_CFLAGS@ @GLIB_CFLAGS@
 (DIR) diff --git a/src/plugins/sound_esd.c b/src/plugins/sound_esd.c
       t@@ -0,0 +1,102 @@
       +/************************************************************************
       + * sound_esd.c    dopewars sound system (ESD/esound driver)             *
       + * Copyright (C)  1998-2002  Ben Webb                                   *
       + *                Email: ben@bellatrix.pcl.ox.ac.uk                     *
       + *                WWW: http://dopewars.sourceforge.net/                 *
       + *                                                                      *
       + * 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       *
       + * of the License, 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.                         *
       + *                                                                      *
       + * You should have received a copy of the GNU General Public License    *
       + * along with this program; if not, write to the Free Software          *
       + * Foundation, Inc., 59 Temple Place - Suite 330, Boston,               *
       + *                   MA  02111-1307, USA.                               *
       + ************************************************************************/
       +
       +#ifdef HAVE_CONFIG_H
       +#include <config.h>
       +#endif
       +
       +#ifdef HAVE_ESD
       +#include <stdio.h>
       +#include <string.h>
       +#include <esd.h>
       +#include <glib.h>
       +#include "../sound.h"
       +
       +#define MAXCACHE 6
       +
       +struct SoundCache {
       +  int esdid;
       +  gchar *name;
       +} cache[MAXCACHE];
       +  
       +
       +static int sock, nextcache;
       +
       +static gboolean SoundOpen_ESD(void)
       +{
       +  int i;
       +
       +  sock = esd_open_sound(NULL);
       +  for (i = 0; i < MAXCACHE; i++) {
       +    cache[i].esdid = -1;
       +    cache[i].name = NULL;
       +  }
       +  nextcache = 0;
       +  return TRUE;
       +}
       +
       +static void SoundClose_ESD(void)
       +{
       +  int i;
       +
       +  for (i = 0; i < MAXCACHE; i++) {
       +    g_free(cache[i].name);
       +    if (cache[i].esdid != -1) {
       +      esd_sample_free(sock, cache[i].esdid);
       +    }
       +  }
       +  esd_close(sock);
       +}
       +
       +static void SoundPlay_ESD(const gchar *snd)
       +{
       +  int i;
       +
       +  for (i = 0; i < MAXCACHE; i++) {
       +    if (cache[i].name && strcmp(cache[i].name, snd) == 0) {
       +      esd_sample_play(sock, cache[i].esdid);
       +      return;
       +    }
       +  }
       +
       +  if (cache[nextcache].esdid != -1) {
       +    esd_sample_free(sock, cache[nextcache].esdid);
       +    g_free(cache[nextcache].name);
       +  }
       +  cache[nextcache].esdid = esd_file_cache(sock, "", snd);
       +  cache[nextcache].name = g_strdup(snd);
       +  esd_sample_play(sock, cache[nextcache].esdid);
       +  nextcache = (nextcache + 1) % MAXCACHE;
       +}
       +
       +SoundDriver *init(void)
       +{
       +  static SoundDriver driver;
       +
       +  driver.name = "esd";
       +  driver.open = SoundOpen_ESD;
       +  driver.close = SoundClose_ESD;
       +  driver.play = SoundPlay_ESD;
       +  return &driver;
       +}
       +
       +#endif /* HAVE_ESD */
 (DIR) diff --git a/src/sound_esd.h b/src/plugins/sound_esd.h
 (DIR) diff --git a/src/plugins/sound_sdl.c b/src/plugins/sound_sdl.c
       t@@ -0,0 +1,121 @@
       +/************************************************************************
       + * sound_sdl.c    dopewars sound system (SDL driver)                    *
       + * Copyright (C)  1998-2002  Ben Webb                                   *
       + *                Email: ben@bellatrix.pcl.ox.ac.uk                     *
       + *                WWW: http://dopewars.sourceforge.net/                 *
       + *                                                                      *
       + * 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       *
       + * of the License, 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.                         *
       + *                                                                      *
       + * You should have received a copy of the GNU General Public License    *
       + * along with this program; if not, write to the Free Software          *
       + * Foundation, Inc., 59 Temple Place - Suite 330, Boston,               *
       + *                   MA  02111-1307, USA.                               *
       + ************************************************************************/
       +
       +#ifdef HAVE_CONFIG_H
       +#include <config.h>
       +#endif
       +
       +#ifdef HAVE_SDL_MIXER
       +#include <stdio.h>
       +#include <string.h>
       +#include <SDL.h>
       +#include <SDL_mixer.h>
       +#include <glib.h>
       +#include "../sound.h"
       +
       +struct ChannelStruct {
       +  Mix_Chunk *chunk;
       +  gchar *name;
       +} channel[MIX_CHANNELS];
       +  
       +static gboolean SoundOpen_SDL(void)
       +{
       +  const int audio_rate = MIX_DEFAULT_FREQUENCY;
       +  const int audio_format = MIX_DEFAULT_FORMAT;
       +  const int audio_channels = 2;
       +  int i;
       +
       +  if (SDL_Init(SDL_INIT_AUDIO) < 0) {
       +    return FALSE;
       +  }
       +
       +  if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
       +    SDL_Quit();
       +    return FALSE;
       +  }
       +  Mix_AllocateChannels(MIX_CHANNELS);
       +
       +  for (i = 0; i < MIX_CHANNELS; i++) {
       +    channel[i].chunk = NULL;
       +    channel[i].name = NULL;
       +  }
       +  return TRUE;
       +}
       +
       +static void SoundClose_SDL(void)
       +{
       +  int i;
       +
       +  for (i = 0; i < MIX_CHANNELS; i++) {
       +    g_free(channel[i].name);
       +    if (channel[i].chunk) {
       +      Mix_FreeChunk(channel[i].chunk);
       +    }
       +  }
       +  Mix_CloseAudio();
       +  SDL_Quit();
       +}
       +
       +static void SoundPlay_SDL(const gchar *snd)
       +{
       +  int i, chan_num;
       +  Mix_Chunk *chunk;
       +
       +  for (i = 0; i < MIX_CHANNELS; i++) {
       +    if (channel[i].name && strcmp(channel[i].name, snd) == 0) {
       +      Mix_PlayChannel(-1, channel[i].chunk, 0);
       +      return;
       +    }
       +  }
       +
       +  chunk = Mix_LoadWAV(snd);
       +  if (!chunk) {
       +    return;
       +  }
       +
       +  chan_num = Mix_PlayChannel(-1, chunk, 0);
       +  if (chan_num < 0) {
       +    Mix_FreeChunk(chunk);
       +    return;
       +  }
       +
       +  if (channel[chan_num].chunk) {
       +    Mix_FreeChunk(channel[chan_num].chunk);
       +    g_free(channel[chan_num].name);
       +  }
       +
       +  channel[chan_num].chunk = chunk;
       +  channel[chan_num].name = g_strdup(snd);
       +}
       +
       +SoundDriver *init(void)
       +{
       +  static SoundDriver driver;
       +
       +  driver.name = "sdl";
       +  driver.open = SoundOpen_SDL;
       +  driver.close = SoundClose_SDL;
       +  driver.play = SoundPlay_SDL;
       +  return &driver;
       +}
       +
       +#endif /* HAVE_SDL_MIXER */
 (DIR) diff --git a/src/sound_sdl.h b/src/plugins/sound_sdl.h
 (DIR) diff --git a/src/sound_winmm.c b/src/plugins/sound_winmm.c
 (DIR) diff --git a/src/sound_winmm.h b/src/plugins/sound_winmm.h
 (DIR) diff --git a/src/sound_esd.c b/src/sound_esd.c
       t@@ -1,102 +0,0 @@
       -/************************************************************************
       - * sound_esd.c    dopewars sound system (ESD/esound driver)             *
       - * Copyright (C)  1998-2002  Ben Webb                                   *
       - *                Email: ben@bellatrix.pcl.ox.ac.uk                     *
       - *                WWW: http://dopewars.sourceforge.net/                 *
       - *                                                                      *
       - * 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       *
       - * of the License, 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.                         *
       - *                                                                      *
       - * You should have received a copy of the GNU General Public License    *
       - * along with this program; if not, write to the Free Software          *
       - * Foundation, Inc., 59 Temple Place - Suite 330, Boston,               *
       - *                   MA  02111-1307, USA.                               *
       - ************************************************************************/
       -
       -#ifdef HAVE_CONFIG_H
       -#include <config.h>
       -#endif
       -
       -#ifdef HAVE_ESD
       -#include <stdio.h>
       -#include <string.h>
       -#include <esd.h>
       -#include <glib.h>
       -#include "sound.h"
       -
       -#define MAXCACHE 6
       -
       -struct SoundCache {
       -  int esdid;
       -  gchar *name;
       -} cache[MAXCACHE];
       -  
       -
       -static int sock, nextcache;
       -
       -static gboolean SoundOpen_ESD(void)
       -{
       -  int i;
       -
       -  sock = esd_open_sound(NULL);
       -  for (i = 0; i < MAXCACHE; i++) {
       -    cache[i].esdid = -1;
       -    cache[i].name = NULL;
       -  }
       -  nextcache = 0;
       -  return TRUE;
       -}
       -
       -static void SoundClose_ESD(void)
       -{
       -  int i;
       -
       -  for (i = 0; i < MAXCACHE; i++) {
       -    g_free(cache[i].name);
       -    if (cache[i].esdid != -1) {
       -      esd_sample_free(sock, cache[i].esdid);
       -    }
       -  }
       -  esd_close(sock);
       -}
       -
       -static void SoundPlay_ESD(const gchar *snd)
       -{
       -  int i;
       -
       -  for (i = 0; i < MAXCACHE; i++) {
       -    if (cache[i].name && strcmp(cache[i].name, snd) == 0) {
       -      esd_sample_play(sock, cache[i].esdid);
       -      return;
       -    }
       -  }
       -
       -  if (cache[nextcache].esdid != -1) {
       -    esd_sample_free(sock, cache[nextcache].esdid);
       -    g_free(cache[nextcache].name);
       -  }
       -  cache[nextcache].esdid = esd_file_cache(sock, "", snd);
       -  cache[nextcache].name = g_strdup(snd);
       -  esd_sample_play(sock, cache[nextcache].esdid);
       -  nextcache = (nextcache + 1) % MAXCACHE;
       -}
       -
       -SoundDriver *init(void)
       -{
       -  static SoundDriver driver;
       -
       -  driver.name = "esd";
       -  driver.open = SoundOpen_ESD;
       -  driver.close = SoundClose_ESD;
       -  driver.play = SoundPlay_ESD;
       -  return &driver;
       -}
       -
       -#endif /* HAVE_ESD */
 (DIR) diff --git a/src/sound_sdl.c b/src/sound_sdl.c
       t@@ -1,121 +0,0 @@
       -/************************************************************************
       - * sound_sdl.c    dopewars sound system (SDL driver)                    *
       - * Copyright (C)  1998-2002  Ben Webb                                   *
       - *                Email: ben@bellatrix.pcl.ox.ac.uk                     *
       - *                WWW: http://dopewars.sourceforge.net/                 *
       - *                                                                      *
       - * 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       *
       - * of the License, 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.                         *
       - *                                                                      *
       - * You should have received a copy of the GNU General Public License    *
       - * along with this program; if not, write to the Free Software          *
       - * Foundation, Inc., 59 Temple Place - Suite 330, Boston,               *
       - *                   MA  02111-1307, USA.                               *
       - ************************************************************************/
       -
       -#ifdef HAVE_CONFIG_H
       -#include <config.h>
       -#endif
       -
       -#ifdef HAVE_SDL_MIXER
       -#include <stdio.h>
       -#include <string.h>
       -#include <SDL.h>
       -#include <SDL_mixer.h>
       -#include <glib.h>
       -#include "sound.h"
       -
       -struct ChannelStruct {
       -  Mix_Chunk *chunk;
       -  gchar *name;
       -} channel[MIX_CHANNELS];
       -  
       -static gboolean SoundOpen_SDL(void)
       -{
       -  const int audio_rate = MIX_DEFAULT_FREQUENCY;
       -  const int audio_format = MIX_DEFAULT_FORMAT;
       -  const int audio_channels = 2;
       -  int i;
       -
       -  if (SDL_Init(SDL_INIT_AUDIO) < 0) {
       -    return FALSE;
       -  }
       -
       -  if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
       -    SDL_Quit();
       -    return FALSE;
       -  }
       -  Mix_AllocateChannels(MIX_CHANNELS);
       -
       -  for (i = 0; i < MIX_CHANNELS; i++) {
       -    channel[i].chunk = NULL;
       -    channel[i].name = NULL;
       -  }
       -  return TRUE;
       -}
       -
       -static void SoundClose_SDL(void)
       -{
       -  int i;
       -
       -  for (i = 0; i < MIX_CHANNELS; i++) {
       -    g_free(channel[i].name);
       -    if (channel[i].chunk) {
       -      Mix_FreeChunk(channel[i].chunk);
       -    }
       -  }
       -  Mix_CloseAudio();
       -  SDL_Quit();
       -}
       -
       -static void SoundPlay_SDL(const gchar *snd)
       -{
       -  int i, chan_num;
       -  Mix_Chunk *chunk;
       -
       -  for (i = 0; i < MIX_CHANNELS; i++) {
       -    if (channel[i].name && strcmp(channel[i].name, snd) == 0) {
       -      Mix_PlayChannel(-1, channel[i].chunk, 0);
       -      return;
       -    }
       -  }
       -
       -  chunk = Mix_LoadWAV(snd);
       -  if (!chunk) {
       -    return;
       -  }
       -
       -  chan_num = Mix_PlayChannel(-1, chunk, 0);
       -  if (chan_num < 0) {
       -    Mix_FreeChunk(chunk);
       -    return;
       -  }
       -
       -  if (channel[chan_num].chunk) {
       -    Mix_FreeChunk(channel[chan_num].chunk);
       -    g_free(channel[chan_num].name);
       -  }
       -
       -  channel[chan_num].chunk = chunk;
       -  channel[chan_num].name = g_strdup(snd);
       -}
       -
       -SoundDriver *init(void)
       -{
       -  static SoundDriver driver;
       -
       -  driver.name = "sdl";
       -  driver.open = SoundOpen_SDL;
       -  driver.close = SoundClose_SDL;
       -  driver.play = SoundPlay_SDL;
       -  return &driver;
       -}
       -
       -#endif /* HAVE_SDL_MIXER */