Re: Performance differences between AudioFileWritePackets() and FSWriteFork()
Re: Performance differences between AudioFileWritePackets() and FSWriteFork()
- Subject: Re: Performance differences between AudioFileWritePackets() and FSWriteFork()
- From: Jeff Moore <email@hidden>
- Date: Tue, 20 Feb 2007 12:04:52 -0800
Sounds to me like you are hitting the system buffer cache in the
FSWriteFork case. I'll bet that the code that uses
AudioFileWritePackets is passing true for the inUseCache argument
while FSWriteFork code is forgetting to or in kFSNoCacheMask to the
mode argument.
One other possiblity is that even with kFSNoCacheMask, the request
might still hit the buffer cache if the buffer being filled doesn't
start on a page boundary or if the position being written to in the
file is not on a page boundary or if the amount being written is not
an even multiple of pages. From what you've said, it doesn't sound
like the last condition is a problem but the first two might be if
you're not careful.
On Feb 20, 2007, at 5:39 AM, Roni Music wrote:
My audio recorder application which is loosely based on the afrecord
example from the AudioFileTools example either uses
AudioFileWritePackets() to write the data
or, when I'm encoding an mp3 file with the Lame mp3, encoder it uses
FSWriteFork().
Everything works fine but when I'm timing the file writes,
AudioFileWritePackets() always takes very little time and always the
same amount but when
using FSWriteFork() now and then (quite seldom) it takes a very long
time, say 100 milliseconds.
I'm always writing chunks that are 4096*4 bytes and the offset in
the file is also always an even multiple of 4096*4 bytes and I have
the noCacheMask set.
From "gooogling" at lot about the best performance for file writes
on OS X this seems to be what should be done.
So my question is, how come that AudioFileWritePackets() works so
good, eventually it also have to write the data to disk with
FSWriteFork()
The writing is done in a secondary thread (as in the afrecord
example) and I'm on OS X 10.4.8 with a Intel iMac, same behavior on
a dual 1 GHz G4.
Any hints for improvements?
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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