<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi,</div><div><br></div><div>I&nbsp;posted yesterday, and whilst I didn't figure out an answer the question about the&nbsp;sequencing&nbsp;of the _put call, I did find another way to get what I need. &nbsp;I wanted to get the index of a sink input after creation, but before it plays, so that I can implement sink-input switching and other stream manipulation (volume changes, etc.) in response to audio policy changes, on an embedded system.</div><div><br></div>I can't explain why _put is called after the stream completes playback, but I did discover a different way to be notified of sink-input creation with the completely filled sink input, using pa_subscription. &nbsp;Recall that neither sink-input new hook or the sink-input fixate hook will call back with a complete sink-input (the index of the sink-input has not been set with either) and that I was not seeing the sink-input put hook being called until after a stream had completed playback. &nbsp;So the method I came across (modified from one of the existing module sources) is as follows.<div><br></div><div>Install a subscription routine using in the module init routine:<div><br></div><div><font face="Verdana, Helvetica, Arial"><span style="font-size: 12px; "><font face="Verdana, Helvetica, Arial"><span style="font-size: 12px; ">&nbsp;&nbsp; &nbsp;u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK_INPUT, subscribe_callback, u);<br></span></font>&nbsp;</span></font></div><div><font class="Apple-style-span" face="Verdana">This allows us to get notifications on sink-input creations. &nbsp;When this routine is called back, it will be passed the index of the created sink input which makes getting at the actual sink-input to inspect it's fields really easy. &nbsp;</font></div><div><font class="Apple-style-span" face="Verdana"><br></font></div><div><font class="Apple-style-span" face="Verdana">Here is a subscribe callback to do this:</font></div><div><br></div><div><font class="Apple-style-span" face="Verdana"><br></font></div><div><font face="Verdana, Helvetica, Arial"><span style="font-size: 12px; ">static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {<br>&nbsp;&nbsp;&nbsp;&nbsp;struct userdata *u = &nbsp;userdata;<br>&nbsp;&nbsp;&nbsp;&nbsp;pa_sink_input *si = NULL;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;pa_assert(c);<br>&nbsp;&nbsp;&nbsp;&nbsp;pa_assert(u);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;pa_log("> pa__init");<br><br>&nbsp;&nbsp;&nbsp;&nbsp;/* we are only interested in sink-input creation events */<br>&nbsp;&nbsp;&nbsp;&nbsp;if (t != PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pa_log("&lt; pa__init - not a new sink input");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br>&nbsp;&nbsp;&nbsp;&nbsp;} else {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx))) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pa_log("&lt; pa__init - can't get index");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;pa_log("new event received on sink-input with index %d",si->index);<br><br>}</span></font>&nbsp;</div><div><br></div><div>Regards</div><div><br></div><div>Nick</div><div><br></div></div></body></html>