pulsecore: Don't allow unreferencing linked object.

Sink(-input) and source(-output) called unlink function when reference
count dropped to zero. This would result in unlink hooks being called
with an object having a reference count of zero, and this is not a
situation we want modules to have to deal with. It is better to just
remove the redundant unlinking code from sink(-input) and
source(-output) and assert on reference count in unlink functions as well.

It is expected that in well behaving code the owner of an object will
always unlink the object before unreferencing.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
This commit is contained in:
Juho Hämäläinen 2016-05-13 17:39:41 +03:00 committed by Arun Raghavan
parent be4619e3f7
commit a5f71d1c54
4 changed files with 9 additions and 16 deletions

View file

@ -548,7 +548,8 @@ static void source_output_set_state(pa_source_output *o, pa_source_output_state_
/* Called from main context */
void pa_source_output_unlink(pa_source_output*o) {
bool linked;
pa_assert(o);
pa_source_output_assert_ref(o);
pa_assert_ctl_context();
/* See pa_sink_unlink() for a couple of comments how this function
@ -614,9 +615,7 @@ static void source_output_free(pa_object* mo) {
pa_assert(o);
pa_assert_ctl_context();
pa_assert(pa_source_output_refcnt(o) == 0);
if (PA_SOURCE_OUTPUT_IS_LINKED(o->state))
pa_source_output_unlink(o);
pa_assert(!PA_SOURCE_OUTPUT_IS_LINKED(o->state));
pa_log_info("Freeing output %u \"%s\"", o->index,
o->proplist ? pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_MEDIA_NAME)) : "");