Hello,

just to finish this thread, a colleague of mine put me on the right track: 
timers. If you look at the alsa-lib timer example 
http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2timer_8c-example.html , 
you see the timer interface being used to register on master timer ticks. The 
read loop simply waits on poll.

Actually, timer work on a variety of events, see 
http://www.alsa-project.org/alsa-doc/alsa-lib/group___timer.html ,  enum  
snd_timer_event_t . To register on specific events, you create a filter mask of 
your events ( 1 << event1 || 1 << event2 || ... ) and set it to your timer 
parameters with snd_timer_params_set_filter . In read loop of the timer 
example, you just need to use snd_timer_tread_t instead of snd_timer_read_t .

In my case, I registered on the timer events SND_TIMER_EVENT_MSTART and 
SND_TIMER_EVENT_MSTOP and it works as expected.

Regards,
Thomas
________________________________________
From: Frank Thomas
Sent: 04 June 2018 08:53:57
To: alsa-user@lists.sourceforge.net
Subject: Get triggered when the device opens

Hello,

I'd like to apologise beforehand if I have not read enough
documentation and/or source code to be posting here. Please do not
hesitate to tell me to RTFM ☺

My application needs to get triggered when a mechanism any application
is opening or closing a certain list of ALSA devices. It seems that
ALSA hooks would be a way to do it. AFAIK I can only use a hook to
trigger a function a in a pcm control plugins with certain arguments. I
would need implement a control plugin that notifies my application for
me and use a hook to trigger the trigger ☺

Is there another way, e.g. with the ALSA API, to get triggered on such
events?

Thanks in advance.


Regards,
Thomas Frank
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to