Re: Streaming Audio - AudioFileStream, CFReadStreamRead and AudioQueue
Re: Streaming Audio - AudioFileStream, CFReadStreamRead and AudioQueue
- Subject: Re: Streaming Audio - AudioFileStream, CFReadStreamRead and AudioQueue
- From: Jens Alfke <email@hidden>
- Date: Wed, 30 Jul 2008 22:35:20 -0700
On 30 Jul '08, at 4:34 AM, Adam Fox wrote: I then open a data stream to a URL of an MP3 stream..
[code] NSURL *url = "" URLWithString:@"http://mp3stream.com"]; CFHTTPMessageRef message = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), (CFURLRef)url, kCFHTTPVersion1_1);
It would be better to use NSURLConnection instead. It's a higher-level (and OOP) API, and it also handles things like redirects and authentication for you.
..here I try and allocate the stream packets into the an AudioQueueBuffer and force that buffer into the AudioQueue callback..
Hm, that's not the approach I use. I have a fixed ring of buffers for my queue, and I fill the next buffer with packets when the queue calls me back. I have a secondary buffer where I store the packets read from the stream until they go into the queue.
Your approach might work; but you need to be careful to dispose all the buffers you create after they've been played, else you're leaking memory. I think you can dispose each buffer that the queue's callback gives you, since that callback occurs after the queue has finished playing that buffer.
—Jens |
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden