sdl_mixer trouble

Started by
2 comments, last by BradDaBug 21 years, 11 months ago
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?
I like the DARK layout!
Advertisement
Maybe you have to do SetPanning AFTER you do PlayChannel? That''s all I can think of really.
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?
I like the DARK layout!
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 ]

This topic is closed to new replies.

Advertisement