handle unlinking of uninitialized sink inputs and source outputs gracefully 10/25210/1
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Wed, 30 Jul 2014 16:35:34 +0000 (19:35 +0300)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Wed, 30 Jul 2014 16:35:34 +0000 (19:35 +0300)
There's an upcoming change in PulseAudio that causes the unlink hooks
of sink inputs and source outputs to be fired more often. The hooks
may be fired when the sink input or source output doesn't have
anything but the state variable initialized, so e.g. proplist may be
NULL.

It seems that currently there's only a couple of places that need to
be modified to take NULL proplist into account, but there's a risk
that in the future some of the code that is called from the unlink
handlers will assume that some other thing is initialized. It would be
good to have some way to easily check right in the beginning of the
unlink handlers whether the sink input or source output has been seen
before. If it has been seen, then there are some guarantees about
things being initialized, and if it hasn't been seen, then the unlink
handlers could return immediately.

Change-Id: I1dc75122e185f747c5b3e4e78a237cec3946a38d

murphy/discover.c
murphy/utils.c

index 217a611..8f82243 100644 (file)
@@ -1125,7 +1125,7 @@ void pa_discover_remove_sink_input(struct userdata *u, pa_sink_input *sinp)
     mir_node       *node;
     mir_node       *sinknod;
     char           *name;
-    bool       had_properties;
+    bool       had_properties = false;
 
     pa_assert(u);
     pa_assert(sinp);
@@ -1135,7 +1135,8 @@ void pa_discover_remove_sink_input(struct userdata *u, pa_sink_input *sinp)
 
     pa_log_debug("sink-input '%s' going to be destroyed", name);
 
-    had_properties = pa_utils_unset_stream_routing_properties(sinp->proplist);
+    if (sinp->proplist)
+        had_properties = pa_utils_unset_stream_routing_properties(sinp->proplist);
 
     if (!(node = pa_discover_remove_node_from_ptr_hash(u, sinp))) {
         if (!pa_multiplex_sink_input_remove(u->multiplex, sinp))
index 90c1ae3..96e1e58 100644 (file)
@@ -178,7 +178,7 @@ char *pa_utils_get_sink_input_name(pa_sink_input *sinp)
 {
     char *name;
 
-    if (sinp && (name = stream_name(sinp->proplist)))
+    if (sinp && sinp->proplist && (name = stream_name(sinp->proplist)))
         return name;
 
     return "<unknown>";
@@ -199,7 +199,7 @@ char *pa_utils_get_source_output_name(pa_source_output *sout)
 {
     char *name;
 
-    if (sout && (name = stream_name(sout->proplist)))
+    if (sout && sout->proplist && (name = stream_name(sout->proplist)))
         return name;
 
     return "<unknown>";