[pulseaudio-discuss] [PATCH 2/2] sink-input: check return error value

Wang Xingchao xingchao.wang at intel.com
Tue May 8 21:46:37 PDT 2012


data->format may be NULL if the sink doesnot support
client's format request, that would further cause assertion error.

Signed-off-by: Wang Xingchao <xingchao.wang at intel.com>
---
 src/pulsecore/sink-input.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 0fc8760..9634d3b 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -267,7 +267,10 @@ int pa_sink_input_new(
         pa_format_info *f = pa_format_info_from_sample_spec(&data->sample_spec,
                 data->channel_map_is_set ? &data->channel_map : NULL);
         pa_idxset_put(tmp, f, NULL);
-        pa_sink_input_new_data_set_formats(data, tmp);
+        if ((r = pa_sink_input_new_data_set_formats(data, tmp)) < 0) {
+            pa_log_error("Unable to set formats for sink-input new data.");
+            return r;
+        }
     }
 
     if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], data)) < 0)
@@ -278,7 +281,10 @@ int pa_sink_input_new(
     if (!data->sink) {
         pa_sink *sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK);
         pa_return_val_if_fail(sink, -PA_ERR_NOENTITY);
-        pa_sink_input_new_data_set_sink(data, sink, FALSE);
+        if ((r = pa_sink_input_new_data_set_sink(data, sink, FALSE)) < 0) {
+            pa_log_error("Unable to set sink for sink-input new data.");
+            return r;
+        }
     }
     /* Routing's done, we have a sink. Now let's fix the format and set up the
      * sample spec */
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list