URL:
  <http://gna.org/bugs/?21426>

                 Summary: Sound sources cannot be removed and escape Wesnoth's
control when the sound volume is set to zero
                 Project: Battle for Wesnoth
            Submitted by: shadowmaster
            Submitted on: Fri 03 Jan 2014 02:12:20 AM CLST
                Category: Bug
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Sound and music
                  Status: In Progress
                 Privacy: Public
             Assigned to: shadowmaster
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.10.x - 1.11.7+dev
        Operating System: Most likely any

    _______________________________________________________

Details:

When the game sound effects volume is set to zero (either by the user in
Preferences → Sound or by the [volume] WML action), the
[remove_sound_source] WML action loses effect and causes any affected playing
(but silenced) sound sources to escape Wesnoth's control.

*Steps to reproduce:*

Insert the following code into data/scenario-test.cfg and run the test
scenario (-t switch in the command-line):


[event]
    name=start

    [sound_source]
        id=campfire_sound_source
        x,y=1,1
        sounds=ambient/campfire.ogg
        # Loop continuously forever
        delay,loop,chance=0,-1,100
        full_range,fade_range={INFINITY},{INFINITY}
        check_fogged,check_shrouded=no,no
    [/sound_source]

    [delay]
        time=250
    [/delay]

    [message]
        speaker=narrator
        message="Sound source created"
    [/message]

    [volume]
        sound=0
    [/volume]

    [remove_sound_source]
        id=campfire_sound_source
    [/remove_sound_source]

    [delay]
        time=250
    [/delay]

    [message]
        speaker=narrator
        message="Sound source deleted"
    [/message]

    [volume]
        sound=100
    [/volume]
[/event]


* A campfire sound source is created prior to displaying the "Sound source
created" message, and deleted afterwards while the sound volume is set to zero
(which means the sound source's channel volume is also set to zero, see
_Observations_ below).
* After the "Sound source deleted" message is displayed, you will hear the
campfire sound again. Furthermore, even if you then load any other scenario,
the campfire sound will continue playing forever.
* Commenting out the [volume] tag that sets the sound volume to zero remedies
this.

This affects both 1.10.x and 1.11.x up to 1.11.7+dev as of this writing, using
SDL 1.2.15 (1.2.15-8) and SDL_mixer 1.2.12 (1.2.12-10) on Debian jessie (Linux
amd64), and SDL 1.2.14 and SDL_mixer 1.2.12 on Windows 7 (x86).

*Observations:*

The problem appears to originate in the sound::reposition_sound() function
called from the soundsource::positional_source class destructor in
soundsource.cpp:135, which is the point at which Wesnoth requests SDL_mixer to
stop the sound source's channel and relinquishes control of it.

Wesnoth performs the request by calling Mix_FadeOutChannel() for the channel
associated to the sound source, with a fade-out interval of 100 milliseconds,
presumably for a smoother effect e.g. when jumping away from a sound source's
effect area by clicking on the minimap.

However, the SDL_mixer library documentation
<http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC36> says:

> int Mix_FadeOutChannel(int channel, int ms)
> [...]
> Gradually fade out which channel over ms milliseconds starting
> from now. The channel will be halted after the fade out is
> completed. Only channels that are playing are set to fade out,
> including paused channels. Any callback set by
> Mix_ChannelFinished will be called when the channel finishes
> fading out. 

It would seem that either the documentation is not correct, or channels that
have their volume set to zero count as not playing. Querying the channel's
volume with Mix_Volume() and using Mix_HaltChannel() (which is not said to
have the same aforementioned catch in the documentation) on the channel if the
volume is zero effectively fixes this issue.




    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?21426>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to