[SDL] [Need help] Why this code crached?

Igor Mironchick imironchick at gmail.com
Sat Jan 20 14:10:28 PST 2007


2007/1/20, Mike Shal <marfey at gmail.com>:

>
> When I ran it I had several issues:
> 1) main() was in the namespace - I assume this is a copy/paste error


U are righ.

2) SDL_OpenAudio failed - I had to set m_desired_spec.channels before
> it would work for me (since this doesn't stop the program, it later
> crashed in SDL_BuildAudioCVT())


Not sure. I was tested with this parameter. And I never have initialized
this in ctor. Try to do:
std::cout << m_dev_spec.channels << std::endl;
after SDL_OpenAudio()
There is NOTHING!!! (Or this is on my machine only?)

3) The check to see if SDL_BuildAudioCVT() doesn't work (at least in
> SDL1.2.7 - maybe this changed). The man page says it returns 1 on
> success and -1 on error, but it's checking for != 0 to determine an
> error condition.


Where I can read about reasons of craches SDL_BuildAudioCVT()?

4) And I believe this is the main issue: In the audio callback, you
> call SDL_MixAudio with the amount of data left in your wave file. This
> doesn't necessarily fit within the mix buffer (defined by the 'len'
> argument in the callback). I think you want to pass in the min of
> 'waveleft' and 'len' to SDL_MixAudio.


May be.. I fix it. But I still can't play any WAV files. Why? How
audio_callback() calles? Is len  parameter always equal length of the WAV?
Or this is something another?

With those changes I was able to get some sound out.
> -Mike


How I can play all types of WAV files?




-- 
Regards,
Igor Mironchick,
Intervale (c)
#ICQ 492-597-570
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070121/8c64ae52/attachment.htm 


More information about the SDL mailing list