提交 0d9acba8 编写于 作者: P Paul Brook

Make AUD_init failure fatal

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: NPaul Brook <paul@codesourcery.com>
上级 f0f26a06
...@@ -1711,6 +1711,10 @@ AudioState *AUD_init (void) ...@@ -1711,6 +1711,10 @@ AudioState *AUD_init (void)
const char *drvname; const char *drvname;
AudioState *s = &glob_audio_state; AudioState *s = &glob_audio_state;
if (s->drv) {
return s;
}
LIST_INIT (&s->hw_head_out); LIST_INIT (&s->hw_head_out);
LIST_INIT (&s->hw_head_in); LIST_INIT (&s->hw_head_in);
LIST_INIT (&s->cap_head); LIST_INIT (&s->cap_head);
...@@ -1718,8 +1722,7 @@ AudioState *AUD_init (void) ...@@ -1718,8 +1722,7 @@ AudioState *AUD_init (void)
s->ts = qemu_new_timer (vm_clock, audio_timer, s); s->ts = qemu_new_timer (vm_clock, audio_timer, s);
if (!s->ts) { if (!s->ts) {
dolog ("Could not create audio timer\n"); hw_error("Could not create audio timer\n");
return NULL;
} }
audio_process_options ("AUDIO", audio_options); audio_process_options ("AUDIO", audio_options);
...@@ -1772,14 +1775,13 @@ AudioState *AUD_init (void) ...@@ -1772,14 +1775,13 @@ AudioState *AUD_init (void)
if (!done) { if (!done) {
done = !audio_driver_init (s, &no_audio_driver); done = !audio_driver_init (s, &no_audio_driver);
if (!done) { if (!done) {
dolog ("Could not initialize audio subsystem\n"); hw_error("Could not initialize audio subsystem\n");
} }
else { else {
dolog ("warning: Using timer based audio emulation\n"); dolog ("warning: Using timer based audio emulation\n");
} }
} }
if (done) {
VMChangeStateEntry *e; VMChangeStateEntry *e;
if (conf.period.hertz <= 0) { if (conf.period.hertz <= 0) {
...@@ -1789,8 +1791,7 @@ AudioState *AUD_init (void) ...@@ -1789,8 +1791,7 @@ AudioState *AUD_init (void)
conf.period.hertz); conf.period.hertz);
} }
conf.period.ticks = 1; conf.period.ticks = 1;
} } else {
else {
conf.period.ticks = ticks_per_sec / conf.period.hertz; conf.period.ticks = ticks_per_sec / conf.period.hertz;
} }
...@@ -1799,11 +1800,6 @@ AudioState *AUD_init (void) ...@@ -1799,11 +1800,6 @@ AudioState *AUD_init (void)
dolog ("warning: Could not register change state handler\n" dolog ("warning: Could not register change state handler\n"
"(Audio can continue looping even after stopping the VM)\n"); "(Audio can continue looping even after stopping the VM)\n");
} }
}
else {
qemu_del_timer (s->ts);
return NULL;
}
LIST_INIT (&s->card_head); LIST_INIT (&s->card_head);
register_savevm ("audio", 0, 1, audio_save, audio_load, s); register_savevm ("audio", 0, 1, audio_save, audio_load, s);
......
...@@ -107,7 +107,6 @@ static void audio_init(qemu_irq *pic) ...@@ -107,7 +107,6 @@ static void audio_init(qemu_irq *pic)
AudioState *s; AudioState *s;
s = AUD_init(); s = AUD_init();
if (s) {
for (c = soundhw; c->name; ++c) { for (c = soundhw; c->name; ++c) {
if (c->enabled) { if (c->enabled) {
if (c->isa) { if (c->isa) {
...@@ -116,7 +115,6 @@ static void audio_init(qemu_irq *pic) ...@@ -116,7 +115,6 @@ static void audio_init(qemu_irq *pic)
} }
} }
} }
}
} }
#endif #endif
......
...@@ -472,9 +472,8 @@ static void audio_init (PCIBus *pci_bus) ...@@ -472,9 +472,8 @@ static void audio_init (PCIBus *pci_bus)
AudioState *s; AudioState *s;
s = AUD_init (); s = AUD_init ();
if (s) {
for (c = soundhw; c->name; ++c) { for (c = soundhw; c->name; ++c) {
if (c->enabled) if (c->enabled) {
c->init.init_pci (pci_bus, s); c->init.init_pci (pci_bus, s);
} }
} }
......
...@@ -428,10 +428,6 @@ static i2c_interface *musicpal_audio_init(qemu_irq irq) ...@@ -428,10 +428,6 @@ static i2c_interface *musicpal_audio_init(qemu_irq irq)
int iomemtype; int iomemtype;
audio = AUD_init(); audio = AUD_init();
if (!audio) {
AUD_log(audio_name, "No audio state\n");
return NULL;
}
s = qemu_mallocz(sizeof(musicpal_audio_state)); s = qemu_mallocz(sizeof(musicpal_audio_state));
s->irq = irq; s->irq = irq;
......
...@@ -791,7 +791,6 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic) ...@@ -791,7 +791,6 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
AudioState *s; AudioState *s;
s = AUD_init (); s = AUD_init ();
if (s) {
for (c = soundhw; c->name; ++c) { for (c = soundhw; c->name; ++c) {
if (c->enabled) { if (c->enabled) {
if (c->isa) { if (c->isa) {
...@@ -805,7 +804,6 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic) ...@@ -805,7 +804,6 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
} }
} }
} }
}
} }
#endif #endif
......
...@@ -744,8 +744,6 @@ static void spitz_i2c_setup(PXA2xxState *cpu) ...@@ -744,8 +744,6 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
i2c_slave *wm; i2c_slave *wm;
audio = AUD_init(); audio = AUD_init();
if (!audio)
return;
/* Attach a WM8750 to the bus */ /* Attach a WM8750 to the bus */
wm = wm8750_init(bus, audio); wm = wm8750_init(bus, audio);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册