Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-20-2008, 12:42 PM   #1 (permalink)
PKMousie
Code Monkey
 
Join Date: Aug 2008
Location: San Jose
Posts: 8
Default Can't play more than one compressed sample on the iPhone itself

I'm writing an app that needs to play a variety of audio samples of different lengths back to back, but only one at a time. The system I came up with works great when using WAV files or whenever running on the simulator no matter what audio type, but on the iPhone itself the logic breaks if I use a compressed audio format like MP3 or AAC. I don't want to ship 5MB of audio when it could be 500K, so this is a serious problem for me!

I think the bugs have to do with the iPhone's hardware acceleration for compressed audio, and certain playback behaviors changing in this context, but I'm not positive.

Basically, I have a list of 18 samples. I load each into it's own queueable object with it's own queue reference and buffers. If nothing is playing, I pick the first object randomly and play it, wait for it's queue's isRunning property to go false, then play the next sample upon completion. Fine, right?

However, when using MP3s, the first sample I play works just fine, but all the other sounds fail to play, stopping immediately (messing up my event logic). Interestingly, when I loop all the way back around to the original sample, it plays again just fine! It doesn't matter which file I play first... the first file always works great, but appears to block the output of all the other sounds that come later, even though it can be correctly played again itself.

The return codes for all of my AudioQueue calls are 0, even when the audio for a sample doesn't play, and I see a reasonable number of buffering messages as if it's reading and enqueueing each and every file correctly. I'm even flushing the object's queue before calling stop, and resetting the object's queue after the 'isRunning' property goes false, to no avail.

Can anybody describe the magic incantation that allows multiple compressed audio files to be played through the AudioQueue engine, one at a time, without them blocking each other's output? Am I missing something simple?

Help!
PKMousie is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,837
Threads: 89,209
Posts: 380,644
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mba_ed2
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.