From 38f4b68ca7b4e22c3dd6c6cee33a818460fd1329 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 3 Aug 2016 01:00:30 -0400 Subject: [PATCH] alsa: capture devices don't need a mixbuf allocated. --- src/audio/alsa/SDL_alsa_audio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index ef3b4c706..810222636 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -700,13 +700,15 @@ ALSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) SDL_CalculateAudioSpec(&this->spec); /* Allocate mixing buffer */ - this->hidden->mixlen = this->spec.size; - this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { - ALSA_CloseDevice(this); - return SDL_OutOfMemory(); + if (!iscapture) { + this->hidden->mixlen = this->spec.size; + this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); + if (this->hidden->mixbuf == NULL) { + ALSA_CloseDevice(this); + return SDL_OutOfMemory(); + } + SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); } - SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); /* Switch to blocking mode for playback */ ALSA_snd_pcm_nonblock(pcm_handle, 0);