pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2478 - in trunk/src: . sound


From: David Philippi at BerliOS
Subject: [Pingus-CVS] r2478 - in trunk/src: . sound
Date: Thu, 3 Nov 2005 12:58:36 +0100

Author: torangan
Date: 2005-11-03 12:57:28 +0100 (Thu, 03 Nov 2005)
New Revision: 2478

Added:
   trunk/src/sound/sound_impl.hxx
Modified:
   trunk/src/pingus_main.cxx
   trunk/src/pingus_main.hxx
   trunk/src/pingus_menu.cxx
   trunk/src/sound/Makefile.am
   trunk/src/sound/sound.cxx
   trunk/src/sound/sound.hxx
   trunk/src/sound/sound_dummy.hxx
   trunk/src/sound/sound_real.cxx
   trunk/src/sound/sound_real.hxx
   trunk/src/world.cxx
Log:
cleanup, mostly sound related

Modified: trunk/src/pingus_main.cxx
===================================================================
--- trunk/src/pingus_main.cxx   2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/pingus_main.cxx   2005-11-03 11:57:28 UTC (rev 2478)
@@ -258,61 +258,6 @@
   argp.add_option('m', "disable-music", "", 
                   _("Disable music"));
 
-#if 0 
-  // FIXME: We need some clean up here
-  struct option long_options[] =
-    {
-      {"disable-music",      no_argument,       0, 'm'},
-      {"disable-sound",      no_argument,       0, 's'},
-      {"enable-cursor",     no_argument,       0, 'c'},
-      {"disable-intro",     no_argument,       0, 'n'},
-      {"play-demo",         required_argument, 0, 'p'},
-      {"disable-demo-recording", required_argument, 0, 'r'},
-      {"speed",             required_argument, 0, 't'},
-      {"datadir",           required_argument, 0, 'd'},
-      {"level",             required_argument, 0, 'l'},
-      {"worldmap",          required_argument, 0, 358},
-      {"credits",           no_argument,       0, 359},
-      {"help",              no_argument,       0, 'h'}, // add -? support
-      {"version",           no_argument,       0, 'V'},
-      {"verbose",           required_argument, 0, 'v'},
-      {"print-fps",         no_argument,       0, 'b'},
-      {"sound-specs",       required_argument, 0, 'S'},
-      {"geometry",          required_argument, 0, 'g'},
-      {"quick-play",        no_argument,       0, 'q'},
-      {"fullscreen",        no_argument,       0, 'f'},
-      ("refresh-rate",      required_argument, 0, 'R'),
-      {"window",            no_argument,       0, 'w'},
-      {"disable-swcursor",  no_argument,       0, 345},
-      {"enable-swcursor",   no_argument,       0, 346},
-      {"disable-action-help",no_argument,      0, 356},
-      {"enable-action-help", no_argument,      0, 357},
-      {"enable-bg-manipulation", no_argument,  0, 348},
-      {"min-cpu-usage",     no_argument,       0, 353},
-      {"min-frame-skip",    required_argument, 0, 354},
-      {"max-frame-skip",    required_argument, 0, 355},
-      {"frame-skip",        required_argument, 0, 357},
-      {"cheat",             required_argument, 0, 356},
-      {"controller",        required_argument, 0, 360},
-      {"render-preview",    required_argument, 0, 361},
-      {"blitter-test",      no_argument,       0, 362},
-      {"use-opengl",        no_argument,       0, 'G'},
-
-      // FIXME: is the number stuff correct?
-      {"fast",            no_argument,       0, 332},
-      {"fast-mode",       no_argument,       0, 332},
-      {"disable-previews",no_argument,       0, 333},
-      {"maintainer-mode", no_argument,       0, 334},
-      {"disable-auto-scrolling",   no_argument,       0, 337},
-
-      //
-      {"no-cfg-file",    no_argument,       0, 342},
-      {"tile-size",      required_argument, 0, 344},
-      {"config-file",    required_argument, 0, 347},
-      {"debug",          required_argument, 0, 352},
-      {0, 0, 0, 0}
-    };
-#endif
   argp.parse_args(argc, argv);
   argp.set_help_indent(20);
   
@@ -882,8 +827,6 @@
       
       window = new CL_DisplayWindow(window_desc);
       
-      sound  = new CL_SoundOutput(44100);
-
       CL_Display::clear();
       CL_Display::flip();
     }
@@ -902,15 +845,14 @@
 void
 PingusMain::deinit_clanlib()
 {
+  CL_SetupCore::deinit();
   CL_SetupGUI::deinit ();
+  CL_SetupDisplay::deinit ();
 
   if (use_opengl)
     CL_SetupGL::deinit();
   else
     CL_SetupSDL::deinit();
-
-  CL_SetupDisplay::deinit ();
-  CL_SetupCore::deinit();
 }
 
 void

Modified: trunk/src/pingus_main.hxx
===================================================================
--- trunk/src/pingus_main.hxx   2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/pingus_main.hxx   2005-11-03 11:57:28 UTC (rev 2478)
@@ -33,7 +33,6 @@
 {
 private:
   CL_DisplayWindow* window; 
-  CL_SoundOutput*   sound;
 
   bool    blitter_test;
   bool    no_config_file;

Modified: trunk/src/pingus_menu.cxx
===================================================================
--- trunk/src/pingus_menu.cxx   2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/pingus_menu.cxx   2005-11-03 11:57:28 UTC (rev 2478)
@@ -156,6 +156,11 @@
 
 PingusMenu::~PingusMenu()
 {
+       delete start_button;
+       delete quit_button;
+       delete contrib_button;
+       delete story_button;
+       delete multiplayer_button;
 }
 
 void

Modified: trunk/src/sound/Makefile.am
===================================================================
--- trunk/src/sound/Makefile.am 2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/sound/Makefile.am 2005-11-03 11:57:28 UTC (rev 2478)
@@ -1,4 +1,4 @@
-# Pingus - A free Lemmings clone
+# Pingus - A free Lemmings clone
 # Copyright (C) 1999 Ingo Ruhnke <address@hidden>
 #
 # This program is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
 libpingus_sound_a_SOURCES = \
        sound.cxx  sound_dummy.cxx  sound_real.cxx \
        sound.hxx  sound_dummy.hxx  sound_real.hxx \
-        sounds.hxx sound_res_mgr.hxx sound_res_mgr.cxx
+        sounds.hxx sound_res_mgr.hxx sound_res_mgr.cxx \
+               sound_impl.hxx
 
 # EOF #

Modified: trunk/src/sound/sound.cxx
===================================================================
--- trunk/src/sound/sound.cxx   2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/sound/sound.cxx   2005-11-03 11:57:28 UTC (rev 2478)
@@ -24,41 +24,42 @@
 #include "../globals.hxx"
 #include "sound_dummy.hxx"
 #include "sound_real.hxx"
+#include "sound.hxx"
 
 namespace Pingus {
 namespace Sound {
 
-PingusSound* PingusSound::sound;
+PingusSoundImpl * PingusSound::sound;
 
 void
-PingusSound::init (PingusSound* s)
+PingusSound::init (PingusSoundImpl* s)
 {
   if (s == 0)
+  {
+    if (sound_enabled || music_enabled)
     {
-      if (sound_enabled || music_enabled)
-        {
-          if (verbose)
-            std::cout << "Init Sound" << std::endl;
+      if (verbose)
+        std::cout << "Init Sound" << std::endl;
 
-          try {
-            PingusSound::init (new PingusSoundReal ());
-          } catch (CL_Error& err) {
-            std::cout << "CL_Error: " << err.message << std::endl;
-            std::cout << "Sound will be disabled" << std::endl;
-            PingusSound::init (new PingusSoundDummy ());
-          }
-        }
-      else
-        {
-          if (verbose)
-            std::cout << "Sound disabled" << std::endl;
-          PingusSound::init (new PingusSoundDummy ());
-        }
+      try {
+        PingusSound::init (new PingusSoundReal ());
+      } catch (CL_Error& err) {
+        std::cout << "CL_Error: " << err.message << std::endl;
+        std::cout << "Sound will be disabled" << std::endl;
+        PingusSound::init (new PingusSoundDummy ());
+      }
     }
+               else
+               {
+                       if (verbose)
+                               std::cout << "Sound disabled" << std::endl;
+                       PingusSound::init (new PingusSoundDummy ());
+               }
+       }
   else
-    {
-      sound = s;
-    }
+  {
+    sound = s;
+  }
 }
 
 void
@@ -69,9 +70,9 @@
 }
 
 /** Load a sound file and play it immediately.
-
address@hidden filename The complete filename */
-
+       @param filename The complete filename
+       @param volume The desired volume level
+       @param panning The desired panning level (stereo only) */
 void
 PingusSound::play_sound(const std::string& name, float volume, float panning)
 {

Modified: trunk/src/sound/sound.hxx
===================================================================
--- trunk/src/sound/sound.hxx   2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/sound/sound.hxx   2005-11-03 11:57:28 UTC (rev 2478)
@@ -20,27 +20,26 @@
 #ifndef HEADER_PINGUS_SOUND_HXX
 #define HEADER_PINGUS_SOUND_HXX
 
+#include <Clanlib/sound.h>
 #include <string>
 #include "sounds.hxx"
+#include "sound_impl.hxx"
 
 namespace Pingus {
 namespace Sound {
+
+class PingusSoundImpl;
+
 class PingusSound
 {
-protected:
-  /** FIXME: this should be SoundImpl, not PingusSound */
-  static PingusSound* sound;
+private:
+  static PingusSoundImpl* sound;
 
-protected:
-  PingusSound () { }
-       virtual ~PingusSound () { }
-
-  virtual void real_play_sound(const std::string & name, float volume, float 
panning) =0;
-  virtual void real_play_music(const std::string & name, float volume) =0;
-  virtual void real_stop_music() =0;
-
 public:
-  static void init (PingusSound* s = 0);
+       PingusSound  () { }
+       ~PingusSound () { }
+
+       static void init (PingusSoundImpl* s = 0);
   static void deinit ();
 
   /** Load a sound file and play it immediately.

Modified: trunk/src/sound/sound_dummy.hxx
===================================================================
--- trunk/src/sound/sound_dummy.hxx     2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/sound/sound_dummy.hxx     2005-11-03 11:57:28 UTC (rev 2478)
@@ -20,15 +20,17 @@
 #ifndef HEADER_PINGUS_SOUND_DUMMY_HXX
 #define HEADER_PINGUS_SOUND_DUMMY_HXX
 
+#include "sound_impl.hxx"
 #include "sound.hxx"
 
 namespace Pingus {
 namespace Sound {
 
-class PingusSoundDummy : public PingusSound
+class PingusSoundDummy : public PingusSoundImpl
 {
 public:
   PingusSoundDummy () { }
+       virtual ~PingusSoundDummy () { }
 
   virtual void real_play_sound (const std::string & filename, float volume, 
float panning);
   virtual void real_play_music (const std::string & filename, float volume);

Added: trunk/src/sound/sound_impl.hxx
===================================================================
--- trunk/src/sound/sound_impl.hxx      2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/sound/sound_impl.hxx      2005-11-03 11:57:28 UTC (rev 2478)
@@ -0,0 +1,52 @@
+//  $Id: sound_impl.hxx,v 1.0 2005/11/01 Jave27 Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
+//
+//  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.
+
+#ifndef HEADER_PINGUS_SOUND_IMPL_HXX
+#define HEADER_PINGUS_SOUND_IMPL_HXX
+
+#include "../pingus.hxx"
+
+namespace Pingus {
+namespace Sound {
+
+class PingusSoundImpl
+{
+public:
+       PingusSoundImpl () { };
+       virtual ~PingusSoundImpl () { };
+
+       /** Load a music file and play it immediately.
+    @param filename The complete filename
+    @param volume   The volume to play the music with  */
+  virtual void real_play_music(const std::string & filename, float volume) = 0;
+
+       /** Stops playing any music file */
+  virtual void real_stop_music() = 0;
+
+       /** Load a sound file and play it immediately
+    @param filename The complete filename
+    @param volume   The volume to play the sound at
+    @param panning  The panning to play the sound with */
+  virtual void real_play_sound(const std::string & filename, 
+                                                                               
                                         float volume, float panning) = 0;
+}; // class PingusSoundImpl
+}  // namespace Sound
+}  // namespace Pingus
+
+#endif

Modified: trunk/src/sound/sound_real.cxx
===================================================================
--- trunk/src/sound/sound_real.cxx      2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/sound/sound_real.cxx      2005-11-03 11:57:28 UTC (rev 2478)
@@ -43,6 +43,7 @@
 {
   pout(PINGUS_DEBUG_SOUND) << "Initializing ClanLib-Sound" << std::endl;
 
+  sound_output  = new CL_SoundOutput(44100);
   CL_SetupSound::init();
 
   pout(PINGUS_DEBUG_SOUND) << "Initializing ClanLib-MikMod" << std::endl;
@@ -70,6 +71,8 @@
 #endif
 
   CL_SetupSound::deinit();
+       sound_output->stop_all();
+       delete sound_output;
 }
 
 struct sound_is_finished
@@ -107,17 +110,17 @@
 PingusSoundReal::real_stop_music ()
 {
   if (music_session)
+  {
+    music_session->stop();
+    delete music_session;
+    music_session = 0;
+
+    if (music_sample)
     {
-      music_session->stop();
-      delete music_session;
-      music_session = 0;
-
-      if (music_sample)
-        {
-          delete music_sample;
-          music_sample = NULL;
-        }
+      delete music_sample;
+      music_sample = NULL;
     }
+  }
 }
 
 void

Modified: trunk/src/sound/sound_real.hxx
===================================================================
--- trunk/src/sound/sound_real.hxx      2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/sound/sound_real.hxx      2005-11-03 11:57:28 UTC (rev 2478)
@@ -22,6 +22,7 @@
 
 #include <config.h>
 #include <vector>
+#include "sound_impl.hxx"
 #include "sound.hxx"
 #include <ClanLib/Sound/soundbuffer_session.h>
 
@@ -33,7 +34,7 @@
 
 /** A simple wrapper class around SDL_Mixer, it will init itself
     automatically if a sound is played. */
-class PingusSoundReal : public PingusSound
+class PingusSoundReal : public PingusSoundImpl
 {
 private:
   /** The current music file */
@@ -42,12 +43,14 @@
   /** Music Controller Session */
   CL_SoundBuffer_Session* music_session;
 
+       /** Sound Output object */
+       CL_SoundOutput* sound_output;
+
 public:
   PingusSoundReal ();
   virtual ~PingusSoundReal ();
 
   /** Load a music file and play it immediately.
-
       @param filename The complete filename
       @param volume   The volume to play the music with  */
   virtual void real_play_music(const std::string & filename, float volume);
@@ -55,11 +58,9 @@
   virtual void real_stop_music();
 
   /** Load a sound file and play it immediately
-
       @param filename The complete filename
       @param volume   The volume to play the sound at
       @param panning  The panning to play the sound with */
-
   virtual void real_play_sound(const std::string & filename, float volume, 
float panning);
 
 private:

Modified: trunk/src/world.cxx
===================================================================
--- trunk/src/world.cxx 2005-11-02 07:41:22 UTC (rev 2477)
+++ trunk/src/world.cxx 2005-11-03 11:57:28 UTC (rev 2478)
@@ -107,7 +107,14 @@
   for (WorldObjIter it = world_obj.begin(); it != world_obj.end(); ++it) {
     delete *it;
   }
-
+       delete pingu_particle_holder;
+       delete rain_particle_holder;
+       delete smoke_particle_holder;
+       delete snow_particle_holder;
+       delete pingus;
+       delete action_holder;
+       delete colmap;
+       delete gfx_map;
   delete game_time;
 }
 





reply via email to

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