mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
audio: allow returning an error from the driver init
An error is already printed by audio_driver_init, but we can make it more precise if the driver can return an Error *. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
aaa6a6f93d
commit
f6061733a9
15 changed files with 48 additions and 27 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "qapi/qapi-visit-audio.h"
|
||||
#include "qapi/qapi-commands-audio.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/help_option.h"
|
||||
|
@ -1555,7 +1556,9 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)
|
|||
static int audio_driver_init(AudioState *s, struct audio_driver *drv,
|
||||
bool msg, Audiodev *dev)
|
||||
{
|
||||
s->drv_opaque = drv->init(dev);
|
||||
Error *local_err = NULL;
|
||||
|
||||
s->drv_opaque = drv->init(dev, &local_err);
|
||||
|
||||
if (s->drv_opaque) {
|
||||
if (!drv->pcm_ops->get_buffer_in) {
|
||||
|
@ -1572,8 +1575,12 @@ static int audio_driver_init(AudioState *s, struct audio_driver *drv,
|
|||
s->drv = drv;
|
||||
return 0;
|
||||
} else {
|
||||
if (msg) {
|
||||
dolog("Could not init `%s' audio driver\n", drv->name);
|
||||
if (!msg) {
|
||||
error_free(local_err);
|
||||
} else if (local_err) {
|
||||
error_report_err(local_err);
|
||||
} else {
|
||||
error_report("Could not init `%s' audio driver", drv->name);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue