Re: Audio progressive download
Re: Audio progressive download
- Subject: Re: Audio progressive download
- From: "Stephen F. Booth" <email@hidden>
- Date: Sat, 7 Aug 2010 08:35:21 -0700
I'm using Matt Gallagher's audio streamer on my radio app. How may I do progressive download?
Tried this:
length = CFReadStreamRead(stream, bytes, kAQDefaultBufSize);
if(!data)
data =[[NSMutableData alloc] initWithLength:0];
[data appendData:[NSData dataWithBytes:bytes length:kAQDefaultBufSize]];
Now I can save the audio data using writeToFile:atomically: NSData
method, but the audio won't play. Also, if I try to load it on a
AVAudioPlayer, I get an error.
Are you sure CFReadStream is returning a valid result? You are appending kAQDefaultBufSize bytes to your data without checking the return value. I think you want to add some expanded error handling (I'm guessing without seeing the rest of your code):
if(nil == data)
data = "" alloc] init];
// assume stream has bytes available to read
length = CFReadStreamRead(stream, bytes, kAQDefaultBufSize);
if(-1 == length)
// handle error
else if(0 == length)
// handle EOS
else
[data appendBytes:bytes length:length];
Stephen
_______________________________________________
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