All of lore.kernel.org
 help / color / mirror / Atom feed
* Can ALSA invoke a Callback ?
@ 2011-08-26 14:24 Ru Vuott
  2011-08-26 14:34 ` Clemens Ladisch
  0 siblings, 1 reply; 6+ messages in thread
From: Ru Vuott @ 2011-08-26 14:24 UTC (permalink / raw)
  To: alsa-devel

Hello,

I would like to know how I can ask ALSA to invoke a "Callback" function when an Midi event arrives from an extern-device.

Thanks
Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can ALSA invoke a Callback ?
  2011-08-26 14:24 Can ALSA invoke a Callback ? Ru Vuott
@ 2011-08-26 14:34 ` Clemens Ladisch
  0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2011-08-26 14:34 UTC (permalink / raw)
  To: Ru Vuott; +Cc: alsa-devel

Ru Vuott wrote:
> I would like to know how I can ask ALSA to invoke a "Callback"
> function when an Midi event arrives from an extern-device.

This is not possible.

The mechanism usually used for this is to check for events from the
MIDI device in the main message loop (which must be based on poll() or
select()).

Are you using raw MIDI or sequencer devices?  How does your program's
event handling work?


Regards,
Clemens

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can ALSA invoke a Callback ?
       [not found] <1314978948.16516.YahooMailClassic@web29618.mail.ird.yahoo.com>
@ 2011-09-02 16:32 ` Clemens Ladisch
  0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2011-09-02 16:32 UTC (permalink / raw)
  To: Ru Vuott; +Cc: alsa-devel

Ru Vuott wrote:
>  hData = OPEN "/dev/snd/midiC2D0" for READ Watch
> 
> Do you think this solution could interfere and give problems to ALSA ?

Yes; this opens the device exclusively.  The ALSA sequencer would be
able to allow multiple applications.

> The rest of my program (for sending midi event, etcetera) continue to use ALSA.

How are you using ALSA from Gambas?  Is there some ALSA module that
could be extended to ALSA watches?


Regards,
Clemens

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can ALSA invoke a Callback ?
       [not found] <1314566910.38637.YahooMailClassic@web29620.mail.ird.yahoo.com>
@ 2011-08-29  9:12 ` Clemens Ladisch
  0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2011-08-29  9:12 UTC (permalink / raw)
  To: Ru Vuott; +Cc: alsa-devel

Ru Vuott wrote:
> you wrote:
> > These functions are designed to be used with poll(); to use
> > them with Gambas, extract the file descriptors and their event masks
> > from the pfds array and call GB.Watch() with these values.
> 
> << GB.Watch() is an internal interpreter API. You can't use it in Gambas code.>>

Then how do you get access to the snd_seq_* functions?  I assumed that
you have some module that offers a Gambas API on top of the ALSA C API;
that module then should also wrap the snd_seq_poll_* calls.

> I need a "file", so I could use in Gambas:
> 
> hfile = Open "....." for Read  W A T C H

You would need some mechanism to watch a file that is identified by its
already opened file descriptor, not by its name.  It looks as if the
only such mechanism is something that uses the internal interpreter API.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can ALSA invoke a Callback ?
       [not found] <1314385032.22194.YahooMailClassic@web29616.mail.ird.yahoo.com>
@ 2011-08-26 22:03 ` Clemens Ladisch
  0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2011-08-26 22:03 UTC (permalink / raw)
  To: Ru Vuott; +Cc: alsa-devel

Ru Vuott wrote:
> Well, I 'm programming with Gambas 3.0 language. I 'm using
> a GUI.

Use snd_seq_poll_descriptors_count() and snd_seq_poll_descriptors() to
get one or more file descriptors and event masks for the sequencer
device; these file descriptors can be used to wait for events.

When you receive an event, check if the device is actually ready for
reading or writing by calling snd_seq_poll_descriptors_revents().

These functions are designed to be used with poll(); to use them with
Gambas, extract the file descriptors and their event masks from the pfds
array and call GB.Watch() with these values.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can ALSA invoke a Callback ?
       [not found] <1314369942.41651.YahooMailClassic@web29613.mail.ird.yahoo.com>
@ 2011-08-26 15:54 ` Clemens Ladisch
  0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2011-08-26 15:54 UTC (permalink / raw)
  To: Ru Vuott; +Cc: alsa-devel

Ru Vuott wrote:
> I'm using Alsa "Seq" functions.
> 
> My midi-program - obviously - does not know exactly when the extern midi event 'll arrive....
> Has it to read uninterruptedly his port, waiting for the events.... ?

This is done only in single-purpose command-line programs like arecordmidi.
When you have other events, you collect the file descriptors of all your
devices/pipes/whatever, and wait for all of them in a poll()-based loop.

How does your program handle events?  Or are you using a GUI framework?


Regards,
Clemens

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-02 16:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26 14:24 Can ALSA invoke a Callback ? Ru Vuott
2011-08-26 14:34 ` Clemens Ladisch
     [not found] <1314369942.41651.YahooMailClassic@web29613.mail.ird.yahoo.com>
2011-08-26 15:54 ` Clemens Ladisch
     [not found] <1314385032.22194.YahooMailClassic@web29616.mail.ird.yahoo.com>
2011-08-26 22:03 ` Clemens Ladisch
     [not found] <1314566910.38637.YahooMailClassic@web29620.mail.ird.yahoo.com>
2011-08-29  9:12 ` Clemens Ladisch
     [not found] <1314978948.16516.YahooMailClassic@web29618.mail.ird.yahoo.com>
2011-09-02 16:32 ` Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.