From ff96165035fa77ca8869a94f5bbd663ab3290d62 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 22 Oct 2019 13:06:20 +0200 Subject: [PATCH] Improve debug --- spa/plugins/alsa/alsa-pcm.c | 3 ++- spa/plugins/audioconvert/merger.c | 5 +---- src/examples/media-session/alsa-monitor.c | 15 +++++++++++---- src/examples/media-session/bluez-monitor.c | 8 ++++++-- src/examples/media-session/media-session.c | 6 ++++-- src/examples/media-session/v4l2-monitor.c | 15 ++++++++++++--- src/pipewire/device.c | 2 +- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index d6ea19307..ce75cc48d 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1158,7 +1158,8 @@ int spa_alsa_start(struct state *state) state, state->threshold, state->duration, state->rate_denom, state->slaved); CHECK(set_swparams(state), "swparams"); - snd_pcm_dump(state->hndl, state->output); + if (SPA_UNLIKELY(spa_log_level_enabled(state->log, SPA_LOG_LEVEL_DEBUG))) + snd_pcm_dump(state->hndl, state->output); if ((err = snd_pcm_prepare(state->hndl)) < 0) { spa_log_error(state->log, NAME" %p: snd_pcm_prepare error: %s", state, diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 1e176c107..8a181e1bc 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -524,11 +524,8 @@ impl_node_port_enum_params(void *object, int seq, return -ENOENT; } - if (spa_pod_filter(&b, &result.param, param, filter) < 0) { - spa_debug_pod(2, NULL, param); - spa_debug_pod(2, NULL, filter); + if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - } spa_node_emit_result(&this->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result); diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index d2286bb37..b83a346a8 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -96,8 +96,11 @@ static void alsa_update_node(struct alsa_object *obj, struct alsa_node *node, const struct spa_device_object_info *info) { pw_log_debug("update node %u", node->id); + + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); + pw_properties_update(node->props, info->props); - spa_debug_dict(0, info->props); } static struct alsa_node *alsa_create_node(struct alsa_object *obj, uint32_t id, @@ -222,12 +225,13 @@ static void alsa_device_info(void *data, const struct spa_device_info *info) struct alsa_object *obj = data; const char *str; + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); + pw_properties_update(obj->props, info->props); if ((str = pw_properties_get(obj->props, PW_KEY_DEVICE_ID)) != NULL) obj->device_id = pw_properties_parse_int(str); - - spa_debug_dict(0, info->props); } static void alsa_device_object_info(void *data, uint32_t id, @@ -272,7 +276,10 @@ static void alsa_update_object(struct monitor *monitor, struct alsa_object *obj, const struct spa_device_object_info *info) { pw_log_debug("update object %u", obj->id); - spa_debug_dict(0, info->props); + + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); + pw_properties_update(obj->props, info->props); } diff --git a/src/examples/media-session/bluez-monitor.c b/src/examples/media-session/bluez-monitor.c index 42c26ab4e..c755d1a4c 100644 --- a/src/examples/media-session/bluez-monitor.c +++ b/src/examples/media-session/bluez-monitor.c @@ -84,7 +84,9 @@ static void bluez5_update_node(struct bluez5_object *obj, struct bluez5_node *no const struct spa_device_object_info *info) { pw_log_debug("update node %u", node->id); - spa_debug_dict(0, info->props); + + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); } static struct bluez5_node *bluez5_create_node(struct bluez5_object *obj, uint32_t id, @@ -215,7 +217,9 @@ static void bluez5_update_object(struct monitor *monitor, struct bluez5_object * const struct spa_device_object_info *info) { pw_log_debug("update object %u", obj->id); - spa_debug_dict(0, info->props); + + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); } static struct bluez5_object *bluez5_create_object(struct monitor *monitor, uint32_t id, diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index 8dd6a19ee..a4e0f9fdd 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -345,7 +345,8 @@ static void node_event_param(void *object, int seq, return; spa_pod_object_fixate((struct spa_pod_object*)param); - spa_debug_pod(2, NULL, param); + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_pod(2, NULL, param); if (spa_format_audio_raw_parse(param, &info) < 0) goto error; @@ -356,7 +357,8 @@ static void node_event_param(void *object, int seq, error: pw_log_warn("unhandled param:"); - spa_debug_pod(2, NULL, param); + if (pw_log_level_enabled(SPA_LOG_LEVEL_WARN)) + spa_debug_pod(2, NULL, param); return; } diff --git a/src/examples/media-session/v4l2-monitor.c b/src/examples/media-session/v4l2-monitor.c index 3d7e13cfc..020ee9794 100644 --- a/src/examples/media-session/v4l2-monitor.c +++ b/src/examples/media-session/v4l2-monitor.c @@ -83,8 +83,11 @@ static void v4l2_update_node(struct v4l2_object *obj, struct v4l2_node *node, const struct spa_device_object_info *info) { pw_log_debug("update node %u", node->id); + + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); + pw_properties_update(node->props, info->props); - spa_debug_dict(0, info->props); } static struct v4l2_node *v4l2_create_node(struct v4l2_object *obj, uint32_t id, @@ -163,8 +166,11 @@ static void v4l2_remove_node(struct v4l2_object *obj, struct v4l2_node *node) static void v4l2_device_info(void *data, const struct spa_device_info *info) { struct v4l2_object *obj = data; + + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); + pw_properties_update(obj->props, info->props); - spa_debug_dict(0, info->props); } static void v4l2_device_object_info(void *data, uint32_t id, @@ -209,7 +215,10 @@ static void v4l2_update_object(struct monitor *monitor, struct v4l2_object *obj, const struct spa_device_object_info *info) { pw_log_debug("update object %u", obj->id); - spa_debug_dict(0, info->props); + + if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) + spa_debug_dict(0, info->props); + pw_properties_update(obj->props, info->props); } diff --git a/src/pipewire/device.c b/src/pipewire/device.c index 16dfc77f0..82c8f6a98 100644 --- a/src/pipewire/device.c +++ b/src/pipewire/device.c @@ -538,7 +538,7 @@ static void device_add_object(struct pw_device *device, uint32_t id, struct object_data *od = NULL; if (info->factory_name == NULL) { - pw_log_warn(NAME" %p: missing factory name", device); + pw_log_debug(NAME" %p: missing factory name", device); return; }