mirror of
https://github.com/xemu-project/xemu.git
synced 2026-07-11 01:24:41 +02:00
audio: keep vmstate handle with AudioState
QOM-ification continues. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
+8
-4
@@ -1622,6 +1622,9 @@ static void audio_state_init(Object *obj)
|
||||
QLIST_INIT(&s->hw_head_in);
|
||||
QLIST_INIT(&s->cap_head);
|
||||
s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s);
|
||||
|
||||
s->vmse = qemu_add_vm_change_state_handler(audio_vm_change_state_handler, s);
|
||||
assert(s->vmse != NULL);
|
||||
}
|
||||
|
||||
static void audio_state_finalize(Object *obj)
|
||||
@@ -1671,6 +1674,11 @@ static void audio_state_finalize(Object *obj)
|
||||
timer_free(s->ts);
|
||||
s->ts = NULL;
|
||||
}
|
||||
|
||||
if (s->vmse) {
|
||||
qemu_del_vm_change_state_handler(s->vmse);
|
||||
s->vmse = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static Object *get_audiodevs_root(void)
|
||||
@@ -1735,7 +1743,6 @@ static AudioState *audio_init(Audiodev *dev, Error **errp)
|
||||
{
|
||||
int done = 0;
|
||||
const char *drvname;
|
||||
VMChangeStateEntry *vmse;
|
||||
AudioState *s;
|
||||
struct audio_driver *driver;
|
||||
|
||||
@@ -1775,9 +1782,6 @@ static AudioState *audio_init(Audiodev *dev, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
vmse = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
|
||||
assert(vmse != NULL);
|
||||
|
||||
if (!object_property_try_add_child(get_audiodevs_root(), dev->id, OBJECT(s), errp)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -235,6 +235,7 @@ typedef struct AudioState {
|
||||
|
||||
bool timer_running;
|
||||
uint64_t timer_last;
|
||||
VMChangeStateEntry *vmse;
|
||||
} AudioState;
|
||||
|
||||
extern const struct mixeng_volume nominal_volume;
|
||||
|
||||
Reference in New Issue
Block a user