Re: Crash playing through DLSMusicDevice with large sound fonts
Re: Crash playing through DLSMusicDevice with large sound fonts
- Subject: Re: Crash playing through DLSMusicDevice with large sound fonts
- From: Chris Reed <email@hidden>
- Date: Wed, 25 Jun 2003 23:48:21 -0500
No, you're totally right!
My fault... I forgot the render notification and actual render callback
prototypes are the same, and just saw "RenderCallback" and didn't look
further (and looking at Robert's reply more than the original question).
-chris
On Wednesday, Jun 25, 2003, at 17:43 US/Central, Yasir Assam wrote:
I'm afraid I'm a bit confused here. You say:
"The best thing to do is install a pre-render notification callback and
submit all MIDI events pertaining to the next buffer in the pre-render
callback."
but I thought I was doing this. If you look at my sample code
(ignoring the
name of the function):
OSStatus RenderCallback( void* ref,
AudioUnitRenderActionFlags flags,
const AudioTimeStamp*,
UInt32 bus,
UInt32 numFrames,
AudioBufferList* bufList)
{
if (ref && (flags & kAudioUnitRenderAction_PreRender)) {
// Loop through all events that need to be played now
while (moreEvents) {
MusicDeviceMIDIEvent(dev, status, byte1, byte2, 0);
//...code left out
}
}
return noErr;
}
you'll notice that I only call MusicDeviceMIDIEvent when the
kAudioUnitRenderAction_PreRender is on. So I assume this will only
execute
before it renders the next buffer. Isn't this what you mean?
I only do this because I was told about a month back in this list that
this
is what I should do to avoid the stuck notes bug (which we were still
getting in 10.2.6 for some strange reason).
If I've misunderstood this, I'd really appreciate a short sample or
pseudo-code telling me what to do.
Thanks,
Yasir
-----Original Message-----
From: Chris Reed [mailto:email@hidden]
Sent: Thursday, 26 June 2003 5:43 AM
To: Robert Grant
Cc: Yasir Assam; email@hidden
Subject: Re: Crash playing through DLSMusicDevice with large sound
fonts
On Wednesday, Jun 25, 2003, at 09:36 US/Central, Robert Grant wrote:
Hi Yasir,
I'm guessing here but I don't think you should be submitting
MIDIEvents in the RenderCallback. The RenderNotification is happening
on the realtime thread and my guess is that the MIDIEvents are taking
too long... Why not submit the events from a non-render thread and
thus let the MusicDevice process them when it's ready?
That's correct. You shouldn't send MIDIEvents to the AU during the
RenderCallback. The best thing to do is install a pre-render
notification callback and submit all MIDI events pertaining to the
next
buffer in the pre-render callback.
-chris
Robert.
On Wednesday, June 25, 2003, at 04:58AM, Yasir Assam
<email@hidden> wrote:
Hi,
My code crashes when playing DLSMusicDevice using a particular large
sound
font (the .sft2 in question is approximately 84MB). The same MIDI
file
played through other OS X apps that use DLSMusicDevice don't crash
when
played through this sound font, so I don't think the sound font is
at
fault.
Oddly, when I set the CPU load (using kAudioUnitProperty_CPULoad) to
values
<= 0.7 the crash goes away, so it seems connected to how much CPU
time the
DLSMusicDevice uses.
Rendering is pretty simple. After initialization I call:
AudioUnitSetRenderNotification(dev, RenderCallback, 0);
and then the render notification callback is:
OSStatus RenderCallback( void* ref,
AudioUnitRenderActionFlags flags,
const AudioTimeStamp*,
UInt32 bus,
UInt32 numFrames,
AudioBufferList* bufList)
{
if (ref && (flags & kAudioUnitRenderAction_PreRender)) {
// Loop through all events that need to be played now
while (moreEvents) {
MusicDeviceMIDIEvent(dev, status, byte1, byte2, 0);
//...code left out
}
}
return noErr;
}
(the code has been edited for clarity)
The crash happens somewhere inside the MusicDeviceMIDIEvent call,
about 11
calls deep.
Is there a known issue with DLSMusicDevice and large sound fonts
crashing
when the system is under strain? The crash could be due to a problem
elsewhere in my code of course, but I wanted to check to see if
there's a
known issue.
Another problem is that the sound font does sound pretty bad (loads
of
crackles. glitches etc.) I presume this is due to lack of CPU cycles
and
there's not much I can do other than optimize my app generally. Is
this is
the case?
Thanks,
Yasir Assam
_______________________________________________
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.
_______________________________________________
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.
_______________________________________________
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.