media-session: use session sample_rate and buffer_size as defaults

This commit is contained in:
Wim Taymans 2018-06-25 14:33:27 +02:00
parent bb7be076bb
commit 35e0399d97

View file

@ -462,8 +462,6 @@ static int handle_autoconnect(struct impl *impl, struct pw_node *node,
if (str == NULL || !pw_properties_parse_bool(str)) if (str == NULL || !pw_properties_parse_bool(str))
return 0; return 0;
sample_rate = DEFAULT_SAMPLE_RATE;
if ((media = pw_properties_get(props, PW_NODE_PROP_MEDIA)) == NULL) if ((media = pw_properties_get(props, PW_NODE_PROP_MEDIA)) == NULL)
media = "Audio"; media = "Audio";
@ -484,19 +482,6 @@ static int handle_autoconnect(struct impl *impl, struct pw_node *node,
else else
exclusive = false; exclusive = false;
buffer_size = MAX_BUFFER_SIZE;
if ((str = pw_properties_get(props, "node.latency")) != NULL) {
uint32_t num, denom;
pw_log_info("module %p: '%s'", impl, str);
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
buffer_size = flp2((num * denom / sample_rate) * sizeof(float));
}
}
pw_log_info("module %p: '%s' '%s' '%s' exclusive:%d quantum:%d/%d", impl,
media, category, role, exclusive,
sample_rate, buffer_size);
if (strcmp(media, "Audio") == 0) { if (strcmp(media, "Audio") == 0) {
if (strcmp(category, "Playback") == 0) if (strcmp(category, "Playback") == 0)
find.media_class = "Audio/Sink"; find.media_class = "Audio/Sink";
@ -520,6 +505,7 @@ static int handle_autoconnect(struct impl *impl, struct pw_node *node,
else else
find.path_id = SPA_ID_INVALID; find.path_id = SPA_ID_INVALID;
pw_log_debug("module %p: try to find and link to node '%d'", impl, find.path_id); pw_log_debug("module %p: try to find and link to node '%d'", impl, find.path_id);
find.impl = impl; find.impl = impl;
@ -532,6 +518,21 @@ static int handle_autoconnect(struct impl *impl, struct pw_node *node,
session = find.sess; session = find.sess;
sample_rate = session->sample_rate;
buffer_size = session->buffer_size;
if ((str = pw_properties_get(props, "node.latency")) != NULL) {
uint32_t num, denom;
pw_log_info("module %p: '%s'", impl, str);
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
buffer_size = flp2((num * sample_rate / denom) * sizeof(float));
}
}
pw_log_info("module %p: '%s' '%s' '%s' exclusive:%d quantum:%d/%d", impl,
media, category, role, exclusive,
sample_rate, buffer_size);
if (strcmp(category, "Capture") == 0) if (strcmp(category, "Capture") == 0)
direction = PW_DIRECTION_OUTPUT; direction = PW_DIRECTION_OUTPUT;
else if (strcmp(category, "Playback") == 0) else if (strcmp(category, "Playback") == 0)