Fwd: Really puzzling ExtAudioFileRead crash...
Fwd: Really puzzling ExtAudioFileRead crash...
- Subject: Fwd: Really puzzling ExtAudioFileRead crash...
- From: Adrian Pflugshaupt <email@hidden>
- Date: Mon, 7 Jan 2008 11:13:29 +0100
Hi all,
I'm currently doing the (almost) same thing and in my opinion the
problem is how you set up the buffer list.
I think you need to use two buffers, not one buffer with two channels.
I changed a section in your code to this and then the crash was gone:
bufList.mNumberBuffers = 2;
bufList.mBuffers[0].mNumberChannels = 1; //extAFNumChannels; // Always
2 channels in this example
bufList.mBuffers[0].mData = data; // data is a pointer (float*) to our
sample buffer
bufList.mBuffers[0].mDataByteSize = samples * sizeof(float);
bufList.mBuffers[1].mNumberChannels = 1; //extAFNumChannels; // Always
2 channels in this example
bufList.mBuffers[1].mData = data + kSegmentSize/2; // data is a
pointer (float*) to our sample buffer
bufList.mBuffers[1].mDataByteSize = samples * sizeof(float);
I had lots of crashes as well initially, but then I switched over to
using all the CA... classes which make my life a lot easier and they
use the ExtAudioFile calls internally. The whole thing then just
becomes:
CAAudioFile audioFile;
audioFile.Open("/test.mp3");
CAStreamBasicDescription format = audioFile.GetFileDataFormat();
format.SetCanonical(format.NumberChannels(), false);
audioFile.SetClientFormat(format);
UInt32 numSamples = 512;
AUOutputBL outputBuffer(format, numSamples);
outputBuffer.Allocate(numSamples);
outputBuffer.Prepare();
audioFile.Read(numSamples, outputBuffer.ABL());
// Then the actual samples can be accessed this way (for a stereo file)
void* channel0data = outputBuffer.ABL()->mBuffers[0].mData;
void* channel1data = outputBuffer.ABL()->mBuffers[1].mData;
Best Regards,
Adrian Pflugshaupt (apulSoft)
On Jan 4, 2008, at 10:37 AM, Stephan M. Bernsee wrote:
Hi all,
I have spent the past few hours trying to figure out what I am doing
wrong in the below piece of code. Basically, I am trying to read an
MP3 audio file using the ExtAudioFile API and convert it to Float32
for further processing. I am compiling the code with Xcode 3 on a
PPC Mac running 10.5.1 and I am experiencing some very strange
crashes. The same code worked flawlessly on Tiger, so it must be
something in Leopard that causes it to behave like this. The thing
is that if I read uncompressed AIFF or WAVE files the code works
fine, but as soon as I am trying to read a file in MP3 format the
code works for a little over 26 seconds into the file, and then
crashes inside the ExtAudioFileRead() method. I have no clue
whatsoever what I might be doing wrong here, as everything looks ok
to me. Also, I would expect the code to either crash or work, and
not crash after 26 seconds of play time...
In oder to make sure it's not some threading issue in my project
that is causing this I have isolated the code and created a separate
project to test this with, and the problem still persists. So,
before I go ahead and file an official bug report (and risk making a
fool of myself in the process because I might have overlooked
something ;-) ) I am seeking your expert advice in order to find out
if there is something I am missing, or if this is indeed a bug in
ExtAudioFileRead(). (..)
_______________________________________________
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