pulse audio module callbacks

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

 



Hello!

'Twas brillig, and Himanshu Chug at 06/06/11 17:22 did gyre and gimble:
> I am going through module-cork-music-on-phone.c
> 
> To understand the code , I need some information about these functions:

Yes, our internal developer docs don't really exist! :s I generally just
read through the code to see when these call backs are called. It's not
ideal, but it's pretty straight forward too. That said we really should
get an effort to provide better internal developer docs (e.g. internal
APIs within the server).

> 1. when each of these calls backs gets executed/called ?

> sink_input_put_cb

Note that for all these questions you've asked about the function as
called in module-cork-music-on-phone.c. In reality these functions can
be called anything you like. The more important question is the HOOK
that you're attaching them to for which you need to look at the
pa__init() function in module-cork-music-on-phone.c

PA_CORE_HOOK_SINK_INPUT_PUT

So this hook is called when the sink input (playback stream) is
physically created. There is an earlier hook that runs called
PA_CORE_HOOK_SINK_INPUT_NEW which is run before the actual sink input
object is created.

> sink_input_unlink_cb

PA_CORE_HOOK_SINK_INPUT_UNLINK

This is called when a sink input disappears (e.g. the client application
closes it's stream (user presses "Stop") or exits.

> sink_input_move_start_cb

PA_CORE_HOOK_SINK_INPUT_MOVE_START

This is called when we start to move a sink input to a new sink. At this
point the sink input is still attached the sink it is moving from.

> sink_input_move_finish_cb

PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH

This is called when we're done moving a sink input to a new sink and
thus the sink input is now attached to the sink it was moved to.


> 2. these callbacks are internally calling to process() function (given
> below) , I am interested to understand the last argument pa_bool_t
> create  of process(struct userdata *u, pa_sink_input *i, pa_bool_t create)
>  ,how to decide when to pass TRUE and FALSE to process? any reference
> (if available) will be helpful.

You can work this out from the semantics of the descriptions above and
the code in the process() function itself.

Ultimately it's telling the process method that it should be corking or
uncorking the streams.

So when we've got a new sink input appearing on our sink (which happens
in the PUT or MOVE_FINISH hooks), we need to look at (potentially)
creating a cork on the other sink inputs on that sink, hence a TRUE value.

But when a stream is disappearing (which can happen when it's moved off
our sink to another one, or when it's just no longer present - i.e.
UNLINK and MOVE_START hooks), we want to look at uncorking things we
have previously corked, hence a FALSE value.

> Thanks in advance

Hope that helps.

Col

PS Documentation patches or similar efforts are as welcome as any other
contribution!

Col
-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]



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

  Powered by Linux