Browse Source

Added method to remove loaded sound

Thomas Buck 10 years ago
parent
commit
b3f067cf83
2 changed files with 18 additions and 0 deletions
  1. 6
    0
      include/Sound.h
  2. 12
    0
      src/Sound.cpp

+ 6
- 0
include/Sound.h View File

76
     int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
76
     int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
77
 
77
 
78
     /*!
78
     /*!
79
+     * \brief Remove a loaded sound
80
+     * \param source valid source id
81
+     */
82
+    void remove(int source);
83
+
84
+    /*!
79
      * \brief Play sound source
85
      * \brief Play sound source
80
      * \param source sound source to play
86
      * \param source sound source to play
81
      */
87
      */

+ 12
- 0
src/Sound.cpp View File

229
 }
229
 }
230
 
230
 
231
 
231
 
232
+void Sound::remove(int source) {
233
+    assert(source >= 0);
234
+    assert(source < mNext);
235
+
236
+    alDeleteSources(1, &mSource[source]);
237
+    alDeleteBuffers(1, &mBuffer[source]);
238
+
239
+    if (source == (mNext - 1))
240
+        mNext--;
241
+}
242
+
243
+
232
 void Sound::play(int source)
244
 void Sound::play(int source)
233
 {
245
 {
234
     assert(mInit == true);
246
     assert(mInit == true);

Loading…
Cancel
Save