Archived

This topic is now archived and is closed to further replies.

BradDaBug

sdl_mixer trouble

Recommended Posts

BradDaBug    913
Occasionally, my game will crash when I use Mix_SetPanning(). I see no pattern of when it''s crashing, and i''ve checked all the data I''ve been giving it, and its all ok. It just crashes either sometime during or after the mixed audio plays. This is my code that finds a free channel, mixes it, and plays sound over it: for (int index = 0; index < 50; index++) { if (!Mix_Playing(index)) { printf("panning... pan = %d, channel = %d", Pan, index); if (!Mix_SetPanning(index, 255 - Pan, Pan)) { printf("ERROR = %s", Mix_GetError()); } printf("playing..."); Mix_PlayChannel(index, data, 0); break; } } This code is inside my little CSound class, which holds Pan and data. Pan is just a byte and data is a pointer to a Mix_Chunk i think it''s called. When it crashes, it doesn''t blame my game but SDL.dll. Any ideas?? Why''s it crashing?

Share this post


Link to post
Share on other sites
BradDaBug    913
After some more testing, i found out that if I loop from 0 to 12 instead of 0 to 49, it doesn''t crash.

Maybe it only has channels 0 to 12 as a default? But why would it crash? Shouldn''t something tell me "hey! that channel doesn''t exist!" or something like that?

Share this post


Link to post
Share on other sites
Kylotan    9997
I believe there are only 8 channels by default. (This is explained in The Docs, although it''s well hidden.) Unless you set it to something else.

Secondly, if you pass -1 as the channel to Mix_PlayChannel, it automatically picks the first free unreserved channel for you. Maybe that is what you want.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]

Share this post


Link to post
Share on other sites