diff options
author | Chris Robinson <[email protected]> | 2014-05-14 03:22:42 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-05-14 03:22:42 -0700 |
commit | f311f74001a30b3d1f518764a4dce2b9333ee60a (patch) | |
tree | d6d46103485662126d260b1329772d3e8b8cb72f /Alc | |
parent | 1d2504d12e996a4c1e8fe9785901db9a9e3b4d7c (diff) |
Avoid freeing an in-use capture buffer
When stopping, ALSA may capture into its own storage buffer. Do not free
the storage buffer if it first reads from it.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/backends/alsa.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 749db892..d0677068 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -1167,16 +1167,14 @@ static ALCenum ALCcaptureAlsa_captureSamples(ALCcaptureAlsa *self, ALCvoid *buff memmove(buffer, self->buffer, amt); if(self->size > amt) - { memmove(self->buffer, self->buffer+amt, self->size - amt); - self->size -= amt; - } - else + else if(self->buffer != buffer) { + /* Do not free the buffer if it's reading into itself. */ free(self->buffer); self->buffer = NULL; - self->size = 0; } + self->size -= amt; amt = snd_pcm_bytes_to_frames(self->pcmHandle, amt); } else if(self->doCapture) |