mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: handle 0 sink/source name or index as default
Some apps use 0 to get some sort of sink/source info. PulseAudio likely has a source/sink at index 0 but PipeWire certainly does not. Asking for 0 source/sink is always because of some hardcoded values in the app and we can return the default source/sink without causing any problems for other apps. See #756
This commit is contained in:
parent
80ce2c94ac
commit
3878ad921a
1 changed files with 8 additions and 4 deletions
|
|
@ -2104,7 +2104,7 @@ static int do_create_playback_stream(struct client *client, uint32_t command, ui
|
||||||
if (sink_name != NULL)
|
if (sink_name != NULL)
|
||||||
pw_properties_set(props,
|
pw_properties_set(props,
|
||||||
PW_KEY_NODE_TARGET, sink_name);
|
PW_KEY_NODE_TARGET, sink_name);
|
||||||
else if (sink_index != SPA_ID_INVALID)
|
else if (sink_index != SPA_ID_INVALID && sink_index != 0)
|
||||||
pw_properties_setf(props,
|
pw_properties_setf(props,
|
||||||
PW_KEY_NODE_TARGET, "%u", sink_index);
|
PW_KEY_NODE_TARGET, "%u", sink_index);
|
||||||
|
|
||||||
|
|
@ -2346,7 +2346,7 @@ static int do_create_record_stream(struct client *client, uint32_t command, uint
|
||||||
if ((id = atoi(source_name)) != 0)
|
if ((id = atoi(source_name)) != 0)
|
||||||
source_index = id;
|
source_index = id;
|
||||||
}
|
}
|
||||||
if (source_index != SPA_ID_INVALID) {
|
if (source_index != SPA_ID_INVALID && source_index != 0) {
|
||||||
if (source_index & MONITOR_FLAG)
|
if (source_index & MONITOR_FLAG)
|
||||||
source_index &= INDEX_MASK;
|
source_index &= INDEX_MASK;
|
||||||
pw_properties_setf(props,
|
pw_properties_setf(props,
|
||||||
|
|
@ -2749,6 +2749,9 @@ static struct pw_manager_object *find_device(struct client *client,
|
||||||
struct selector sel;
|
struct selector sel;
|
||||||
const char *def;
|
const char *def;
|
||||||
|
|
||||||
|
if (id == 0)
|
||||||
|
id = SPA_ID_INVALID;
|
||||||
|
|
||||||
if (name != NULL && !sink) {
|
if (name != NULL && !sink) {
|
||||||
if (pw_endswith(name, ".monitor")) {
|
if (pw_endswith(name, ".monitor")) {
|
||||||
name = strndupa(name, strlen(name)-8);
|
name = strndupa(name, strlen(name)-8);
|
||||||
|
|
@ -2778,7 +2781,8 @@ static struct pw_manager_object *find_device(struct client *client,
|
||||||
def = DEFAULT_SOURCE;
|
def = DEFAULT_SOURCE;
|
||||||
}
|
}
|
||||||
if (id == SPA_ID_INVALID &&
|
if (id == SPA_ID_INVALID &&
|
||||||
(sel.value == NULL || strcmp(sel.value, def) == 0))
|
(sel.value == NULL || strcmp(sel.value, def) == 0 ||
|
||||||
|
strcmp(sel.value, "0") == 0))
|
||||||
sel.value = get_default(client, sink);
|
sel.value = get_default(client, sink);
|
||||||
|
|
||||||
return select_object(client->manager, &sel);
|
return select_object(client->manager, &sel);
|
||||||
|
|
@ -4536,7 +4540,7 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st
|
||||||
|
|
||||||
if (command == COMMAND_GET_SINK_INFO || command == COMMAND_GET_SOURCE_INFO) {
|
if (command == COMMAND_GET_SINK_INFO || command == COMMAND_GET_SOURCE_INFO) {
|
||||||
if ((sel.value == NULL && sel.id == SPA_ID_INVALID) ||
|
if ((sel.value == NULL && sel.id == SPA_ID_INVALID) ||
|
||||||
(sel.value != NULL && strcmp(sel.value, def) == 0))
|
(sel.value != NULL && (strcmp(sel.value, def) == 0 || strcmp(sel.value, "0")) == 0))
|
||||||
sel.value = get_default(client, command == COMMAND_GET_SINK_INFO);
|
sel.value = get_default(client, command == COMMAND_GET_SINK_INFO);
|
||||||
} else {
|
} else {
|
||||||
if (sel.value == NULL && sel.id == SPA_ID_INVALID)
|
if (sel.value == NULL && sel.id == SPA_ID_INVALID)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue