[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 24/27] virtio-snd: Add code to device unrealize function
From: |
Shreyansh Chouhan |
Subject: |
[RFC PATCH 24/27] virtio-snd: Add code to device unrealize function |
Date: |
Thu, 29 Apr 2021 17:34:42 +0530 |
Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com>
---
hw/audio/virtio-snd.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index 5f12375d95..e2e47e9467 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -1006,8 +1006,34 @@ static void virtio_snd_device_realize(DeviceState *dev,
Error **errp)
}
}
+/*
+ * Frees the resources allocated to the device and then frees the device
+ * itself.
+ *
+ * @dev: VirtIOSound card device
+ */
static void virtio_snd_device_unrealize(DeviceState *dev)
{
+ VirtIOSound *s = VIRTIO_SOUND(dev);
+
+ for (int i = 0; i < s->snd_conf.streams; i++) {
+ virtio_snd_pcm_release_impl(s, i);
+ g_free(s->pcm_params[i]);
+ s->pcm_params[i] = NULL;
+ }
+ g_free(s->streams);
+ s->streams = NULL;
+ g_free(s->pcm_params);
+ s->pcm_params = NULL;
+
+ for (int i = 0; i < s->snd_conf.jacks; i++) {
+ g_free(s->jacks[i]);
+ s->jacks[i] = NULL;
+ }
+ g_free(s->jacks);
+ s->jacks = NULL;
+
+ virtio_delete_queue(s->ctrl_vq);
}
static void virtio_snd_reset(VirtIODevice *vdev)
--
2.25.1
- [RFC PATCH 18/27] virtio-snd: Add default configs to realize fn, (continued)
- [RFC PATCH 18/27] virtio-snd: Add default configs to realize fn, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 16/27] virtio-snd: Add VIRITO_SND_R_PCM_SET_PARAMS handle, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 21/27] virtio-snd: Add VIRTIO_SND_R_PCM_STOP handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 20/27] virtio-snd: Add VIRITO_SND_R_PCM_START handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 17/27] virtio-snd: Add VIRTIO_SND_R_PCM_PREPARE handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 19/27] virtio-snd: Add callback for SWVoiceOut, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 23/27] virtio-snd: Replaced goto with if else, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 22/27] virtio-snd: Add VIRTIO_SND_R_PCM_RELEASE handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 25/27] virtio-snd: Add tx vq and handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 24/27] virtio-snd: Add code to device unrealize function,
Shreyansh Chouhan <=
- [RFC PATCH 27/27] virtio-snd: Add rx vq and stub handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 26/27] virtio-snd: Add event vq and a handler stub, Shreyansh Chouhan, 2021/04/29
- Re: [RFC PATCH 00/27] Virtio sound card implementation, no-reply, 2021/04/29
- Re: [RFC PATCH 00/27] Virtio sound card implementation, Gerd Hoffmann, 2021/04/30