mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-01-02 03:22:35 +00:00
audio: Allow PipeWire and PulseAudio streams to migrate to other sinks.
SDL still manages hotplug and default device management here, but if a user
wants to use an external tool, such as `pactl move-sink-input`, to put it
onto a different device, they probably know what they're doing and we
shouldn't stop them.
If this turns out to have some unexpected consequences, though, we can revisit
the change.
Fixes https://github.com/libsdl-org/sdl2-compat/issues/367
(cherry picked from commit 4c035a1fd8)
This commit is contained in:
@@ -1187,7 +1187,11 @@ static bool PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||
PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%i", device->sample_frames, device->spec.freq);
|
||||
PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%u", device->spec.freq);
|
||||
PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_ALWAYS_PROCESS, "true");
|
||||
PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_DONT_RECONNECT, "true"); // Requesting a specific device, don't migrate to new default hardware.
|
||||
|
||||
// UPDATE: This prevents users from moving the audio to a new sink (device) using standard tools. This is slightly in conflict
|
||||
// with how SDL wants to manage audio devices, but if people want to do it, we should let them, so this is commented out
|
||||
// for now. We might revisit later.
|
||||
//PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_DONT_RECONNECT, "true"); // Requesting a specific device, don't migrate to new default hardware.
|
||||
|
||||
if (node_id != PW_ID_ANY) {
|
||||
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
|
||||
|
||||
@@ -701,7 +701,10 @@ static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
PULSEAUDIO_pa_stream_set_state_callback(h->stream, PulseStreamStateChangeCallback, NULL);
|
||||
|
||||
// SDL manages device moves if the default changes, so don't ever let Pulse automatically migrate this stream.
|
||||
flags |= PA_STREAM_DONT_MOVE;
|
||||
// UPDATE: This prevents users from moving the audio to a new sink (device) using standard tools. This is slightly in conflict
|
||||
// with how SDL wants to manage audio devices, but if people want to do it, we should let them, so this is commented out
|
||||
// for now. We might revisit later.
|
||||
//flags |= PA_STREAM_DONT_MOVE;
|
||||
|
||||
const char *device_path = ((PulseDeviceHandle *) device->handle)->device_path;
|
||||
if (recording) {
|
||||
|
||||
Reference in New Issue
Block a user