[openbeos-midi] Re: BMidiPort

  • From: "Matthijs Hollemans" <matthijs@xxxxxxxxxxxxxxxxxxx>
  • To: <openbeos-midi@xxxxxxxxxxxxx>
  • Date: Thu, 14 Nov 2002 13:31:51 +0100

> Most probably the BMidiPort is responsable for scan
> all /dev/midi/* it can support. And the midi_server, thru
> an internal MidiPort objects, open each and publish them
> as a BMidiEndpoint (consumer & producer) ...

I doubt that (in BeOS R5) there is any correlation between (the
implementation of) libmidi's BMidiPort and the midi_server's
internal MidiPort objects. But it is probably safe to say that
midi_server's MidiPort objects now do what the pre-R5 implementation
of BMidiPort used to.

> However, looking at midi_server internals, it seems he's watching
> /dev/midi/* tree, so maybe since Midi2 the BMidiPort class
> don't scan devices itself anymore but rely on midi_server to do

My guess exactly. For R5, Be re-implemented libmidi using the
classes from libmidi2, so it is very unlikely that the classes from
libmidi do any of that work themselves. Rather, they rely on the
midi_server. And that is why we should do the same. (Actually, this
really simplifies our implementation of the midi1 kit ;-)

> > What should happen if you
> > Open() a port, say /dev/midi/sblive?
> As the midi_server should have already open /dev/midi/sblive
> it at his startup, I'll bet you will get a "Busy" error on a
> BMidiPort::Open("/dev/midi/sblive");

You are right, when the midi_server starts, it reads all the devices
from /dev/midi and makes endpoints for these devices. But you are
mistaken about the "busy" error. From the BMidiPort docs: "The
object isn't given exclusive access to the ports that it has
opened--other BMidiPort objects, potentially from other
applications, can open the same MIDI ports."

My guess is that BMidiPort does not really open any ports anymore.
It just hooks up a local producer and consumer of its own to the
endpoints exported from the midi_server. I haven't studied this part
of the Midi Kit, yet, so I may be wrong.

> Well, I guess yes. A quick search at BMidiEndpoint::Name() until
> match device_path passed to BMidiPort::Open(device_path).

Actually, that is what I thought too. So BMidiPort _never_ looks in
the /dev/midi hierarchy. Instead, it just looks at the published
devices with NextEndpoint() etc. If the name of an endpoint starts
with /dev/midi/, then this is a hardware device, and BMidiPort can
talk to it.


Other related posts: