From 9a692b7b2c5f2d2a9ac7421041a0619d58baa5ef Mon Sep 17 00:00:00 2001
From: jpbl <jpbl>
Date: Thu, 12 Jan 2006 22:31:14 +0000
Subject: [PATCH] cleaned the example03.cpp

---
 src/audio/OpenAL/NullSource.cpp | 37 +++++++++++++++++++++++++++++++++
 src/audio/OpenAL/example03.cpp  | 18 +++++++++-------
 2 files changed, 47 insertions(+), 8 deletions(-)
 create mode 100644 src/audio/OpenAL/NullSource.cpp

diff --git a/src/audio/OpenAL/NullSource.cpp b/src/audio/OpenAL/NullSource.cpp
new file mode 100644
index 0000000000..7bb8862082
--- /dev/null
+++ b/src/audio/OpenAL/NullSource.cpp
@@ -0,0 +1,37 @@
+/*
+ *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
+ *  Author: Jean-Philippe Barrette-LaPierre
+ *             <jean-philippe.barrette-lapierre@savoirfairelinux.com>
+ *
+ *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "NullSource.hpp"
+
+SFLAudio::NullSource::NullSource()
+  : Source(0, 0)
+{}
+
+bool
+SFLAudio::NullSource::isPlaying()
+{return true;}
+
+void
+SFLAudio::NullSource::play(void *, int)
+{}
+
+void
+SFLAudio::NullSource::stop()
+{}
diff --git a/src/audio/OpenAL/example03.cpp b/src/audio/OpenAL/example03.cpp
index 7367b70c20..8465e129cc 100644
--- a/src/audio/OpenAL/example03.cpp
+++ b/src/audio/OpenAL/example03.cpp
@@ -51,8 +51,8 @@ int main(int argc, char* argv[])
   Info *infos = new Info[argc-1];
   ALenum error;
 
+  // Load wav files
   for(int i = 0; i < 2; i++) {
-    // Load test.wav
     alutLoadWAVFile(files[i],
 		    &infos[i].format,
 		    &infos[i].data,
@@ -68,24 +68,26 @@ int main(int argc, char* argv[])
     i++;
   }
 
+  // Start the wav playing.
   for(int i = 0; i < argc - 1; i++) {
     Source *source = context->createSource(infos[i].format, infos[i].freq);
     source->play(&infos[i].data, infos[i].size);
   }
 
+  // Unload wav files
   for(int i = 0; i < argc - 1; i++) {
-    // Unload wav files
     alutUnloadWAV(infos[i].format, 
 		  infos[i].data, 
 		  infos[i].size, 
 		  infos[i].freq);
+    error = alGetError();
+    if (error != AL_NO_ERROR) {
+      std::cerr << "OpenAL: unloadWAV : " << alGetString(error);
+    }
   }
-   
-  std::cin.get();
   
-  error = alGetError();
-  if (error != AL_NO_ERROR) {
-    std::cerr << "OpenAL: unloadWAV : " << alGetString(error);
-  }
+  // Wait for user input.
+  std::cout << "Press any key to quit the program." << std::endl;
+  std::cin.get();
 }
 
-- 
GitLab