[pulseaudio-discuss] Few questions about PA API
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Mon Apr 14 00:42:37 PDT 2014
On Mon, 2014-04-14 at 01:16 +0200, Lukasz Marek wrote:
> Hi,
>
> I hope this is correct list for general questions about PulseAudio
> development. I devel some stuff for FFmpeg project and I want to update
> pulse output device. I have few questions:
>
> - Is this possible to detect that mute/volume for sink input has changed
> without calling pa_context_get_sink_input_info periodically?
> I saw some commits recently that seems to add this, but ubuntu still use
> 4.0 for example, so probably not, but I still wanted to ask about it.
You can get notifications about sink input changes with the subscription
API: http://freedesktop.org/software/pulseaudio/doxygen/subscribe.html
The API will tell you only that something changed (not necessarily
volume/mute), so when you get a change event for a sink input that you
are interested in, you then call pa_context_get_sink_input_info().
> - If not, would you judge pa_context_get_sink_input_info to be expensive
> function? I think about calling it every time new data are written or
> something.
The function sends a packet to the server and the server sends a reply
packet to the application. It's certainly much better to use the
subscription API.
> - Is it possible to write non-interleaved data?
> For example, for stereo instead of
> L R L R L R L R... samples
> to write:
> L L L L L .... R R R R R.... samples
Not possible.
> - pa_stream_write has parameter pa_free_cb_t to provide zero-copy.
> Unfortunately it doesn't accept user data, in case of FFmpeg, the buffer
> is inside AVBuffer, AVPacket, or AVFrame (AVBuffer technically).
> Each of them contains a variable with a buffer that should be passed to
> pa_stream_write, but free function should unref this structure, not
> buffer itself.
> It cannot be extracted without copying and this zero-copy is hard to reach.
> My question is: do you think it is doable/acceptable to add other
> function that would accept userdata for free callback?
> I know there is pa_stream_begin_write, but this is not suitable neither.
Yes, I think that would be acceptable. I wonder what would be a good
name for the function. pa_stream_write_with_free_userdata?
--
Tanu
More information about the pulseaudio-discuss
mailing list