fix: property inspector - always show channels/sample rate, show 'default' if unknown
- Removed duplicated/broken code from property parsing - Always shows Channels and Sample Rate for audio nodes - Shows 'default' if sample rate not available on node - Latency shows ms calculation when sample rate known - Added fallback: clock.rate, api.alsa.rate
This commit is contained in:
@@ -102,10 +102,22 @@ static void on_node_info(void *data, const struct pw_node_info *info) {
|
||||
const char *str;
|
||||
|
||||
str = spa_dict_lookup(info->props, "default.clock.rate");
|
||||
if (str) nobj->node.sample_rate = (uint32_t)atoi(str);
|
||||
if (str && strlen(str) > 0) nobj->node.sample_rate = (uint32_t)atoi(str);
|
||||
|
||||
str = spa_dict_lookup(info->props, "default.clock.quantum");
|
||||
if (str) nobj->node.quantum = (uint32_t)atoi(str);
|
||||
if (str && strlen(str) > 0) nobj->node.quantum = (uint32_t)atoi(str);
|
||||
|
||||
// Also try clock.rate (set on some devices)
|
||||
if (nobj->node.sample_rate == 0) {
|
||||
str = spa_dict_lookup(info->props, "clock.rate");
|
||||
if (str && strlen(str) > 0) nobj->node.sample_rate = (uint32_t)atoi(str);
|
||||
}
|
||||
|
||||
// Also try api.alsa.rate
|
||||
if (nobj->node.sample_rate == 0) {
|
||||
str = spa_dict_lookup(info->props, "api.alsa.rate");
|
||||
if (str && strlen(str) > 0) nobj->node.sample_rate = (uint32_t)atoi(str);
|
||||
}
|
||||
|
||||
str = spa_dict_lookup(info->props, "audio.channels");
|
||||
if (str) nobj->node.channels = (uint32_t)atoi(str);
|
||||
@@ -125,26 +137,31 @@ static void on_node_info(void *data, const struct pw_node_info *info) {
|
||||
str = spa_dict_lookup(info->props, "priority.driver");
|
||||
if (str) nobj->node.priority = atoi(str);
|
||||
|
||||
// Latency info
|
||||
// Latency: "256/48000" format
|
||||
str = spa_dict_lookup(info->props, "node.latency");
|
||||
if (str) {
|
||||
// Format: "256/48000" -> quantum=256 rate=48000
|
||||
uint32_t q = 0, r = 0;
|
||||
if (sscanf(str, "%u/%u", &q, &r) == 2) {
|
||||
nobj->node.quantum = q;
|
||||
nobj->node.sample_rate = r;
|
||||
if (nobj->node.quantum == 0) nobj->node.quantum = q;
|
||||
if (nobj->node.sample_rate == 0 && r > 0) nobj->node.sample_rate = r;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: read clock rate from device props
|
||||
// ALSA period size
|
||||
str = spa_dict_lookup(info->props, "api.alsa.period-size");
|
||||
if (str) nobj->node.rate = (uint32_t)atoi(str);
|
||||
|
||||
// Fallback: clock.rate
|
||||
if (nobj->node.sample_rate == 0) {
|
||||
str = spa_dict_lookup(info->props, "clock.rate");
|
||||
if (str) nobj->node.sample_rate = (uint32_t)atoi(str);
|
||||
}
|
||||
|
||||
// ALSA latency
|
||||
str = spa_dict_lookup(info->props, "api.alsa.period-size");
|
||||
if (str) nobj->node.rate = (uint32_t)atoi(str); // reuse rate field for period-size
|
||||
// Fallback: api.alsa.rate
|
||||
if (nobj->node.sample_rate == 0) {
|
||||
str = spa_dict_lookup(info->props, "api.alsa.rate");
|
||||
if (str) nobj->node.sample_rate = (uint32_t)atoi(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user