Go Back   iPhone Dev SDK Forum

Featured Member Applications

TanZen ($0.99)

Endless Walls ($0.99)

Air Hockey ($0.99)

SUPER STRIKE - Motion Bowl ($0.99)

BarSlot ($0.99)

MeterRead ($0.99)

Colorblind Helper ($4.99)

gContacts ($1.99)

ProgCalc ($1.99)

Forex On The Go Lite (FREE)

HUE knewit! ($0.99)

Want your application to be advertised here?

» Advertisements


Visit our friends over at The App Show! Steve and Dave produce a weekly show shining a light on the iPhone 2.0 software and the applications being developed by the amazing development community for the iPhone SDK!
» Online Users: 91
12 members and 79 guests
Akemim, audibles, backwardselvis, FetaBoy, futurejones, jclardy, jeff_lamarche, noobAppDeveloper, SkylarEC, smith288, wuf810, zword
Most users ever online was 207, 10-24-2008 at 09:29 AM.
» Stats
Members: 3,917
Threads: 5,628
Posts: 23,290
Top Poster: scottiphone (705)
Welcome to our newest member, mef
Thread: Mp3 Playback
View Single Post
Old 08-20-2008, 01:08 PM   #10 (permalink)
PKMousie
Code Monkey
 
Join Date: Aug 2008
Location: San Jose
Posts: 7
Default

I know the answer for you, I think! But I can only get you so far... since even though I can now play MP3 files perfectly on the simulator, I'm still having trouble getting them to behave correctly on the phone. But I CAN get at least one to play on the phone itself... so I know I'm 99% of the way there.

The SpeakHere sample (which I used as well, leading to much frustration) leaves out a hugely important piece of code. You need to manually allocate the package decriptions for VBR content... and AAC/MP3 files are always considered VBR even if they're encoded CBR!!! Here's the test and allocation:

Code:
// Test for VBR format files, which need extra initialization

if (audioFormat.mBytesPerPacket == 0 || audioFormat.mFramesPerPacket == 0) { 
    packetDescriptions = (AudioStreamPacketDescription*)malloc(
        numPacketsToRead * sizeof(AudioStreamPacketDescription) 
    ); 
} else { 
    packetDescriptions = NULL; 
}
Just stick a version of this somewhere in your code, after you've loaded the audio format information and calculated your packets to read and buffer sizes, but before you read and enqueue the data. It's all spelled out in the documentation, but it's easy to miss or think you don't need it (like I did). Once I added this allocation step, MP3s play just fine in the simulator! Woo!

Audio Queue Services Guide - Set Sizes for a Playback Audio Queue

I hope this helps, or helps anyone else who stumbles across your post when trying to figure this stuff out like I did!

And maybe now someone else can help me with my problem!
PKMousie is offline   Reply With Quote
 
Powered by vBadvanced CMPS v3.0.1

All times are GMT -5. The time now is 08:01 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.