PDA

View Full Version : Ogg problem



User137
04-05-2005, 12:25 AM
I have made one unit that wraps openal and ogg loading in nice small packet. Everything works fine, except for minor detail... When i play Ogg during game and have something heavy running background it causes lag that makes ogg play start looping a half second block to infinite. It normalizes when i restart playing the piece...
I have no idea why it starts looping. Here's my play function if it helps:

procedure alPlay(OggStream: TOggStream);
begin
if OggStream<>nil then
with OggStream do begin
Update;
if not playing then Playback;
end;
end;

Btw, do any of you have mp3 loading functions, or is it just old and bad format?

noeska
06-05-2005, 05:59 PM
try using larger buffers and or more buffers. Also does stop play and killing and restart play help? Do share your complete source with the rest of us. Also for small ogg sound you could consider using openal's native ogg play buffer. On torry.net there should be a mp3 player with source. The decoding part is in c and comes compiled in a dll as far as i can remember.

User137
06-05-2005, 10:02 PM
Hey, i see it's your OpenAL page i used as my source :D

From
http://www.noeska.com/doal/tutorials.aspx
i downloaded the OpenAL Ogg Player and copied the whole ogg class as is, then instantiated it on LoadSound function.

But before that i experimented with tutorials, by putting ogg update interval to higher number and it started the same looping.
I don't like the fact that ogg may start looping if playing pauses, say for 10 seconds for some reason...could be cd-rom drive starting spinning, other, well.. it is a serious bug.

I guess increasing buffer helps, but it doesn't sound a long term solution.

Edit: (Assume TOggStream is in use) Is there a way to determine through variables if sound is looping?
One variable i can think of is time indicator. Playing could then be forced to continue, or started over...

Edit2: Experimented a bit with the ogg player sample. I set OGGTimer.Interval=200 where it started looping. I noticed that the seek position was growing all the time, meaning that music should be hearing ok... Then i tried increasing normal BufferSize = 4096*8; to larger, but it complained of Range Check Error. Smaller values didn't complain.

Edit3: Ok, i made fix now that automatically restarts song playing from the start when it goes looping. I used the Playing and Playback return values determing it...and there my game is playing music while i'm writing this 8) Would be better to continue playing instead of restarting, but how?