瀏覽代碼

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
Ryan C. Gordon 3 周之前
父節點
當前提交
4c035a1fd8
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 5 1
      src/audio/pipewire/SDL_pipewire.c
  2. 4 1
      src/audio/pulseaudio/SDL_pulseaudio.c

+ 5 - 1
src/audio/pipewire/SDL_pipewire.c

@@ -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);

+ 4 - 1
src/audio/pulseaudio/SDL_pulseaudio.c

@@ -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) {