OGG on iPhone

My game requires OGG playback.
I have therefore compiled both libogg and libvorbis as static libraries and linked them with my game. This works on both simulator and iPhone.
The question is actually more generic.
Using OGG seems to be very costly. Encoding an average song of 1.5 minutes is done in like 30 seconds on the iPhone. Currently I'm reading the whole encoded song into a buffer and then submit that to OpenAL. It works, but very slow. The playback is of course fine.

What is the better way to get around this?
Is threading+streaming a good idea or would it be too costly and introduce delay in my rendering/logic updates?

My game requires OGG playback.
I have therefore compiled both libogg and libvorbis as static libraries and linked them with my game. This works on both simulator and iPhone.
The question is actually more generic.
Using OGG seems to be very costly. Encoding an average song of 1.5 minutes is done in like 30 seconds on the iPhone. Currently I'm reading the whole encoded song into a buffer and then submit that to OpenAL. It works, but very slow. The playback is of course fine.

What is the better way to get around this?
Is threading+streaming a good idea or would it be too costly and introduce delay in my rendering/logic updates?

Glad to see OGG works on iPhone. Unfortunately, unless you can get it running through hardware, I don't see the point of using it. The Apple APIs decode compressed music through specialized hardware, which is highly efficient, so it doesn't make any logical sense to be spending CPU cycles on that IMHO.

AnotherJake Wrote:Glad to see OGG works on iPhone. Unfortunately, unless you can get it running through hardware, I don't see the point of using it. The Apple APIs decode compressed music through specialized hardware, which is highly efficient, so it doesn't make any logical sense to be spending CPU cycles on that IMHO.

You are damn right, but can you tell that to my users who cry out stuff like "99% of my music collection for 'the game' is in .ogg format!! what should I do?"?? Personally I wouldn't need ogg since my collection is mostly mp3 and at least I know how to convert from ogg to mp3 if I really need something

I wonder if you could decode little chunks of your OGG files and feed it to Audio Queues during its callback? Or perhaps RemoteIO could be used for that instead. I haven't used RemoteIO for output though, so I don't know how that works, but if it uses a callback to play sequential buffers of audio (like it does for input) then perhaps that might work. You'd still be burning CPU, but it'd be on-the-fly.

Personally I'd consider telling my users to convert their audio if they want to use it on iPhone

AnotherJake Wrote:I wonder if you could decode little chunks of your OGG files and feed it to Audio Queues during its callback? Or perhaps RemoteIO could be used for that instead. I haven't used RemoteIO for output though, so I don't know how that works, but if it uses a callback to play sequential buffers of audio (like it does for input) then perhaps that might work. You'd still be burning CPU, but it'd be on-the-fly.

Personally I'd consider telling my users to convert their audio if they want to use it on iPhone

Well, it's already on-the-fly from what I can see. I stream.. thus I decode little chunks (played with lots of different sizes/buffer counts). The slow part is not Playing the sound... but decoding the sound so I guess it just stops here.
I already wrote a wiki page stating that they must convert and that ogg will work once apple adds support for it.. sad but true.

I was talking about *decoding* it in chunks. You said in your original post that you're decoding the whole thing at once and then uploading it to OpenAL. What I am suggesting is decoding only small parts of it at a time and uploading those to Apple's audio buffers, be they via RemoteIO or Audio Queues.

Doing stream decoding of Vorbis files is not too hard, but again, why bother? AAC and the like is supposedly hardware decompressed. If your users are complaining that they can't use their ogg encoded files with your game, I really have to ask... How are they getting the ogg files into your game in the first place?

I like Vorbis and it's API as much as the next guy, but it doesn't really seem very pragmatic on the iPhone when you can play an MP3 or AAC in hardware using Apple's API in 4 lines of code.

Ahh... at the end I was 'streaming' which means decoding small chunks and then posting them to OpenAL buffers..
I just forgot that my initial post was talking about a full upload.. sorry

Skorche, the game is a DanceDanceRevolution clone and it uses songs/simfiles from StepMania (stepmania.com) which is a great opensourced PC version simulator of DDR.. so instead of creating own format I just take it from the existing game so my users directly have like over 10k songs to play Sad news is that at least 50% of it is in ogg format. That makes me sad.