Jump to content
Eternal Lands Official Forums
bluap

Make Sound / No sound option live

Recommended Posts

I often start the client with sound disabled and want it enabled, and visa versa. What would be nice would be for the change to immediately take effect, without restarting the client. I've been hacking my copy of the client built from CVS and have this almost working. Would such a patch be accepted? Is someone in particular responsible for the sound code, sound.c mainly?

 

I note there is a code freeze coming in a day or so. I am unlikely to be able to submit a patch before that unfortunately.

Share this post


Link to post
Share on other sites

I'd love to be able to turn the sound/music on/off in the game without restarting it! So, even if it can't go in this update, please work on it for another update :blush:

Share this post


Link to post
Share on other sites

I'd love to be able to turn the sound/music on/off in the game without restarting it! So, even if it can't go in this update, please work on it for another update :D

Agreed. It would also make my sound debugging a bit easier. :)

Share this post


Link to post
Share on other sites

it should be easy enough to do... once I get home I'll see about making that change (yeah, it would be handy)

while I'm at it, should i add an option to turn music on/off? (currently you can either remove all music files or put music volume to 0... which doesn't stop it playing)

Share this post


Link to post
Share on other sites
while I'm at it, should i add an option to turn music on/off?

Yes please. That would be very handy.

 

Shame the sound.c file is changing so much. :-S

Share this post


Link to post
Share on other sites

okay, both are now in CVS. don't expect music to go back to the start if you turn it off and then on again... it's more of a pause. but both work

Share this post


Link to post
Share on other sites

Does this feature require some define to work? I've just got a fresh CVS, built it and get something like this:

 

If during load:

 

no_sound == 0, no_music == 1, -> sounds play (checkbox unchecked), music plays (checkbox checked)

 

If during load:

 

no_sound == 1, no_music == 0 -> sounds doesn't play (checkbox checked), music doesn't play (checkbox unchecked), changing options in Audio panel does not seem to start neither sounds nor music

 

If both sounds and music are enabled at load time, they work fine.

 

It looks like the sound system is still dependant on no_sound setting during load time... at least for my build. :P

Share this post


Link to post
Share on other sites
If both sounds and music are enabled at load time, they work fine.
d'oh. okay, I think I know what the problem is. the initialisation not being called if it's loaded with them off.

I'll go fix that now, thanks

ed: should be all better now... if it wasn't initialised when you try to turn sound on, it gets initialised then

Edited by ttlanhil

Share this post


Link to post
Share on other sites

Thanks for providing a patch so quickly. However, the patch I've been working on is a bit different. I want to use the audio device for other things once I've switched off game sound. Therefore, my patch frees the audio device when sound is turned off and attempts to grab it as before when turned on.

 

Also, a side effect of your patch is that now, even if you start the client with sound turned off, it still grabs the audio device. I therefore have to start my other audio app before el and grab the device first. Previous to your or my patch, if I was already using the sound device when I started el and sound was enabled, I had all kinds of lag issues. My patch only grabs the sound device when sound is turned on.

 

I'm not trying to compete here, just get the best solution to the issue as I saw it :)

Share this post


Link to post
Share on other sites
Therefore, my patch frees the audio device when sound is turned off and attempts to grab it as before when turned on.
well, that means EL might not be able to get sound access back again later. plus most people don't have EL play directly to /dev/dsp, etc...
Also, a side effect of your patch is that now, even if you start the client with sound turned off, it still grabs the audio device.
really? does it set the music option on, even if sounds is off, perhaps? it shouldn't grab the sound device until sound or music is enabled

Share this post


Link to post
Share on other sites
well, that means EL might not be able to get sound access back again later. plus most people don't have EL play directly to /dev/dsp, etc...

EL can have the device when I've finished with it and want game audio back. I'd love to know how to specify some other device, I've hunted high and low for such an option but can't find it.

 

really? does it set the music option on, even if sounds is off, perhaps? it shouldn't grab the sound device until sound or music is enabled

No sound is produced but it grabs the audio device, so I'm now worse off :whistle:

Share this post


Link to post
Share on other sites
I'd love to know how to specify some other device, I've hunted high and low for such an option but can't find it.
well, look into the OpenAL documentation, probably in initialisation, but don't expect much
No sound is produced but it grabs the audio device, so I'm now worse off :whistle:
odd... check config, if either sound or music is turned on, then it will have started up

Share this post


Link to post
Share on other sites
odd... check config, if either sound or music is turned on, then it will have started up

config has #no_music = 1 and #no_sound = 1

toggle_sounds() and toggle_music() are both called during initialisation to set there initial values of 1. The call to toggle_sounds() then calls init_sound() which grabs the audio device. I think you need to check if the result of the toggle will be to turn sound off, then don't call init_sound(). Could be very wrong though....

Share this post


Link to post
Share on other sites
I think you need to check if the result of the toggle will be to turn sound off, then don't call init_sound()
sounds right to me. d'oh. this was a bit more complicated than i thought... oh well, it should be all fixed now (as in, in CVS)

here's hoping that, apart from not releasing audio when not playing, it does what people want :)

Share this post


Link to post
Share on other sites

One more issue I'm affraid :devlish:

 

If you start with music disabled, turning it on does not work. I think its because the music thread exits on startup as music is off and is never started again. I moved the music thread initialisation/closure into the init_sound() and destroy)sound() functions and that worked fine.

Share this post


Link to post
Share on other sites

I have a similar issue. If I start with sound and music disabled by configuration, I can enable sound in game by clicking on music :confused: or sound checkboxes but I it won't enable music. If I start with either sound or music enabled (having the second option disabled) by configuration, both sound and music are enabled in game :)

 

I've tested toggling these options in previous version of sound.c and they did worked.

Share this post


Link to post
Share on other sites
while I'm at it, should i add an option to turn music on/off?

Yes please. That would be very handy.

 

Shame the sound.c file is changing so much. :-S

Yeah, that'll be akward to integrate new changes against! So who else is working on sound and what are they doing - you might want to see the thread about testing my changes so you can see how different it's becoming...

Share this post


Link to post
Share on other sites
Shame the sound.c file is changing so much. :-S
Yeah, that'll be akward to integrate new changes against! So who else is working on sound and what are they doing - you might want to see the thread about testing my changes so you can see how different it's becoming...

I have merged the changes that ttl has made with your patch, but I haven't completely tested it as I don't know your code very well. If you could maintain your patch it would be appreciated. I'll post more in that thread.

 

 

/edit: Typos. :-S

Edited by Torg

Share this post


Link to post
Share on other sites

Thank you, ttl, for this great patch. Now the sound device is captured whenever I launch my client, and never released. Even with sound disabled.

 

Edit: It was because music wasn't disabled. Why isn't music disabled when sound is disabled? I always thought music was sound.

Edited by Vegar

Share this post


Link to post
Share on other sites
Edit: It was because music wasn't disabled. Why isn't music disabled when sound is disabled? I always thought music was sound.
sound = sound effects, not all audio

Share this post


Link to post
Share on other sites
Edit: It was because music wasn't disabled. Why isn't music disabled when sound is disabled? I always thought music was sound.
sound = sound effects, not all audio

Can't it dynamically release the audio device like bluap originally id it? (if it doesn't already). It is EXTREMELY annoying to load the client then open mplayer/xmms and have to restart EL because of this.

Share this post


Link to post
Share on other sites
Can't it dynamically release the audio device
I've made a patch to do this; when both sound (effects) and music are turned off it should release the audio device; when either is turned on it'll grab it again... unfortunately that's hard to test in win, so I'm getting help making sure it all works. if all is well, the changes will be committed

in the meantime, the patch is here: http://users.on.net/~gingerman/sound_fix.patch

anyone who compiles CVS, especially on *nix, is welcome to try it out and see if there are any issues remaining (but if there is a problem, check if I've updated the patch since... and if it's not there anymore then all was well and it got put in)

Edited by ttlanhil

Share this post


Link to post
Share on other sites

in the meantime, the patch is here: http://users.on.net/~gingerman/sound_fix.patch

anyone who compiles CVS, especially on *nix, is welcome to try it out and see if there are any issues remaining (but if there is a problem, check if I've updated the patch since... and if it's not there anymore then all was well and it got put in)

Sorry for not replying to this earlier but I've been away from home for a few days without Internet access!

 

Thanks again for continuing to work on this. I've removed all my code changes (and make defs) and updated against the latest CVS as of just now, then applied your patch (using "patch < sound_fix.patch" which I hope was correct). Here is what I have found.

 

1) Starting with both options disabled. My sound dev is free and all is well.

 

2) If I enable both, the sound dev is grabbed and the music starts. Great, though sometimes I have to change location before the music starts.

 

3) If however, I turn both options off again, the client hangs for a few seconds (up to about 20) before continuing as normal with the sound dev now free again. When messing with my changes I found this behaviour related to stopping the music thread.

 

4) Switching both options on again, we are back to state 2.

 

5) Going for broke, if I switch both options off again, I get the delay for a few seconds then the client crashes with the following debug output to my terminal:

 

mutex 0x8fe08a0 busy

el.x86.linux.bin: mutex/posixmutex.c:38: Posix_DestroyMutex: Assertion `0' failed.

toggle_music(): turning sound ontoggle_music(): turning music ontoggle_music(): turning sound offtoggle_music(): turning music offtoggle_music(): turning sound ontoggle_music(): turning music ontoggle_music(): turning sound offtoggle_music(): turning music offAborted

 

gdb revels:

(gdb) where

#0 0xb7a717c7 in raise () from /lib/tls/libc.so.6

#1 0xb7a7306b in abort () from /lib/tls/libc.so.6

#2 0xb7a6a735 in __assert_fail () from /lib/tls/libc.so.6

#3 0xb7d06795 in Posix_DestroyMutex () from /usr/lib/libopenal.so.0

#4 0xb7cef3a8 in _alDestroyMixer () from /usr/lib/libopenal.so.0

#5 0xb7cec808 in _alExit () from /usr/lib/libopenal.so.0

#6 0xb7d06afd in alcDestroyContext () from /usr/lib/libopenal.so.0

#7 0x080adeb5 in destroy_sound () at sound.c:910

#8 0x080ad7af in turn_music_off () at sound.c:745

#9 0x080ad770 in toggle_music (var=0x80d7ae4) at sound.c:734

#10 0x0807483c in onclick_label_handler (widget=0x0, mx=92, my=12, flags=67108864)

at elconfig.c:1709

#11 0x080c1018 in widget_handle_click (widget=0xc49fd10, mx=92, my=12, flags=36865)

at widgets.c:492

#12 0x08077a6e in click_in_window (win_id=11, x=140, y=557, flags=67108864)

at elwindows.c:1270

#13 0x08075818 in click_in_windows (mx=140, my=557, flags=67108864) at elwindows.c:133

#14 0x0807a8c6 in HandleEvent (event=0xbf995864) at events.c:208

#15 0x0809349c in start_rendering () at main.c:98

#16 0x08093745 in main (argc=0, argv=0xbf995934) at main.c:227

 

In all cases, for consistency, I toggled the sound option before the music option.

 

I also find that the client hands on exit if music or sound are enabled.

Edited by bluap

Share this post


Link to post
Share on other sites

it has been updated since... now here's the thing. it works fine for me, but I have reports of crashes on other computers...

it'd be appreciated it more people can test it all out and see where bugs may live

(although I'm almost ready to just blame the OpenAL libs for not working to spec, because at least one case looks strongly like that... but I'd prefer it not crashing no matter what)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×