• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: some sort of dispose
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: some sort of dispose


  • Subject: Re: some sort of dispose
  • From: Pete Gontier <email@hidden>
  • Date: Thu, 24 Jul 2003 10:57:58 -0700

Unfortunately, pre-flighting won't solve the problem, since the "all kindsa stuff which might throw an exception" includes (wrapped) calls to MIDIDeviceAddEntity, MIDIObjectSetIntegerProperty, and MIDISetupAddDevice, none of which I can do before MIDIDeviceCreate.

I am not terribly worried about this because, as you point out, failure seems fairly unlikely and the consequences seem minor. Nevertheless, the lack of MIDIDeviceDispose (or whatever) did strike me as conspicuously asymmetric.

This is now Radar 3341954.

--

Pete Gontier
http://www.m-audio.com/

On Thursday, Jul 24, 2003, at 10:16 US/Pacific, Doug Wyatt wrote:

Ugh. The only way to delete a device is to call MIDISetupAddDevice and then MIDISetupRemoveDevice, which does dispose it.

We could add an API but then it would only exist on Panther and wouldn't help you on earlier systems.

You might preflight to see if you're going to be able to finish creating the device successfully before creating it? IOW, gather all the information you're going to need to create the device before actually doing it.

Leaking is bad, but a MIDIDevice is pretty lightweight (no more than a few hundred bytes), so if it's pretty unlikely that you'd fail, it wouldn't be horrible if you failed to dispose it -- nothing in CoreMIDI retains a reference to it until you call MIDISetupAddDevice.

Doug

On Wednesday, 23 July, 2003, at 18:57, Pete Gontier wrote:
Am I missing something obvious? (see comments below)

MIDIDeviceRef InterfaceStarter::CreateMIDIDevice
(ConstDeviceDescriptorPtr ourDeviceDescriptor)
{
MIDIDeviceRef midiDeviceRef;

ThrowIfError (MIDIDeviceCreate ( MIDIDriverRef (fInterface),
ourDeviceDescriptor->modelName,
ourDeviceDescriptor->manufacturerName,
ourDeviceDescriptor->modelName,
&midiDeviceRef ));
Assert (midiDeviceRef != nil);

try
{
// all kindsa stuff which might throw an exception
}
catch (...)
{
// Ordinarily, I would pass midiDeviceRef to some sort of dispose
// function, but there does not seem to be any such function.

throw;
}

return midiDeviceRef;
}
_______________________________________________
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.

References: 
 >Re: some sort of dispose (From: Doug Wyatt <email@hidden>)

  • Prev by Date: MusicPlayerIsPlaying() : is it done yet?
  • Next by Date: Re: LAP : AU music device needs Audio & MIDI
  • Previous by thread: Re: some sort of dispose
  • Next by thread: MusicPlayerIsPlaying() : is it done yet?
  • Index(es):
    • Date
    • Thread