Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes when using SDL.OpenAudio directly #1

Open
jacius opened this issue Jan 28, 2011 · 0 comments
Open

Crashes when using SDL.OpenAudio directly #1

jacius opened this issue Jan 28, 2011 · 0 comments
Labels

Comments

@jacius
Copy link
Member

jacius commented Jan 28, 2011

(Copied from jacius#1, originally reported by rhp in November 2009)

Hi,

I am trying to set-up a program in which I use SDL to play some sound from a pre-loaded buffer.
Using the callback method for OpenAudio gives me some trouble: it crashes after running through a few loops of the callback method.

See this example:

#! /usr/bin/ruby -w

require 'rubygems'
require 'ruby-sdl-ffi'

SDL.Init(SDL::INIT_AUDIO)

spec = 
    SDL::AudioSpec.new(
        :freq => 22100,
        :format => SDL::AUDIO_S16,
        :channels => 2,
        :silence => 0,
        :samples => 512,
        :padding => 0,
        :size => 0,
        :userdata => nil,
        :callback => Proc.new { |unused, stream, len|
            p stream
            p len
        }
    )

raise "Could not open SDL audio" if SDL.OpenAudio(spec, nil) < 0

SDL.PauseAudio(0)

loop do
    SDL.PollEvent do |event|
        case event
            when SDL::QuitEvent
                exit(0)
            else
                # Do nothing
        end
    end
end

Comments from the original issue:

  • rhp November 15, 2009
    Auch... that didn't go entirely right...
    But I think you get the point...
    (ed: referring to broken formatting in the original post)

  • jacius November 29, 2009
    Hi. This library is still very young, so things are expected not to work. Thanks for the report though, I'll be sure to fix it in the future.

    As a workaround until this is fixed, I would suggest using SDL::Mixer::OpenAudio instead, if you don't need all the advanced AudioSpec stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant