mail[Wesnoth-commits] r24694 - /trunk/src/sound.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by grywacz on March 16, 2008 - 11:10:
Author: grzywacz
Date: Sun Mar 16 11:10:41 2008
New Revision: 24694

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24694&view=rev
Log:
Work around for a bug in SDL_mixer that makes the channel finished hook fire 
twice. Fixed a potential problem with channel getting marked as busy even 
before sample was (not) loaded. Removed (buggy) reseting of channel status in 
reposition_sound().

Modified:
    trunk/src/sound.cpp

Modified: trunk/src/sound.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sound.cpp?rev=24694&r1=24693&r2=24694&view=diff
==============================================================================
--- trunk/src/sound.cpp (original)
+++ trunk/src/sound.cpp Sun Mar 16 11:10:41 2008
@@ -671,7 +671,6 @@
                if(ch_id == id) {
                        if(distance >= DISTANCE_SILENT) {
                                Mix_FadeOutChannel(ch, 100);
-                               ch_id = -1;
                        }
                        else {
                                Mix_SetDistance(ch, distance);
@@ -717,15 +716,6 @@
        if(channel == -1) {
                LOG_AUDIO << "All channels dedicated to sound group(" << 
group << ") are busy, skipping.\n";
                return false;
-       }
-       channel_ids[channel] = id;
-
-       /*
-        * This check prevents SDL_Mixer from blowing up on Windows when UI 
sound is played
-        * in response to toggling the checkbox which disables sound.
-        */
-       if(group != SOUND_UI) {
-               Mix_SetDistance(channel, distance);
        }
 
        sound_cache_chunk temp_chunk(file); // search the sound cache on this 
key
@@ -774,6 +764,14 @@
                it = sound_cache.begin();
        }
 
+       /*
+        * This check prevents SDL_Mixer from blowing up on Windows when UI 
sound is played
+        * in response to toggling the checkbox which disables sound.
+        */
+       if(group != SOUND_UI) {
+               Mix_SetDistance(channel, distance);
+       }
+
        int res;
        if(loop_ticks > 0) {
                if(fadein_ticks > 0) {
@@ -792,11 +790,14 @@
                        res = Mix_PlayChannel(channel, it->get_data(), 
repeats);
                }
        }
+
        if(res < 0) {
                ERR_AUDIO << "error playing sound effect: " << Mix_GetError() 
<< "\n";
                //still keep it in the sound cache, in case we want to try 
again later
                return false;
        }
+
+       channel_ids[channel] = id;
 
        //reserve the channel's chunk from being freed, since it is playing
        channel_chunks[res] = it->get_data();




Related Messages


Powered by MHonArc, Updated Sun Mar 16 11:41:04 2008