Re: [LAD] sequencer and sysex again

From: <rdxesy@email-addr-hidden>
Date: Fri Jun 06 2008 - 21:47:27 EEST

On Fri, Jun 06, 2008 at 20:22:44 +0200
Fons Adriaensen <fons@email-addr-hidden> wrote:
> On Fri, Jun 06, 2008 at 07:30:49PM +0200, rdxesy@email-addr-hidden wrote:
>
> > now there are two things i dont understand:
> > first: why is the midi_callback() thread being called once
> > ...
> > 1. call the midi_callback() thread more often
> > ...
>
> I try to understand what's happening, but your terminology
> is somewhat confusing...
>
> Threads are run, or can be running or waiting, but they
> are never 'called'. Functions are called.
>
> So what is this 'midi callback' thing exactly ?
>
> Is it a thread doing a blocking read() on a midi port,
> and waking up when there is data for it ? If so what
> does this trhead do with the data it receives ?
> Or is it a function you call periodically ?
> Or something else ?
>
> Ciao,
>

Ciao,

sorry for being unprecise.
let me show you :)

...
pthread_create (&midi_listener, NULL, midi_listen, NULL);
...

static void
*midi_listen(void *ptr)
{
    int seq_nfds, i;
    struct pollfd *pfds;

    seq_nfds = snd_seq_poll_descriptors_count(seq, POLLIN);
    pfds = (struct pollfd *)alloca(sizeof(struct pollfd) * (seq_nfds));
    snd_seq_poll_descriptors(seq, pfds, seq_nfds, POLLIN);

    while (1)
    {
        if (poll (pfds, seq_nfds, 1000) > 0)
        {
            pmesg(100, "poll\n");
            for (i = 0; i < seq_nfds; i++)
                if (pfds[i].revents > 0)
                    midi_callback ();
        }
    }

}

static void
midi_callback(void)
{
    pmesg(100, "midi midi_callback() ENTERING\n");

    snd_seq_event_t *ev;
    unsigned char *data = NULL;
    int param, value, err;

    do
    {
        err = snd_seq_event_input(seq, &ev);
        if (err < 0)
            return;

        if (ev->type == SND_SEQ_EVENT_SYSEX)
        {
            data = ev->data.ext.ptr;

            ... set sliders and stuff eg:

            if (param == VOLUME || param == PAN)
            {
                gdk_threads_enter ();
                set_slider(param, value);
                gdk_threads_leave ();
            }
            ...

    }
    while (snd_seq_event_input_pending(seq, 0) > 0);
}

I guess this makes things clearer :)

While this thread is running i am requesting the parameters
as shown earlier.

Cheers,
Jan
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Sat Jun 7 00:15:39 2008

This archive was generated by hypermail 2.1.8 : Sat Jun 07 2008 - 00:15:39 EEST