[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-commits] [COMMIT d4b709c] Make AUD_init failure fatal
From: |
Anthony Liguori |
Subject: |
[Qemu-commits] [COMMIT d4b709c] Make AUD_init failure fatal |
Date: |
Tue, 12 May 2009 11:11:21 -0000 |
From: Paul Brook <address@hidden>
Failure to initialize the audio subsystem is not handled consistently.
Where it is handled it has guest visible effects, which is wrong.
We already have a "nosound" audio driver as a last resort, so trying to
proceed without an audio backend seems pointless.
Also protect against multiple calls to AUD_init so that this can be
pushed down into individual devices.
Signed-off-by: Paul Brook <address@hidden>
diff --git a/audio/audio.c b/audio/audio.c
index 3c311d7..84d9ae6 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1711,6 +1711,10 @@ AudioState *AUD_init (void)
const char *drvname;
AudioState *s = &glob_audio_state;
+ if (s->drv) {
+ return s;
+ }
+
LIST_INIT (&s->hw_head_out);
LIST_INIT (&s->hw_head_in);
LIST_INIT (&s->cap_head);
@@ -1718,8 +1722,7 @@ AudioState *AUD_init (void)
s->ts = qemu_new_timer (vm_clock, audio_timer, s);
if (!s->ts) {
- dolog ("Could not create audio timer\n");
- return NULL;
+ hw_error("Could not create audio timer\n");
}
audio_process_options ("AUDIO", audio_options);
@@ -1772,37 +1775,30 @@ AudioState *AUD_init (void)
if (!done) {
done = !audio_driver_init (s, &no_audio_driver);
if (!done) {
- dolog ("Could not initialize audio subsystem\n");
+ hw_error("Could not initialize audio subsystem\n");
}
else {
dolog ("warning: Using timer based audio emulation\n");
}
}
- if (done) {
- VMChangeStateEntry *e;
-
- if (conf.period.hertz <= 0) {
- if (conf.period.hertz < 0) {
- dolog ("warning: Timer period is negative - %d "
- "treating as zero\n",
- conf.period.hertz);
- }
- conf.period.ticks = 1;
- }
- else {
- conf.period.ticks = ticks_per_sec / conf.period.hertz;
- }
+ VMChangeStateEntry *e;
- e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler,
s);
- if (!e) {
- dolog ("warning: Could not register change state handler\n"
- "(Audio can continue looping even after stopping the
VM)\n");
+ if (conf.period.hertz <= 0) {
+ if (conf.period.hertz < 0) {
+ dolog ("warning: Timer period is negative - %d "
+ "treating as zero\n",
+ conf.period.hertz);
}
+ conf.period.ticks = 1;
+ } else {
+ conf.period.ticks = ticks_per_sec / conf.period.hertz;
}
- else {
- qemu_del_timer (s->ts);
- return NULL;
+
+ e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
+ if (!e) {
+ dolog ("warning: Could not register change state handler\n"
+ "(Audio can continue looping even after stopping the VM)\n");
}
LIST_INIT (&s->card_head);
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 9550413..3734aa9 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -107,12 +107,10 @@ static void audio_init(qemu_irq *pic)
AudioState *s;
s = AUD_init();
- if (s) {
- for (c = soundhw; c->name; ++c) {
- if (c->enabled) {
- if (c->isa) {
- c->init.init_isa(s, pic);
- }
+ for (c = soundhw; c->name; ++c) {
+ if (c->enabled) {
+ if (c->isa) {
+ c->init.init_isa(s, pic);
}
}
}
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index e7504c1..015c16b 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -472,10 +472,9 @@ static void audio_init (PCIBus *pci_bus)
AudioState *s;
s = AUD_init ();
- if (s) {
- for (c = soundhw; c->name; ++c) {
- if (c->enabled)
- c->init.init_pci (pci_bus, s);
+ for (c = soundhw; c->name; ++c) {
+ if (c->enabled) {
+ c->init.init_pci (pci_bus, s);
}
}
}
diff --git a/hw/musicpal.c b/hw/musicpal.c
index b698610..0c47e5d 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -428,10 +428,6 @@ static i2c_interface *musicpal_audio_init(qemu_irq irq)
int iomemtype;
audio = AUD_init();
- if (!audio) {
- AUD_log(audio_name, "No audio state\n");
- return NULL;
- }
s = qemu_mallocz(sizeof(musicpal_audio_state));
s->irq = irq;
diff --git a/hw/pc.c b/hw/pc.c
index 6b46427..fe9d644 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -791,16 +791,14 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
AudioState *s;
s = AUD_init ();
- if (s) {
- for (c = soundhw; c->name; ++c) {
- if (c->enabled) {
- if (c->isa) {
- c->init.init_isa (s, pic);
- }
- else {
- if (pci_bus) {
- c->init.init_pci (pci_bus, s);
- }
+ for (c = soundhw; c->name; ++c) {
+ if (c->enabled) {
+ if (c->isa) {
+ c->init.init_isa (s, pic);
+ }
+ else {
+ if (pci_bus) {
+ c->init.init_pci (pci_bus, s);
}
}
}
diff --git a/hw/spitz.c b/hw/spitz.c
index 3c155a4..e53a81d 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -744,8 +744,6 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
i2c_slave *wm;
audio = AUD_init();
- if (!audio)
- return;
/* Attach a WM8750 to the bus */
wm = wm8750_init(bus, audio);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-commits] [COMMIT d4b709c] Make AUD_init failure fatal,
Anthony Liguori <=