[linux-audio-dev] XAP: Multiple Event Ports or not?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] XAP: Multiple Event Ports or not?
From: David Olofson (david_AT_olofson.net)
Date: Mon Dec 09 2002 - 13:20:31 EET


And now I just realized something else...

Why argue whether or not there should be a single event port per
plugin instance, or one per Channel, or whatever? Just have the
*plugin* set up the ports, and have the host ask a callback

        XAP_event_port *get_event_port(XAP_cnx_descriptor *cd);

when it wants the port to use to reach a specific Bay:Channel:Slot.
Most plugins will probably consider only the Bay and Channel fields,
but some may ignore all fields and always return the same port, while
others may split the range of Slots of multiple ports in arbitrary
ways.

That way, you can have *one Event Port per Control* if you like. :-)

Well, yes, there is one issue, of course: When you use the same port
for multiple Channels and/or multiple Bays, you'll need the Channel
and/or Bay indices as arguments in the event struct.

I'm thinking that you might still just have a 32 bit "index" or
"slot" field in the event struct, but optionally split it up, encode
it or whatever, as you like. It would be easy enough to have the
plugin do that as part of the get_event_port() callback above;
something like:

        XAP_target_descriptor
        {
                XAP_event_port *port;
                unsigned long id; /* Plugin's reference;
                                         * may be *anything*.
                                         */
        }

        int map_target(XAP_cnx_descriptor *cd,
                        XAP_target_descriptor *td);

That is, the map_target() call converts <port, bay, channel, slot>
inte <port, id> in whatever way the plugin author wants. The
ID/index/slot thing is just "that value you're supposed to write into
the "index" field of events sent to this target" anyway, so it
doesn't matter the slightest to senders - or the host - what the
value actually means.

Example:
        * Plugin wants *everything* on one port.

        * Plugin will return the same physical port whichever
          event input Bay:Channel:Slot you ask for.

        int map_target(XAP_cnx_descriptor *cd,
                        XAP_target_descriptor *td)
        {
                MY_plugin *me = cd->plugin; /* Get "this". */
                td->port = me->my_universal_event_port;
                td->id = cd->bay << 24;
                td->id |= cd->channel << 16;
                td->id |= cd->slot;
                return 0; /* Ok! --> */
        }

        * In the single event processing loop, the plugin will
          just extract the bay, channel and slot fields like this:

                int bay = event->index >> 24;
                int channel = (event->index >> 16) & 0xff;
                int slot = event->index & 0xffff;

Is this ok?

//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`---------------------------> http://olofson.net/audiality -'
.- M A I A -------------------------------------------------.
| The Multimedia Application Integration Architecture |
`----------------------------> http://www.linuxdj.com/maia -'
   --- http://olofson.net --- http://www.reologica.se ---


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon Dec 09 2002 - 13:32:40 EET