understanding PA cork/uncorking scenarios

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2011-06-16 at 12:54 +0530, Himanshu Chug wrote:
> Hi
> 
> I am trying to understand how the corking/uncorking events reach from PA
> module to PA applications/clients e.g gst-launch
> 
> Say, we are corking the playback stream in module-cork-music-on-phone by
> calling :
> 
> apply_cork(struct userdata *u, pa_sink *s, pa_sink_input *ignore, pa_bool_t
> cork)
>      pa_sink_input_send_event(ignore, PA_STREAM_EVENT_REQUEST_CORK, NULL);
> (in sink-input.c)
> 
> (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_SEND_EVENT],
> &hook_data)   (function then fire an hook)
>                       sink_input_send_event_hook_cb( pa_core *c,
> pa_sink_input_send_event_hook_data *data, struct userdata *u)    ( in
> module-x11-cork-request, passing *data that contains cork event)
> 
> 
> now inside sink_input_send_event_hook_cb( )   ( in module-x11-cork-request )
> there is an if-else check
> 
>     if (pa_streq(data->event, PA_STREAM_EVENT_REQUEST_CORK))
>         sym = XF86XK_AudioPause;
>     else if (pa_streq(data->event, PA_STREAM_EVENT_REQUEST_UNCORK))
>         sym = XF86XK_AudioPlay;
>     else
>         return PA_HOOK_OK;
> 
> further the same function is calling
>     XTestFakeKeyEvent(display, code, True, CurrentTime);
>     XSync(display, False);

module-x11-cork-request is a workaround for clients that don't handle
stream events (a workaround that isn't working very well, I've heard).
As can be seen from the code you pasted, the idea is to generate
AudioPause and AudioPlay X11 keyboard events with the hope that the
applications will handle those.

> But it is not clear to me how the Cork/Uncork events then reach to PA client
> (say pulsesink or Gst-launch)

src/pulsecore/protocol-native.c has sink_input_send_event_cb(), which
sends all stream events over the protocol to the client. It's then up to
the client to decide what to do.

> and then where gst listens to these events and
> pause / resume gst pipeline accordingly ?
> Is pulsesink involved here somehow ? I can see
> gst_pulsering_stream_event_cb( )  function (inside pulsesink.c)  handling
> PA_STREAM_EVENT_REQUEST_CORK but currently it is under #ifdef
> HAVE_PULSE_0_9_15 flag and disabled.

That's the function that should handle the cork request and pause the
Gstreamer pipeline. If the code is disabled, then Pulseaudio's stream
events apparently are not currently handled by Gstreamer.

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux