<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 posted yesterday, and whilst I didn't figure out an answer the question about the sequencing of the _put call, I did find another way to get what I need. 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. 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. 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; "> u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK_INPUT, subscribe_callback, u);<br></span></font> </span></font></div><div><font class="Apple-style-span" face="Verdana">This allows us to get notifications on sink-input creations. 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. </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> struct userdata *u = userdata;<br> pa_sink_input *si = NULL;<br><br> pa_assert(c);<br> pa_assert(u);<br><br> pa_log("> pa__init");<br><br> /* we are only interested in sink-input creation events */<br> if (t != PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW) {<br> pa_log("< pa__init - not a new sink input");<br> return;<br> } else {<br> if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx))) {<br> pa_log("< pa__init - can't get index");<br> return;<br> }<br> }<br><br> pa_log("new event received on sink-input with index %d",si->index);<br><br>}</span></font> </div><div><br></div><div>Regards</div><div><br></div><div>Nick</div><div><br></div></div></body></html>