PCM events are sent when changes occur to a subchannel.
There many situations where it's useful to notify an application when an event occurs to the subchannel so that the application can take appropriate actions. For example, an application may maintain its own states, and so needs to update its application-specific states.
PCM events can be a state change or when the subchannel has been muted by the system. For example, events are when audio concurrency management moves a subchannel from the RUNNING state to the SUSPENDED state. It's important to note that PCM events aren't generated when API calls are made; for example, a call to snd_pcm_*_pause() won't generate an event.
By default, applications won't receive events unless they call the snd_pcm_set_filter() to register to receive them. To register for events, a bitmask must be applied to the enable member in the snd_pcm_filter_t argument to the snd_pcm_set_filter() as shown here:
/* Enable PCM events */ snd_pcm_filter_t pevent; pevent.enable = ( (1<<SND_PCM_EVENT_AUDIOMGMT_STATUS) | (1<<SND_PCM_EVENT_AUDIOMGMT_MUTE) | (1<<SND_PCM_EVENT_OUTPUTCLASS) ); snd_pcm_set_filter(pcm_handle, SND_PCM_CHANNEL_PLAYBACK, &pevent);
You can use snd_pcm_get_filter() to see which events you registered for.
To work with the PCM events, call snd_pcm_channel_read_event(). That call is a non-blocking call where you can then use select() (with exceptfds) or call poll() (with POLLRDBAND) to retrieve the PCM events from your queue. For information about those functions, see the QNX Neutrino C Library Reference.
When you retrieve an event, use the snd_pcm_event_t structure to determine the event type you received. You can use the data member (a union) to get event data. These are the available event types: