Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/audio/wasapi/SDL_wasapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,7 @@ static bool mgmtthrtask_PrepDevice(void *userdata)

newspec.freq = waveformat->nSamplesPerSec;

if (device->recording && device->hidden->isplayback)
{
if (device->recording && device->hidden->isplayback) {
streamflags |= AUDCLNT_STREAMFLAGS_LOOPBACK;
}

Expand Down
16 changes: 11 additions & 5 deletions src/core/windows/SDL_immdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devn

if (!device) {
// handle is freed by SDL_IMMDevice_FreeDeviceHandle!
SDL_IMMDevice_HandleData *handle = (SDL_IMMDevice_HandleData *)SDL_malloc(sizeof(SDL_IMMDevice_HandleData));
SDL_IMMDevice_HandleData *handle = (SDL_IMMDevice_HandleData *)SDL_calloc(1, sizeof(*handle));
if (!handle) {
return NULL;
}
Expand All @@ -156,7 +156,7 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devn
SDL_free(handle);
return NULL;
}
SDL_memcpy(&handle->directsound_guid, dsoundguid, sizeof(GUID));
SDL_copyp(&handle->directsound_guid, dsoundguid);

SDL_AudioSpec spec;
SDL_zero(spec);
Expand All @@ -168,15 +168,21 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devn

if (!recording && supports_recording_playback_devices) {
// handle is freed by SDL_IMMDevice_FreeDeviceHandle!
SDL_IMMDevice_HandleData *recording_handle = (SDL_IMMDevice_HandleData *)SDL_malloc(sizeof(SDL_IMMDevice_HandleData));
SDL_IMMDevice_HandleData *recording_handle = (SDL_IMMDevice_HandleData *)SDL_malloc(sizeof(*recording_handle));
if (!recording_handle) {
return NULL;
}

SDL_memcpy(&recording_handle->directsound_guid, dsoundguid, sizeof(GUID));
recording_handle->immdevice_id = SDL_wcsdup(devid);
if (!recording_handle->immdevice_id) {
SDL_free(recording_handle);
return NULL;
}

SDL_copyp(&recording_handle->directsound_guid, dsoundguid);

if (!recording_handle->immdevice_id || !SDL_AddAudioDevice(true, devname, &spec, recording_handle)) {
if (!SDL_AddAudioDevice(true, devname, &spec, recording_handle)) {
SDL_free(recording_handle->immdevice_id);
SDL_free(recording_handle);
}
}
Expand Down
Loading