alsa: capture devices don't need a mixbuf allocated.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 03 Aug 2016 01:00:30 -0400
changeset 10229 ac7e62852dab
parent 10228 d7ae395db9f2
child 10230 ef43b2e678d2
alsa: capture devices don't need a mixbuf allocated.
src/audio/alsa/SDL_alsa_audio.c
--- a/src/audio/alsa/SDL_alsa_audio.c	Wed Aug 03 00:31:08 2016 -0400
+++ b/src/audio/alsa/SDL_alsa_audio.c	Wed Aug 03 01:00:30 2016 -0400
@@ -700,13 +700,15 @@
     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);