Re: Calling TellListener & AUParameterSet in audio thread
Re: Calling TellListener & AUParameterSet in audio thread
- Subject: Re: Calling TellListener & AUParameterSet in audio thread
- From: Bill Stewart <email@hidden>
- Date: Wed, 19 Mar 2003 11:03:02 -0800
Firstly, I passed this by Doug and his comments were in line with what
I'd have thought:
TellListener should not be called from the audio thread. It's generated
from UI gestures, and thus shouldn't be happening on an audio thread.
AUParameterSet may be called from the audio thread; all it does is call
AudioUnitSetParameter and AUParameterListenerNotify.
Doug
Secondly - yes this is ultimately just a thread of execution - there
are no a priori reasons why you cannot call malloc on the I/O thread -
but there are VERY GOOD REASONS not to - aside from the time involved,
malloc takes locks based on the zone that malloc is operating in, and
thus it is easy if you have alot of UI activity going on elsewhere that
calls you make will malloc, take a lock, then stall your I/O thread.
The stack traces you have below are indicative of precisely this
problem - though why it is crashing is another question - I don't know.
In the situations that we've seen this contention occur on, the I/O
thread (or some other real time thread) just waits until the UI thread
releases the lock, but not crashes.
Bill
On Wednesday, March 19, 2003, at 03:50 AM, Angus F. Hewlett wrote:
Interesting... I've had some similar logs with crashes relating to
mallocs
in the audio thread.
Now, I'm fully aware that memory allocation in an audio thread is a Bad
Thing, but surely in OS X it shouldn't be causing actual crashes? Could
someone point me to a good reference on this stuff?
Attached is the relevant portion of a crash log - thread 0 is a UI
thread
doing a malloc, thread 2 is the audio thread which is also doing a
malloc
(I've since changed the code so that it allocates what it needs - in
fact
only a few bytes - on the stack - but still interested in why it
actually
blows up):-
Thread 0 Crashed:
#0 0x90004be8 in szone_malloc
#1 0x90004a64 in malloc_zone_malloc
#2 0x91937078 in AddRange
#3 0x91932578 in MakePairsList
#4 0x91935bb8 in GetMetricsForGlyphs
#5 0x91933518 in _eLLCLayoutText
#6 0x919391f4 in LLCLayoutText
#7 0x91a6e8ac in
_Z12LayoutGlyphsP14ATSGlyphVectorP23ATSLineLayoutLineParamslP14Attribut
e
Group
#8 0x91a65ea8 in
_Z16ATSULayoutGlyphsP21TATSUGlyphRecordArrayP23ATSLineLayoutLineParamsl
P
7ATSUTabmP9CGContext
#9 0x91a5f198 in
_ZN15TTextLineLayout22EnsureLayoutIsUpToDateEmhPP21TATSUGlyphRecordArra
y
#10 0x91a694c4 in
_ZN15TTextLineLayout14GetGlyphBoundsEmmlltmP12ATSTrapezoidPm
#11 0x91a6b00c in ATSUGetGlyphBounds
#12 0x969b5ae0 in
_ZN15TATSUTextLayout18GetGlyphBoundsRectEmmP6CGRect
#13 0x969c5e90 in _ZN15TATSUTextLayout13LayoutToWidthEfh
#14 0x969bc370 in _ZN15TATSUTextLayout12VerifyLayoutEfh
#15 0x969b0d78 in
_ZN15TATSUTextLayout13GetDimensionsEhmsRK7CGPointPS0_Pf
#16 0x969b55cc in
_ZN10DataEngine22GetThemeTextDimensionsEtRK15TThemeDrawStatePK10__CFStr
i
nghmsfP20OpaqueThemeTextCacheRK7CGPointPS8_Pf
#17 0x969b8cb0 in HIThemeGetTextDimensions
#18 0x969caa88 in GetThemeTextDimensions
#19 0x969e4310 in
_Z12DrawItemTextP22StandardMenuDefGlobalsPK14DrawOneItemRecitPK4RectPS4
_
PsP9CGContext
#20 0x969c88cc in _Z16DrawItemCallbackPK4RectshlPv
#21 0x969c9818 in _Z16DrawMenuItemLoopssPP7GDevicel
#22 0x969c4d1c in
_ZN10DataEngine17DrawThemeMenuItemERK6CGRectS2_ffttP19MenuItemDrawingXU
P
PmmfP9CGContext
#23 0x96a03a2c in HIThemeDrawMenuItem
#24 0x969ea068 in _DrawThemeMenuItemWithCallout
#25 0x969dbdd0 in
_Z11DrawOneItemsssP4RectP13ItemHeightRecP16MenuTrackingDataP22StandardM
e
nuDefGlobalsh
#26 0x969e5464 in _Z22DrawEntireMenuCallbackssPP7GDevicel
#27 0x91a71170 in CommonDeviceLoop
#28 0x96a40f60 in
_Z14DrawEntireMenuP22StandardMenuDefGlobalsP16MenuTrackingData
#29 0x96a5ba38 in _Z13DoDrawMessageP22StandardMenuDefGlobalstt
#30 0x969d4bc4 in _Z12StandardMDEFsP13OpaqueMenuRefP4Rect5PointPs
#31 0x969cfed8 in _Z12_CallMenuDefP8MenuDatasP4Rect5PointPs
#32 0x96a382b4 in _Z8DrawMDEFP14MenuSelectDatah
#33 0x96a288ec in _Z11DrawTheMenuP14MenuSelectDataPP9__CFArrayPh
#34 0x96aa60d0 in _Z11OpenSubmenuP14MenuSelectDataP8MenuDatahPh
#35 0x969fb05c in _Z10CheckHItemP14MenuSelectDataPh
#36 0x969e45b0 in _Z15TrackMenuCommonR14MenuSelectDataPh
#37 0x96a90d5c in
_Z19PopUpMenuSelectCoreP8MenuData5PointdS1_PP7GDevicePK4RecttmS7_PP13Op
a
queMenuRefPt
#38 0x96b0f918 in PopUpMenuSelect
#39 0x002d65cc in 0x2d65cc
#40 0x002a5b1c in 0x2a5b1c
#41 0x002b885c in 0x2b885c
#42 0x001d0e60 in 0x1d0e60
#43 0x001d38d8 in 0x1d38d8
#44 0x001bce18 in 0x1bce18
#45 0x0014f8d4 in 0x14f8d4
#46 0x00360324 in 0x360324
#47 0x0036328c in 0x36328c
#48 0x0035bb18 in 0x35bb18
#49 0x0035b304 in 0x35b304
#50 0x0014edd4 in 0x14edd4
#51 0x00003e28 in 0x3e28
#52 0x00003ca8 in 0x3ca8
Thread 2:
#0 0x90014d28 in syscall_thread_switch
#1 0x90004b9c in szone_malloc
#2 0x90004a64 in malloc_zone_malloc
#3 0x08d68660 in _Znwm (Search.cpp:1280)
#4 0x08d58b38 in _ZN15CResContextInit14SetThisContextEi
(ResContextInit.cpp:47)
#5 0x08d52640 in _ZN13CVST2AUPlugin6RenderERmRK14AudioTimeStampm
(VST2AUPlugin.cpp:694)
#6 0x08d79d74 in _ZN6AUBase9RenderBusERmRK14AudioTimeStampmm
(AUBase.cpp:230)
#7 0x08d4a414 in
_ZN6AUBase11DoRenderBusERmRK14AudioTimeStampmP15AUOutputElementmR15Audi
o
BufferList (AUBase.cpp:1011)
#8 0x08d4a22c in
_ZN6AUBase8DoRenderERmRK14AudioTimeStampmmR15AudioBufferList
(AUBase.cpp:974)
#9 0x08d4cd24 in
_ZN6AUBase22ComponentEntryDispatchEP19ComponentParametersPS_
(AUDispatch.cpp:726)
#10 0x08d5063c in
_ZN15MusicDeviceBase22ComponentEntryDispatchEP19ComponentParametersPS_
(MusicDeviceBase.cpp:247)
#11 0x08d80784 in
_ZN19ComponentEntryPointI13CVST2AUPluginE8DispatchEP19ComponentParamete
r
sPS0_ (VST2AURegister.cpp:76)
#12 0x08d50c94 in CVST2AUPluginEntry (VST2AUPlugin.cpp:132)
#13 0x91eb0ea4 in AudioUnitRender
#14 0x00465e78 in 0x465e78
#15 0x0042f06c in 0x42f06c
#16 0x00430ad8 in 0x430ad8
#17 0x004310d4 in 0x4310d4
#18 0x00435da0 in 0x435da0
#19 0x90020d48 in _pthread_body
At 06:19 PM 3/18/2003 +0100, email@hidden wrote:
Hi,
"Calling AUCarbonViewBase::TellListener and ::AUParameterSet
from the audio thread is not safe".
Is that assertion true ? I had some bugs with logs that seems to
point them out (but I'm not sure...). Since I exec them in the
GUI thread now, everything is OK. Might it be related ?
Thanks,
Raf
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
=======================================================
Angus F. Hewlett, Technical Director
FXpansion Audio UK Ltd - http://www.fxpansion.com
=======================================================
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.