Forums Archived

The forums are being archived. See this topic for more information.

Autodisable Audio

Get help and support with Rubygame

Autodisable Audio

Postby shevegen » Thu Jul 09, 2009 2:02 pm

lib/ruby/site_ruby/1.8/rubygame/named_resource.rb:105:in `autoload': Could not load Sound file './whiff.wav': No available audio device (Rubygame::SDLError)
lib/ruby/site_ruby/1.8/rubygame/named_resource.rb:105:in `[]'
from chimp.rb:237:in `main'

My sound is broken right now. Is it possible to autodisable audio in case the sound is broken or can not be found? I'd like to just run the samples and dont mind if audio output is not possible

Edit: Nevermind, I just set the two variables to false and now it works. :)

I still wonder how to check for audio output possible?
shevegen
 
Posts: 5
Joined: Sat Feb 07, 2009 3:04 pm

Re: Autodisable Audio

Postby shawn42 » Thu Jul 09, 2009 4:57 pm

Per gamebox's sound_manager.rb:
puts 'Warning, sound disabled' unless
(@enabled = (Rubygame::VERSIONS[:sdl_mixer] != nil))

I think that's what you're looking for. Note, that if your rubygame was compiled with a valid sdl_mixer, then it got broken, I don't this approach will work.

/Shawn
User avatar
shawn42
 
Posts: 109
Joined: Tue Feb 10, 2009 8:22 pm

Re: Autodisable Audio

Postby jacius » Thu Jul 09, 2009 6:15 pm

You could also try this to detect the problem ahead of time:

Code: Select all
sound_works = begin
                Rubygame.open_audio
                true
              rescue Rubygame::SDLError => s
                warn "Audio failed: #{s.message}"
                false
              end

Rubygame.open_audio is not normally needed, since it will do that automatically when you play a sound or music, but it's useful in this case.
User avatar
jacius
Site Admin
 
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm


Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron