<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.13"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>PulseAudio: Event Subscription</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">PulseAudio  <span id="projectnumber">10.0.0-1.1.mga6</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.13 --> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> $(function() { initMenu('',false,false,'search.php','Search'); }); </script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> $(document).ready(function(){initNavTree('subscribe.html','');}); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <div class="title">Event Subscription </div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><h1><a class="anchor" id="overv_sec"></a> Overview</h1> <p>The application can be notified, asynchronously, whenever the internal layout of the server changes. Possible notifications are described in the <a class="el" href="def_8h.html#a6bedfa147a9565383f1f44642cfef6a3">pa_subscription_event_type</a> and <a class="el" href="def_8h.html#ad4e7f11f879e8c77ae5289145ecf6947">pa_subscription_mask</a> enumerations.</p> <p>The application sets the notification mask using <a class="el" href="subscribe_8h.html#abe684246fd5cb640b0199bcfe7f801b0" title="Enable event notification. ">pa_context_subscribe()</a> and the function that will be called whenever a notification occurs using <a class="el" href="subscribe_8h.html#a55281f798863e7b37594d347be7ad98c" title="Set the context specific call back function that is called whenever the state of the daemon changes...">pa_context_set_subscribe_callback()</a>.</p> <p>The callback will be called with a <a class="el" href="def_8h.html#acbc7a15d7a9fe0722b02e2d739200035">pa_subscription_event_type_t</a> representing the event that caused the callback. Clients can examine what object changed using <a class="el" href="def_8h.html#a6bedfa147a9565383f1f44642cfef6a3a55fdfc2a2ca13b0356e1389b522f38f7">PA_SUBSCRIPTION_EVENT_FACILITY_MASK</a>. The actual event type can then be extracted with <a class="el" href="def_8h.html#a6bedfa147a9565383f1f44642cfef6a3aa79dc3715e76129204822efba5d49219">PA_SUBSCRIPTION_EVENT_TYPE_MASK</a>. Please note that the masked values are integers, not flags (so you will check the object/event type using a comparison not a binary AND). For example, the callback might look something like:</p> <pre class="fragment">void my_subscription_callback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) { if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE) { if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { ... a source was added, let's do stuff! ... } } } </pre> </div></div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="async.html">Asynchronous API</a></li> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li> </ul> </div> </body> </html>