diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/wavcapture.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/audio/wavcapture.c b/audio/wavcapture.c index d1a6f7ba78..d915fa02bf 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -34,22 +34,19 @@ static void wav_destroy (void *opaque) uint32_t datalen = wav->bytes; uint32_t rifflen = datalen + 36; - if (!wav->f) { - return; - } - - le_store (rlen, rifflen, 4); - le_store (dlen, datalen, 4); - - qemu_fseek (wav->f, 4, SEEK_SET); - qemu_put_buffer (wav->f, rlen, 4); - - qemu_fseek (wav->f, 32, SEEK_CUR); - qemu_put_buffer (wav->f, dlen, 4); - qemu_fclose (wav->f); - if (wav->path) { - qemu_free (wav->path); + if (wav->f) { + le_store (rlen, rifflen, 4); + le_store (dlen, datalen, 4); + + qemu_fseek (wav->f, 4, SEEK_SET); + qemu_put_buffer (wav->f, rlen, 4); + + qemu_fseek (wav->f, 32, SEEK_CUR); + qemu_put_buffer (wav->f, dlen, 4); + qemu_fclose (wav->f); } + + qemu_free (wav->path); } static void wav_capture (void *opaque, void *buf, int size) @@ -153,6 +150,8 @@ int wav_start_capture (CaptureState *s, const char *path, int freq, cap = AUD_add_capture (NULL, &as, &ops, wav); if (!cap) { term_printf ("Failed to add audio capture\n"); + qemu_free (wav->path); + qemu_fclose (wav->f); qemu_free (wav); return -1; } |