+static void sink_input_event(pa_context *ctx,
+ pa_subscription_event_type_t type,
+ uint32_t idx, audio_output_t *aout)
+{
+ pa_operation *op;
+
+ /* Gee... PA will not provide the infos directly in the event. */
+ switch (type)
+ {
+ case PA_SUBSCRIPTION_EVENT_REMOVE:
+ msg_Err(aout, "sink input killed!");
+ break;
+
+ default:
+ op = pa_context_get_sink_input_info(ctx, idx, sink_input_info_cb,
+ aout);
+ if (likely(op != NULL))
+ pa_operation_unref(op);
+ break;
+ }
+}
+
+
+/*** Context ***/
+static void context_cb(pa_context *ctx, pa_subscription_event_type_t type,
+ uint32_t idx, void *userdata)
+{
+ audio_output_t *aout = userdata;
+ aout_sys_t *sys = aout->sys;
+ unsigned facility = type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK;
+
+ type &= PA_SUBSCRIPTION_EVENT_TYPE_MASK;
+ switch (facility)
+ {
+ case PA_SUBSCRIPTION_EVENT_SINK:
+ sink_event(ctx, type, idx, userdata);
+ break;
+
+ case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
+ /* only interested in our sink input */
+ if (sys->stream != NULL && idx == pa_stream_get_index(sys->stream))
+ sink_input_event(ctx, type, idx, userdata);
+ break;
+
+ default: /* unsubscribed facility?! */
+ assert(0);
+ }
+}
+