diff options
author | Yu Ning <yu.ning@intel.com> | 2015-08-18 12:10:47 +0800 |
---|---|---|
committer | Konstantinos Menychtas <kmenychtas@google.com> | 2015-08-26 06:41:27 +0000 |
commit | 6efc2fb4e2eba21b43a2b7758f93fe84a12cab35 (patch) | |
tree | 334c4f33a9ed3847f071164a969dd2cb5d3cc664 | |
parent | 7eb5edb304d37c06a4af63348295d7ec71057ef6 (diff) | |
download | qemu-android-6efc2fb4e2eba21b43a2b7758f93fe84a12cab35.tar.gz |
goldfish_audio: Do not quit QEMU when device fails to initialize
The goldfish audio device is useful but not essential to the Android
emulator. However, in the current implementation, any error during the
initialization of the output voice leads to immediate termination of
QEMU. On the other hand, when such an error occurs, the classic emulator
only prints a warning message and then continues booting.
This issue can be fixed by pretending a successful qdev realization,
i.e. dropping the error_setg() call from goldfish_audio_realize().
Otherwise, once QEMU is notified of the error, an exit() is inevitable.
In addition, move the MMIO initialization code to the beginning of
goldfish_audio_realize() to ensure its execution, because QEMU expects
this qdev to have a MMIO region. If MMIO setup is done in the very end,
any early return statement will result in an assertion error later on.
Change-Id: If0fc0f87553b52456931d9f7e144d91c8a0dac53
Signed-off-by: Yu Ning <yu.ning@intel.com>
-rw-r--r-- | hw/audio/goldfish_audio.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/hw/audio/goldfish_audio.c b/hw/audio/goldfish_audio.c index a2e83a25bf..ad1bf7b8fc 100644 --- a/hw/audio/goldfish_audio.c +++ b/hw/audio/goldfish_audio.c @@ -458,8 +458,20 @@ static void goldfish_audio_realize(DeviceState *dev, Error **errp) struct goldfish_audio_state *s = GOLDFISH_AUDIO(dev); struct audsettings as; + /* MMIO must be set up regardless of whether the initialization of input + * and output voices is successful or not. Otherwise, an assertion error + * will occur in sysbus_mmio_map_common() (hw/core/sysbus.c). + */ + memory_region_init_io(&s->iomem, OBJECT(s), &goldfish_audio_iomem_ops, s, + "goldfish_audio", 0x100); + sysbus_init_mmio(sbdev, &s->iomem); sysbus_init_irq(sbdev, &s->irq); + /* Skip all the rest if both audio input and output are disabled. */ + if (!s->output && !s->input) { + return; + } + AUD_register_card( "goldfish_audio", &s->card); as.freq = 44100; @@ -477,8 +489,7 @@ static void goldfish_audio_realize(DeviceState *dev, Error **errp) &as ); if (!s->voice) { - error_setg(errp, "opening audio output failed"); - return; + error_report("warning: opening audio output failed"); } } @@ -504,10 +515,6 @@ static void goldfish_audio_realize(DeviceState *dev, Error **errp) goldfish_audio_buff_init( &s->out_buffs[0] ); goldfish_audio_buff_init( &s->out_buffs[1] ); goldfish_audio_buff_init( &s->in_buff ); - - memory_region_init_io(&s->iomem, OBJECT(s), &goldfish_audio_iomem_ops, s, - "goldfish_audio", 0x100); - sysbus_init_mmio(sbdev, &s->iomem); } static Property goldfish_audio_properties[] = { |