Commit 0d9acba8fddbf970c7353083e6a60b47017ce3e4
1 parent
f0f26a06
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: Paul Brook <paul@codesourcery.com>
Showing
6 changed files
with
35 additions
and
50 deletions
audio/audio.c
@@ -1711,6 +1711,10 @@ AudioState *AUD_init (void) | @@ -1711,6 +1711,10 @@ AudioState *AUD_init (void) | ||
1711 | const char *drvname; | 1711 | const char *drvname; |
1712 | AudioState *s = &glob_audio_state; | 1712 | AudioState *s = &glob_audio_state; |
1713 | 1713 | ||
1714 | + if (s->drv) { | ||
1715 | + return s; | ||
1716 | + } | ||
1717 | + | ||
1714 | LIST_INIT (&s->hw_head_out); | 1718 | LIST_INIT (&s->hw_head_out); |
1715 | LIST_INIT (&s->hw_head_in); | 1719 | LIST_INIT (&s->hw_head_in); |
1716 | LIST_INIT (&s->cap_head); | 1720 | LIST_INIT (&s->cap_head); |
@@ -1718,8 +1722,7 @@ AudioState *AUD_init (void) | @@ -1718,8 +1722,7 @@ AudioState *AUD_init (void) | ||
1718 | 1722 | ||
1719 | s->ts = qemu_new_timer (vm_clock, audio_timer, s); | 1723 | s->ts = qemu_new_timer (vm_clock, audio_timer, s); |
1720 | if (!s->ts) { | 1724 | if (!s->ts) { |
1721 | - dolog ("Could not create audio timer\n"); | ||
1722 | - return NULL; | 1725 | + hw_error("Could not create audio timer\n"); |
1723 | } | 1726 | } |
1724 | 1727 | ||
1725 | audio_process_options ("AUDIO", audio_options); | 1728 | audio_process_options ("AUDIO", audio_options); |
@@ -1772,37 +1775,30 @@ AudioState *AUD_init (void) | @@ -1772,37 +1775,30 @@ AudioState *AUD_init (void) | ||
1772 | if (!done) { | 1775 | if (!done) { |
1773 | done = !audio_driver_init (s, &no_audio_driver); | 1776 | done = !audio_driver_init (s, &no_audio_driver); |
1774 | if (!done) { | 1777 | if (!done) { |
1775 | - dolog ("Could not initialize audio subsystem\n"); | 1778 | + hw_error("Could not initialize audio subsystem\n"); |
1776 | } | 1779 | } |
1777 | else { | 1780 | else { |
1778 | dolog ("warning: Using timer based audio emulation\n"); | 1781 | dolog ("warning: Using timer based audio emulation\n"); |
1779 | } | 1782 | } |
1780 | } | 1783 | } |
1781 | 1784 | ||
1782 | - if (done) { | ||
1783 | - VMChangeStateEntry *e; | ||
1784 | - | ||
1785 | - if (conf.period.hertz <= 0) { | ||
1786 | - if (conf.period.hertz < 0) { | ||
1787 | - dolog ("warning: Timer period is negative - %d " | ||
1788 | - "treating as zero\n", | ||
1789 | - conf.period.hertz); | ||
1790 | - } | ||
1791 | - conf.period.ticks = 1; | ||
1792 | - } | ||
1793 | - else { | ||
1794 | - conf.period.ticks = ticks_per_sec / conf.period.hertz; | ||
1795 | - } | 1785 | + VMChangeStateEntry *e; |
1796 | 1786 | ||
1797 | - e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); | ||
1798 | - if (!e) { | ||
1799 | - dolog ("warning: Could not register change state handler\n" | ||
1800 | - "(Audio can continue looping even after stopping the VM)\n"); | 1787 | + if (conf.period.hertz <= 0) { |
1788 | + if (conf.period.hertz < 0) { | ||
1789 | + dolog ("warning: Timer period is negative - %d " | ||
1790 | + "treating as zero\n", | ||
1791 | + conf.period.hertz); | ||
1801 | } | 1792 | } |
1793 | + conf.period.ticks = 1; | ||
1794 | + } else { | ||
1795 | + conf.period.ticks = ticks_per_sec / conf.period.hertz; | ||
1802 | } | 1796 | } |
1803 | - else { | ||
1804 | - qemu_del_timer (s->ts); | ||
1805 | - return NULL; | 1797 | + |
1798 | + e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); | ||
1799 | + if (!e) { | ||
1800 | + dolog ("warning: Could not register change state handler\n" | ||
1801 | + "(Audio can continue looping even after stopping the VM)\n"); | ||
1806 | } | 1802 | } |
1807 | 1803 | ||
1808 | LIST_INIT (&s->card_head); | 1804 | LIST_INIT (&s->card_head); |
hw/mips_jazz.c
@@ -107,12 +107,10 @@ static void audio_init(qemu_irq *pic) | @@ -107,12 +107,10 @@ static void audio_init(qemu_irq *pic) | ||
107 | AudioState *s; | 107 | AudioState *s; |
108 | 108 | ||
109 | s = AUD_init(); | 109 | s = AUD_init(); |
110 | - if (s) { | ||
111 | - for (c = soundhw; c->name; ++c) { | ||
112 | - if (c->enabled) { | ||
113 | - if (c->isa) { | ||
114 | - c->init.init_isa(s, pic); | ||
115 | - } | 110 | + for (c = soundhw; c->name; ++c) { |
111 | + if (c->enabled) { | ||
112 | + if (c->isa) { | ||
113 | + c->init.init_isa(s, pic); | ||
116 | } | 114 | } |
117 | } | 115 | } |
118 | } | 116 | } |
hw/mips_malta.c
@@ -472,10 +472,9 @@ static void audio_init (PCIBus *pci_bus) | @@ -472,10 +472,9 @@ static void audio_init (PCIBus *pci_bus) | ||
472 | AudioState *s; | 472 | AudioState *s; |
473 | 473 | ||
474 | s = AUD_init (); | 474 | s = AUD_init (); |
475 | - if (s) { | ||
476 | - for (c = soundhw; c->name; ++c) { | ||
477 | - if (c->enabled) | ||
478 | - c->init.init_pci (pci_bus, s); | 475 | + for (c = soundhw; c->name; ++c) { |
476 | + if (c->enabled) { | ||
477 | + c->init.init_pci (pci_bus, s); | ||
479 | } | 478 | } |
480 | } | 479 | } |
481 | } | 480 | } |
hw/musicpal.c
@@ -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) | ||
428 | int iomemtype; | 428 | int iomemtype; |
429 | 429 | ||
430 | audio = AUD_init(); | 430 | audio = AUD_init(); |
431 | - if (!audio) { | ||
432 | - AUD_log(audio_name, "No audio state\n"); | ||
433 | - return NULL; | ||
434 | - } | ||
435 | 431 | ||
436 | s = qemu_mallocz(sizeof(musicpal_audio_state)); | 432 | s = qemu_mallocz(sizeof(musicpal_audio_state)); |
437 | s->irq = irq; | 433 | s->irq = irq; |
hw/pc.c
@@ -791,16 +791,14 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic) | @@ -791,16 +791,14 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic) | ||
791 | AudioState *s; | 791 | AudioState *s; |
792 | 792 | ||
793 | s = AUD_init (); | 793 | s = AUD_init (); |
794 | - if (s) { | ||
795 | - for (c = soundhw; c->name; ++c) { | ||
796 | - if (c->enabled) { | ||
797 | - if (c->isa) { | ||
798 | - c->init.init_isa (s, pic); | ||
799 | - } | ||
800 | - else { | ||
801 | - if (pci_bus) { | ||
802 | - c->init.init_pci (pci_bus, s); | ||
803 | - } | 794 | + for (c = soundhw; c->name; ++c) { |
795 | + if (c->enabled) { | ||
796 | + if (c->isa) { | ||
797 | + c->init.init_isa (s, pic); | ||
798 | + } | ||
799 | + else { | ||
800 | + if (pci_bus) { | ||
801 | + c->init.init_pci (pci_bus, s); | ||
804 | } | 802 | } |
805 | } | 803 | } |
806 | } | 804 | } |
hw/spitz.c
@@ -744,8 +744,6 @@ static void spitz_i2c_setup(PXA2xxState *cpu) | @@ -744,8 +744,6 @@ static void spitz_i2c_setup(PXA2xxState *cpu) | ||
744 | i2c_slave *wm; | 744 | i2c_slave *wm; |
745 | 745 | ||
746 | audio = AUD_init(); | 746 | audio = AUD_init(); |
747 | - if (!audio) | ||
748 | - return; | ||
749 | /* Attach a WM8750 to the bus */ | 747 | /* Attach a WM8750 to the bus */ |
750 | wm = wm8750_init(bus, audio); | 748 | wm = wm8750_init(bus, audio); |
751 | 749 |