I am seeking for an option to track the lifetime of pa_context objects. Unfortunately there in no callback when the reference counter reaches zero. It will only call pa_context free which is not visible to API users.

In fact, I am writing a C++ wrapper to the asynchronous API. And I want to start the (threaded) mainloop automatically. So the user need not to care about the mainloop at all. Well nothing special so far.

But also I have to stop the main loop when it is no longer needed. This is not trivial, because the pa_context might only be referenced internally by other PA objects. So an instance counter of the C++ context wrappers is not sufficient, because they might have gone out of scope while the mainloop is still needed for processing.

However, if I could track the total number of existing pa_context objects, I could safely stop the main loop after the last pa_context died. Without any pa_context object it is most likely no longer needed.

The only available observable is the stat callback. But tracking changes to PA_CONTEXT_FAILED and PA_CONTEXT_TERMINATED is not sufficient. First of all a context might not have been used at all, Secondly a terminated connection might become connected later.

Any ideas how to terminate the mainloop?

Running the mainloop thread infinitely might have impact on the application termination behavior. Especially, because i am talking about a plug-in with a private (mainloop) thread, which the application itself does not even know.


Marcel
_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss

Reply via email to