Problem opening *some* audiofiles via AudioFileOpenWithCallbacks
Problem opening *some* audiofiles via AudioFileOpenWithCallbacks
- Subject: Problem opening *some* audiofiles via AudioFileOpenWithCallbacks
- From: email@hidden
- Date: Tue, 6 Feb 2007 09:28:31 +0100 (CET)
- Importance: Normal
Hello!
I am holding audio data in an NSData Object, passing it to
AudioFileOpenWithCallbacks to read the audiofile. Afterwards I call:
AudioFileGetProperty(audioFile2, kAudioFilePropertyDataFormat, &propsize,
&fileFormat);
to read the data format. Curiously, this works with many files, but with
some files it fails with the following error:
AudioUnitGetProperty (file format) failed with error -50
This is how I have implemented the ReadAudioFromBuffer method:
xtern OSStatus ReadAudioFromBuffer(void *inRefCon,
SInt64 inPosition,
ByteCount requestCount,
void *buffer,
ByteCount *actualCount)
{
ByteCount requestOffset = inPosition + requestCount;
ByteCount availableBytes = [inRefCon length] - inPosition;
if (requestOffset > [inRefCon length]) {
*actualCount = availableBytes;
} else {
*actualCount = requestCount;
}
[inRefCon getBytes:buffer range:NSMakeRange(inPosition,*actualCount)];
return noErr;
}
You can download the xcode project together with a working and a "broken"
audio file here:
http://www.systemshutdown.de/audiocallbacktest.zip
Thanks for any advice,
Michael
_______________________________________________
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