0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

linux-pulseaudio: Use DONT_MOVE for non-default devices

Ask the PA server to kindly not migrate our streams to the default
device unless the user chose the default device for input/output
captures.

Fixes #3211
This commit is contained in:
Kurt Kartaltepe 2022-10-07 18:35:43 -07:00 committed by Jim
parent 47fcaed8d3
commit 84687813e3

View File

@ -34,6 +34,7 @@ struct pulse_data {
/* user settings */
char *device;
bool is_default;
bool input;
/* server info */
@ -236,9 +237,9 @@ static void pulse_server_info(pa_context *c, const pa_server_info *i,
blog(LOG_INFO, "Server name: '%s %s'", i->server_name,
i->server_version);
if (data->device && strcmp("default", data->device) == 0) {
if (data->is_default) {
bfree(data->device);
if (data->input) {
bfree(data->device);
data->device = bstrdup(i->default_source_name);
blog(LOG_DEBUG, "Default input device: '%s'",
@ -249,7 +250,6 @@ static void pulse_server_info(pa_context *c, const pa_server_info *i,
strcat(monitor, i->default_sink_name);
strcat(monitor, ".monitor");
bfree(data->device);
data->device = bstrdup(monitor);
blog(LOG_DEBUG, "Default output device: '%s'",
@ -379,6 +379,8 @@ static int_fast32_t pulse_start_recording(struct pulse_data *data)
attr.tlength = (uint32_t)-1;
pa_stream_flags_t flags = PA_STREAM_ADJUST_LATENCY;
if (!data->is_default)
flags |= PA_STREAM_DONT_MOVE;
pulse_lock();
int_fast32_t ret = pa_stream_connect_record(data->stream, data->device,
@ -390,7 +392,12 @@ static int_fast32_t pulse_start_recording(struct pulse_data *data)
return -1;
}
blog(LOG_INFO, "Started recording from '%s'", data->device);
if (data->is_default)
blog(LOG_INFO, "Started recording from '%s' (default)",
data->device);
else
blog(LOG_INFO, "Started recording from '%s'", data->device);
return 0;
}
@ -547,6 +554,7 @@ static void pulse_update(void *vptr, obs_data_t *settings)
if (data->device)
bfree(data->device);
data->device = bstrdup(new_device);
data->is_default = strcmp("default", data->device) == 0;
restart = true;
}