IPhone (SDK 6): AudioQueue still wonky-can't play mp3

I have an mp3 streaming app up and running (sortof).
Initially I set things up in "VBR" mode, which requires supplying packet descriptions for each frame supplied to the queue. That worked (??). Mostly. I was getting some dropouts and other flaky behaviour, but it gave me something to demo.
Note that this is a CBR stream. So then I set up things to handle CBR, which is much simpler.
So I have a call similar to this:
status=AudioQueueEnqueueBuffer(inAQ, inCompleteAQBuffer,0, NULL);
This does not work. My connectLoop is as follows taken from the audio queue example code:
do
loopError=CFRunLoopRunInMode(kCFRunLoopDefaultMode,0.25,false);
}while(!m_myInfo.mDone);
When working, my audio callback routine is regularly called when the queue is ready for more data. When it is not working using the CBR approach the callback is NEVER called. It is as if somewhere along the line it gets gummed up, or is not initialized properly, even though the CBR method is less involved so should be harder to make mistakes.
Is there any gotcha here that is easy to overlook? The format data is retrieved from a call to to AudioFileGetProperty(), also per the example. So in theory, that should be all I need.
Any ideas?

Hi, here is what I have got so far with regards to streaming and playing an MP3..
I hope it helps some people, and I hope some people can help me!
First, I define a custom data structure to hold stuff throughout..
typedef struct {
AudioFileStreamID audioFileStream;
AudioStreamBasicDescription mDataFormat;
AudioQueueRef mQueue;
CFReadStream readStream;
UInt32 mNumPackets;
AudioStreamPacketDescription *mPacketDescs;
} CustomData;
CustomData customData;
I also set up an AudioQueue with a callback..
AudioQueueNewOutput(&customData.mDataFormat,
AudioOutputCallBack,
&customData,
NULL,
kCFRunLoopCommonModes,
0,
&customData.mQueue);
I set up an AudioFileStream..
AudioFileStreamOpen(0,
audioFileStream_Properties,
audioFileStream_Packets,
kAudioFileMP3Type,
&customData.audioFileStream);
..this has call back functions attached when the AudioFileStream receives either stream properties or stream packets..
I then open a data stream to a URL of an MP3 stream..
NSURL *url = [NSURL URLWithString:@"http://mp3stream.com"];
CFHTTPMessageRef message = CFHTTPMessageCreateRequest(kCFAllocatorDefault,
CFSTR("GET"),
(CFURLRef)url,
kCFHTTPVersion1_1);
customData.readStream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, message);
CFOptionFlags events = kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccured | kCFStreamEventEndEncountered;
CFStreamClientContext dataStreamContext = {0, self, NULL, NULL, NULL};
if (CFReadStreamSetClient(customData.readStream, events, readStreamEventCallBack, &dataStreamContext)) {
CFReadStreamScheduleWithRunLoop(customData.readStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
CFReadStreamOpen(customData.readStream);
..this opens a CFReadStream with a call back function that is called on bytes available events, error events and end events..
void readStreamEventCallBack(CFReadStreamRef stream, CFStreamEventType eventType, void *clientcallBackInfo) {
switch(eventType) {
case kCFStreamEventHasBytesAvailable:
UInt8 buf[4096];
CFIndex bytesRead = CFReadStreamRead(stream, buf, 4096);
if (bytesRead > 0) {
AudioFileStreamParseBytes(customData.audioFileStream, bytesRead, buf, 0);
case kCFStreamEventErrorOccurred:
//do stuff
break;
case kCFStreamEventEndOccurred:
//do stuff
break;
So when the CFReadStream reads some bytes it passes them to the AudioFileStream which will in turn call its callback functions when it receives stream properties or stream packets..
In audioFileStream_Properties I attempt to get the dataFormat of the stream..
void audioFileStream_Properties (void *inClientData,
AudioFileStreamID inAudioFileStream,
AudioFileStreamPropertyID inPropertyID,
UInt32 *ioFlags) {
if (inPropertyID == kAudioFileStreamProperty_DataFormat) {
UInt32 size;
AudioFileStreamGetPropertyInfo(inAudioFileStream, inPropertyID, &size, nil)
AudioFileStreamGetProperty(inAudioFileStream, inPropertyID, &size, &customData.mDataFormat);
Most of these function calls return an OSStatus which should be checked for error (!= 0) but I have left them out for now..
Then the AudioFileStream packets..
void audioFileStream_Packets (void *inClientData,
UInt32 inNumberBytes,
UInt32 inNumberPackets,
const void *inInputData,
AudioStreamPacketDescription *inPacketDescs) {
customData.mNumPackets = inNumberPackets;
customData.mPacketDescs = inPacketDescs;
AudioQueueBufferRef outBuffer;
AudioQueueAllocateBuffer(customData.mQueue, inNumberBytes, &outBuffer);
AudioOutputCallBack(&customData, customData.mQueue, outBuffer);
..here I try and allocate the stream packets into the an AudioQueueBuffer and force that buffer into the AudioQueue callback..
static void AudioOutputCallBack(void *inCustomData,
AudioQueueRef outAQ,
AudioQueueBufferRef) {
CustomData *customData = (CustomData*)inCustomData;
AudioQueueEnqueueBuffer(customData->mQueue, outBuffer, (customData->mPacketDescs ? customData->mNumPackets : 0), playState->mPacketDescs);
..Now, I would hope this would be queuing buffers up ready to play! However,
AudioQueueEnqueueBuffer returns error 1718449215 - I am not sure what this means, I am led to believe it might be a dataFormat error
Hope everyone call follow!
Adam
null

Similar Messages

  • Iphone 4 iOS 7.1.1 can't play some songs

    All of a sudden I can't play some songs on my Iphone 4.  I have iOS 7.1.1.  Some of the songs are grayed out and have the download progress square within the circle icon next to them.  Tried syncing with ITunes on my pc but get an error "!" next to the same songs.  ITunes defines this icon to mean that the song could not be found as it may have been deleted or moved.  Anyone have any ideas?

    durrrrr. nevermind. re-installed itunes and it looks good for now.

  • [solved] I can't play MP3 files in JuK

    Hi
    When i try play a mp3 file, with juk, the system says this:
    [zuargo@zuargo-archlinux ~]$ juk
    [zuargo@zuargo-archlinux ~]$ xine is asking to seek behind the end of the data stream
    I have installed xine-phonon and it is uses default.
    I have tried installing gstreamer phonon (with all official of the repository plugins) but I have the same problem... I can't hear anything...
    I have tried installing pulseaudio but... nothing...
    I have tried installing oss but.... nothing
    I have tried erasing the file ~.xine/catalog.cache but... nothing...
    some web pages says solved it issue installing a package called libxine-ffmep but it is not in pacman...
    really I tried many options but I can't solved this problem
    of course, I can play mp3 files in the command line (throughout mpg123) and they sound good...
    sorry for my bad english I speak spanish
    Last edited by zuargo (2009-08-25 02:20:27)

    AdrenalineJunky wrote:
    from everything i'm reading, it seems like that error message is normally associated with xine-ffmpeg being missing...
    phonon-xine depends on xine-lib which depends on ffmpeg, but its probably worth checking to make sure they are installed.
    I have installed xine-lib
    Rasi wrote:Since there doesnt seem to be an obvious solution, simply use the gstreamer backend.
    I have used the gstreamer backend and it not works... I can't hear the mp3 files...
    another idea?

  • Can't play mp3 file through RTP

    I created an server/client application to play remote file through RTP using JMF. However, it works with *.wav and video track of mpg file only, can't work when playing *.mp3 and audio track of mpg file. Do anyone know the reason?

    No any errors.
    I just follow the code sample "AVTransmit2" & "AVReceive2" and change the format.
    I change the format of mpg file audio stream to G723, it works now! So I think I used wrong format, but I found there is only two supported RTP format for mp3 file and it doesn't work for both of them.

  • Can't play mp3 with sonata?

    Hi,
    Just installed Sonata om ny new fresh Arch installation.
    Alsa is configured and I can play the sound test aplay ....wav files...
    But now when im in X I started sonata and I cant ge the application to play my mp3 files?
    I can't even see them?
    And if I browse with Thunar and try run a file using sonata nothing happends...
    So how do I get sonata so show my files, I need a guideanse of that application, and second do one have to config anymore to play mp3 in x?

    Sonata is a python-based interface to MPD. Either install and setup MPD(Music Player Daemon), or use another player(Totem?)
    EDIT: Have fun learning how to use Archlinux, you already learned one thing! Don't give up now.
    ~Sander
    Last edited by Sander Hoksbergen (2009-01-22 20:53:32)

  • Can I play mp3's from Zen Xtra on Winam

    Is it possible to play mp3's from Zen Xtra not by Creative Media Player but by another mp3 player ? The problem is that I play music on parties and I need crossfading that I can't enable in Creative Media Player. Thanx for your answers

    evenstar wrote:
    Got it !!!! Thank you very much for your help :-))))))))))
    Glad to help

  • Can't play MP3's from Finder without Quick Look

    Not really expecting any relevant answers but I might as well try I guess.
    Ok, before:
    __ .mp3
    Center of this icon had a play button, and it was possible to minimize the window while the song played.
    No need for Quick Look or a media player.
    Now:
    Quick look works.
    But as I mentioned, I can't just click a play button in a finder window, as in here with my mouse hovered over the bottom icon.
    I don't understand why the icons are different or how to fix this.

    Ignore the first two, long story. Anyway:
    THEN:
    • Icon had a center Play button.
    • Could play mp3's inside a miminize-able Finder window.
    • No need for media player or Quick Look.
    NOW:
    Those luxuries are now gone.
    Also, Get info shows both icons..
    Mp3's play from here, but unlike Finder, there's no Quick Look to track songs when necessary.
    • This is an external drive.
    • Permissions are fine.
    • I always browse in icon view.
    • Opening with QuickTime / VLC does not help.
    I just want to know a fix without a 3rd party or Terminal.
    This happened before and went away.

  • Media Player - can't play MP3 files

    I'm have trouble playing my MP3 files on Q10. (Car doesn't support Bluetooth music - only voice commands, hands free calling).
    My MP3 files are stored on micro 8gb card - when connecting USB cable phone tells me it "can't connect to my computer(?)"
    The USB connection DID work when I realised my 'Phone book was empty'. On voice commanding the settings to install Phone book (which it did) I am back to the 'unable to connect to computer ' message. Are these two events linked?
    What's going on?!
    My old Blackberry Torch with card only (No SIM - 'cos it's in my new phone) plays MP3 files fine - but I want my Q10 to play the files.
    Help?

    Thank you for your answer. My problem is with a direct link, [http://www.vocacionpasionista.com/Novedades/Un%20deseo%20de%20paz.mp3 this one] .
    The data URI seemed to work but just while it's loading, when the page loads the player disappears.
    The direct link doesn't work at all, just like with mine, that window pops up.

  • N91 8GB CAN NOT PLAY MP3 FORMAT?!!!

    HEEL.MY N91 8GB CAN ONLY PLAYWMA FORMAT.I RESEAT MY PHONE BUT IT CAN`T PLAY.WHAT AM I DOING????

    What message do you get when you try to play MP3?
    what's the bitrate of this Mp3?, it should be less than 300kbps otherwise it may not play.
    Is it a variable bitrate or constant bitrate MP3?
    What type of metadata does it have, some metadata formats are not supported.
    640K Should be enough for everybody
    El_Loco Nokia Video Blog

  • [iPhone SDK] Using audioQueue automatically stops music player.

    Hi,
    This is a PR I recently submitted.
    +Using the audioQueue in an SDK application automatically stops the music player.+
    +STEPS TO REPRODUCE+
    +On the device :+
    +Play a tune in the music application.+
    +Launch the LunarLander sample+
    RESULTS
    +The music is stopped.+
    NOTES
    +I use the Audio Queue to generate different tones (sin waves) in my program (reacting to touch screen presses).+
    +As far as i understood, only the audio queue can let me do that.+
    +I want those sound effects to be in parallel to the music, if the user did not choose to stop the music by himself.+
    +At least, the stop of the music play should be explicit when using the audio queue SDK (i cannot find a way to do it).+
    My PR was closed because it 'Behaves correctly' with the following comment :
    +We want people to use AudioSession (to behave better when an incoming call is rejected), so they can set it how they want it.+
    +If you look at the AudioSession API <AudioToolbox/AudioServices.h> we recommend setting your category as "ambient" and this will:+
    +(1) Mean you can't use formats like MP3 or AAC+
    +(2) Means that the iPod will be able to play in the background+
    Since i cannot find a way do discuss with the resolver of my PR (other than submitting a new equivalent PR), I hope that someone here will be able to help.
    I cannot find any "Audio Session" API that would allow me to feed some sound data (to play a specific sine tone effect) while the user touches the screen.
    The only API I can find (other than the ones for Audio Queue and Open-AL) is dedicated to play files (as it is used to play short sound effects).
    Moreover, when I look, as suggested, at the <AudioToolbox/AudioServices.h> file, I cannot find anything related to "category" nor "ambient".
    Could this be a problem of the current beta ?
    Does anyone know a way to generate (on the fly) some sound effect while keeping the (iPod) music played ?

    Thank you for the reply. The podcasts i was referring to are audio only. I checked the video app and it is blank.
    New information: The last day of podcast downloads that worked properly was 6/13. I was able to find the newer podcast downloads by searching the phone and they will play in the music player when selected in the search results. They still don't show up on the music player's list of podcasts and they won't play sequentially. It's like the music player refuses to acknowledge the existence of any podcast after 6/13.

  • [iPhone SDK Beta 6] Simulator only can't find Frameworks

    I'm scratching my head on this one. I can load an example project and it runs in the simulator, no problem. My own project, however gives me this:
    warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
    and something similar for every other linked framework. Eventually, this leads to nothing working and the app quitting out. Works fine on the device, and again, it works with the example projects, so the files aren't actually missing or misplaced.
    Instead it seems like something in my build settings or a similar problem. The rub is that I've gone through every build setting and parameter of a working example project line by line to make sure they match, but my project still won't compile in the simulator.
    The only caveat is that I'm not using a .nib or .xib file as all the examples are transitioning to now. I don't see how that's relevant in the smallest way, however.
    Can anyone with more experience or knowledge about XCode projects give me some insight to what I might be missing? It's driving me a little insane.

    Well, I really don't know what the problem was specifically, but I narrowed it down to drawing the render buffer from OpenGL. It seems that, only on the simulator, if I do this too quickly after the window is created and all that it causes the problem.
    The console results were weird talking about missing frameworks which seems completely unrelated to what problems were happening.
    So... no help to anyone else I guess, but I completely rebuilt the project restructured my program like the demos with a nib and everything and it still turns out it had nothing to do with that. I was able to fix my original with one line commented out. 2 days for one line. weeee.
    Message was edited by: aaronsullivan

  • My iPhone 4 (iOS 4.3.5) can't play my protected AAC  Audio files

    When i try playing an older song i have purchased in iTunes, of the "protected AAC audio file" type, my iPhone just skips it. And this is on both my new acount and my old acount. I made two playlist to test this issue, and the older "protected" files does not work, but all the new "purchased" files work fine.
    I should think this is a software problem, and more people are experiencing this, but i couldn't find any ohter threads with this issue...
    HELP! I want to listen to the Johnny Cash album i purchased in 2006...

    five computers... not devices!?
    anyhooo, i de-authorized all devices for that acount and re authorized, then tried syncing again... no result!

  • IPHONE 4 -  VGA Adapter for monitor can it play downloaded videos

    purchased VGA Adapter to playback music video from tubeplayer APP ( youtube) ON A COMPUTER MONITOR / Played back photo video and Photo as slide show but not videos

    the app have to support the old type of tvout that the iphone4 supports
    since then they use airplay mirror which the apps don't have to do anything extra to support
    so guess many app makers removed the feature from their apps

  • How can I play MP3 files with time capsule on a stereo set?

    Hello,
    Can anyone offer ideas/suggestions how to play my mp3 files (itunes) from a Time Capsule device? I use a plain Philip 5.1dts set. I would like to be able to select music with either my iphone, ipad ir macbook.
    thanks, Anton

    You will need to add an Apple - AirPort Express to be able to stream your iTunes data to your amp/speaker setup.

  • How long can you play mp3's/maximum battery life?

    What is the average battery life for a 30 gig, early 5th generation Ipod video? I'm asking as I get about 5 hours using Apples instructions for maximum battery life.

    Usually, the battery life for the original Fifth Generation iPods was approximately 12-15 hours, I think, although I'm not perfectly sure about that estimate.
    Anyways, about 5 horus is not normal for your iPod, and I woulkd suggest that you send your iPod in for service (if it is still under warranty).
    To arrange an iPod service request, see here: Placing an iPod service request
    -Kylene

Maybe you are looking for

  • Foreign currency rounding

    Hi, foreign currency rounding. if i make advance payment to vendor 100000 GBP(69), after i booked invoice 150000 GBP(72) then i clear the advance payment 100000 GBP to invoice amount. now i am making final payment to vendor. at the time of 50000 GBP

  • Performance Point Filter Scorecard by Time Dimension (without Time Intelligence)

    Hello, I use Performance Point 2010 and want to build a Performance Point Dashboard with Scorecard. My requirement is to provide a List of Years as a Filter for a Scorecard. In the Scorecard I have a KPI which I want filter by Time Dimension. I can d

  • Join between 2 large tables

    I've got 2 tables: pay_run_results (+/- 35.000.000 records) and XX_PAY_COSTS (25.000.000 records) When in join those table i get an error: ORA-01652: unable to extend temp segment by 128 in tablespace temp1 So i thought the temp space would be to sma

  • Question on using FM  'MASTER_IDOC_DISTRIBUTE'

    Hi guys, I am always recieving an excemption = 2 (error_writing_idoc_status) when using 'MASTER_IDOC_DISTRIBUTE', what would be the problem with my code? thanks in advance! Regards, Mike

  • Flash and FireFox. What's going wrong?

    All of a sudden lately flash plugin won't load, or so says the error message. I have ver. 11.3.300.268. I click update, and it takes me to the plugin update page which says I have the current ver. I know there's a newer ver.. How do I get it?