소스 검색

audio: Don't let simplified audio streams bind to new devices.

This can happen if you close the stream's underlying device directly, which
removes the binding but doesn't destroy the object.

In this case, the stream remains valid until destroyed, but still should not
be able to be bound to a new device.
Ryan C. Gordon 2 년 전
부모
커밋
40fb76196c
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      src/audio/SDL_audio.c

+ 2 - 0
src/audio/SDL_audio.c

@@ -1689,6 +1689,8 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
             SDL_assert((stream->bound_device == NULL) == ((stream->prev_binding == NULL) || (stream->next_binding == NULL)));
             if (stream->bound_device) {
                 retval = SDL_SetError("Stream #%d is already bound to a device", i);
+            } else if (stream->simplified) {  // You can get here if you closed the device instead of destroying the stream.
+                retval = SDL_SetError("Cannot change binding on a stream created with SDL_OpenAudioDeviceStream");
             }
         }