pulse-server: improve message debug, add offset

This commit is contained in:
Wim Taymans 2020-11-09 09:42:15 +01:00
parent d7d4f094a8
commit b6efcd90a7

View file

@ -590,11 +590,13 @@ static int message_put(struct message *m, ...)
static int message_dump(struct message *m) static int message_dump(struct message *m)
{ {
int res; int res;
uint32_t i, offset = m->offset; uint32_t i, offset = m->offset, o;
pw_log_debug("message: len:%d alloc:%u", m->length, m->allocated);
while (true) { while (true) {
uint8_t tag; uint8_t tag;
o = m->offset;
if (read_u8(m, &tag) < 0) if (read_u8(m, &tag) < 0)
break; break;
@ -604,18 +606,18 @@ static int message_dump(struct message *m)
char *val; char *val;
if ((res = read_string(m, &val)) < 0) if ((res = read_string(m, &val)) < 0)
return res; return res;
pw_log_debug("string: '%s'", val); pw_log_debug("%u: string: '%s'", o, val);
break; break;
} }
case TAG_STRING_NULL: case TAG_STRING_NULL:
pw_log_debug("string: NULL"); pw_log_debug("%u: string: NULL", o);
break; break;
case TAG_U8: case TAG_U8:
{ {
uint8_t val; uint8_t val;
if ((res = read_u8(m, &val)) < 0) if ((res = read_u8(m, &val)) < 0)
return res; return res;
pw_log_debug("u8: %u", val); pw_log_debug("%u: u8: %u", o, val);
break; break;
} }
case TAG_U32: case TAG_U32:
@ -623,7 +625,7 @@ static int message_dump(struct message *m)
uint32_t val; uint32_t val;
if ((res = read_u32(m, &val)) < 0) if ((res = read_u32(m, &val)) < 0)
return res; return res;
pw_log_debug("u32: %u", val); pw_log_debug("%u: u32: %u", o, val);
break; break;
} }
case TAG_S64: case TAG_S64:
@ -631,7 +633,7 @@ static int message_dump(struct message *m)
uint64_t val; uint64_t val;
if ((res = read_u64(m, &val)) < 0) if ((res = read_u64(m, &val)) < 0)
return res; return res;
pw_log_debug("s64: %"PRIi64"", (int64_t)val); pw_log_debug("%u: s64: %"PRIi64"", o, (int64_t)val);
break; break;
} }
case TAG_U64: case TAG_U64:
@ -639,7 +641,7 @@ static int message_dump(struct message *m)
uint64_t val; uint64_t val;
if ((res = read_u64(m, &val)) < 0) if ((res = read_u64(m, &val)) < 0)
return res; return res;
pw_log_debug("u64: %"PRIu64"", val); pw_log_debug("%u: u64: %"PRIu64"", o, val);
break; break;
} }
case TAG_USEC: case TAG_USEC:
@ -647,7 +649,7 @@ static int message_dump(struct message *m)
uint64_t val; uint64_t val;
if ((res = read_u64(m, &val)) < 0) if ((res = read_u64(m, &val)) < 0)
return res; return res;
pw_log_debug("u64: %"PRIu64"", val); pw_log_debug("%u: u64: %"PRIu64"", o, val);
break; break;
} }
case TAG_SAMPLE_SPEC: case TAG_SAMPLE_SPEC:
@ -655,7 +657,7 @@ static int message_dump(struct message *m)
struct sample_spec ss; struct sample_spec ss;
if ((res = read_sample_spec(m, &ss)) < 0) if ((res = read_sample_spec(m, &ss)) < 0)
return res; return res;
pw_log_debug("ss: format:%s rate:%d channels:%u", pw_log_debug("%u: ss: format:%s rate:%d channels:%u", o,
format_pa2name(ss.format), ss.rate, format_pa2name(ss.format), ss.rate,
ss.channels); ss.channels);
break; break;
@ -670,17 +672,17 @@ static int message_dump(struct message *m)
break; break;
} }
case TAG_BOOLEAN_TRUE: case TAG_BOOLEAN_TRUE:
pw_log_debug("bool: true"); pw_log_debug("%u: bool: true", o);
break; break;
case TAG_BOOLEAN_FALSE: case TAG_BOOLEAN_FALSE:
pw_log_debug("bool: false"); pw_log_debug("%u: bool: false", o);
break; break;
case TAG_TIMEVAL: case TAG_TIMEVAL:
{ {
struct timeval tv; struct timeval tv;
if ((res = read_timeval(m, &tv)) < 0) if ((res = read_timeval(m, &tv)) < 0)
return res; return res;
pw_log_debug("timeval: %lu:%lu", tv.tv_sec, tv.tv_usec); pw_log_debug("%u: timeval: %lu:%lu", o, tv.tv_sec, tv.tv_usec);
break; break;
} }
case TAG_CHANNEL_MAP: case TAG_CHANNEL_MAP:
@ -688,7 +690,7 @@ static int message_dump(struct message *m)
struct channel_map map; struct channel_map map;
if ((res = read_channel_map(m, &map)) < 0) if ((res = read_channel_map(m, &map)) < 0)
return res; return res;
pw_log_debug("channelmap: channels:%u", map.channels); pw_log_debug("%u: channelmap: channels:%u", o, map.channels);
for (i = 0; i < map.channels; i++) for (i = 0; i < map.channels; i++)
pw_log_debug(" %d: %s", i, channel_pa2name(map.map[i])); pw_log_debug(" %d: %s", i, channel_pa2name(map.map[i]));
break; break;
@ -698,7 +700,7 @@ static int message_dump(struct message *m)
struct volume vol; struct volume vol;
if ((res = read_cvolume(m, &vol)) < 0) if ((res = read_cvolume(m, &vol)) < 0)
return res; return res;
pw_log_debug("cvolume: channels:%u", vol.channels); pw_log_debug("%u: cvolume: channels:%u", o, vol.channels);
for (i = 0; i < vol.channels; i++) for (i = 0; i < vol.channels; i++)
pw_log_debug(" %d: %f", i, vol.values[i]); pw_log_debug(" %d: %f", i, vol.values[i]);
break; break;
@ -709,7 +711,7 @@ static int message_dump(struct message *m)
const struct spa_dict_item *it; const struct spa_dict_item *it;
if ((res = read_props(m, props)) < 0) if ((res = read_props(m, props)) < 0)
return res; return res;
pw_log_debug("props: n_items:%u", props->dict.n_items); pw_log_debug("%u: props: n_items:%u", o, props->dict.n_items);
spa_dict_for_each(it, &props->dict) spa_dict_for_each(it, &props->dict)
pw_log_debug(" '%s': '%s'", it->key, it->value); pw_log_debug(" '%s': '%s'", it->key, it->value);
pw_properties_free(props); pw_properties_free(props);
@ -720,7 +722,7 @@ static int message_dump(struct message *m)
float vol; float vol;
if ((res = read_volume(m, &vol)) < 0) if ((res = read_volume(m, &vol)) < 0)
return res; return res;
pw_log_debug("volume: %f", vol); pw_log_debug("%u: volume: %f", o, vol);
break; break;
} }
case TAG_FORMAT_INFO: case TAG_FORMAT_INFO:
@ -729,7 +731,7 @@ static int message_dump(struct message *m)
const struct spa_dict_item *it; const struct spa_dict_item *it;
if ((res = read_format_info(m, &info)) < 0) if ((res = read_format_info(m, &info)) < 0)
return res; return res;
pw_log_debug("format-info: n_items:%u", info.props->dict.n_items); pw_log_debug("%u: format-info: n_items:%u", o, info.props->dict.n_items);
spa_dict_for_each(it, &info.props->dict) spa_dict_for_each(it, &info.props->dict)
pw_log_debug(" '%s': '%s'", it->key, it->value); pw_log_debug(" '%s': '%s'", it->key, it->value);
break; break;