|
@@ -13,6 +13,7 @@
|
|
#include "audio.h"
|
|
#include "audio.h"
|
|
#include <errno.h>
|
|
#include <errno.h>
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/error-report.h"
|
|
|
|
+#include "qapi/error.h"
|
|
#include <spa/param/audio/format-utils.h>
|
|
#include <spa/param/audio/format-utils.h>
|
|
#include <spa/utils/ringbuffer.h>
|
|
#include <spa/utils/ringbuffer.h>
|
|
#include <spa/utils/result.h>
|
|
#include <spa/utils/result.h>
|
|
@@ -736,7 +737,7 @@ static const struct pw_core_events core_events = {
|
|
};
|
|
};
|
|
|
|
|
|
static void *
|
|
static void *
|
|
-qpw_audio_init(Audiodev *dev)
|
|
|
|
|
|
+qpw_audio_init(Audiodev *dev, Error **errp)
|
|
{
|
|
{
|
|
g_autofree pwaudio *pw = g_new0(pwaudio, 1);
|
|
g_autofree pwaudio *pw = g_new0(pwaudio, 1);
|
|
|
|
|
|
@@ -748,19 +749,19 @@ qpw_audio_init(Audiodev *dev)
|
|
pw->dev = dev;
|
|
pw->dev = dev;
|
|
pw->thread_loop = pw_thread_loop_new("PipeWire thread loop", NULL);
|
|
pw->thread_loop = pw_thread_loop_new("PipeWire thread loop", NULL);
|
|
if (pw->thread_loop == NULL) {
|
|
if (pw->thread_loop == NULL) {
|
|
- error_report("Could not create PipeWire loop: %s", g_strerror(errno));
|
|
|
|
|
|
+ error_setg_errno(errp, errno, "Could not create PipeWire loop");
|
|
goto fail;
|
|
goto fail;
|
|
}
|
|
}
|
|
|
|
|
|
pw->context =
|
|
pw->context =
|
|
pw_context_new(pw_thread_loop_get_loop(pw->thread_loop), NULL, 0);
|
|
pw_context_new(pw_thread_loop_get_loop(pw->thread_loop), NULL, 0);
|
|
if (pw->context == NULL) {
|
|
if (pw->context == NULL) {
|
|
- error_report("Could not create PipeWire context: %s", g_strerror(errno));
|
|
|
|
|
|
+ error_setg_errno(errp, errno, "Could not create PipeWire context");
|
|
goto fail;
|
|
goto fail;
|
|
}
|
|
}
|
|
|
|
|
|
if (pw_thread_loop_start(pw->thread_loop) < 0) {
|
|
if (pw_thread_loop_start(pw->thread_loop) < 0) {
|
|
- error_report("Could not start PipeWire loop: %s", g_strerror(errno));
|
|
|
|
|
|
+ error_setg_errno(errp, errno, "Could not start PipeWire loop");
|
|
goto fail;
|
|
goto fail;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -769,13 +770,13 @@ qpw_audio_init(Audiodev *dev)
|
|
pw->core = pw_context_connect(pw->context, NULL, 0);
|
|
pw->core = pw_context_connect(pw->context, NULL, 0);
|
|
if (pw->core == NULL) {
|
|
if (pw->core == NULL) {
|
|
pw_thread_loop_unlock(pw->thread_loop);
|
|
pw_thread_loop_unlock(pw->thread_loop);
|
|
- goto fail;
|
|
|
|
|
|
+ goto fail_error;
|
|
}
|
|
}
|
|
|
|
|
|
if (pw_core_add_listener(pw->core, &pw->core_listener,
|
|
if (pw_core_add_listener(pw->core, &pw->core_listener,
|
|
&core_events, pw) < 0) {
|
|
&core_events, pw) < 0) {
|
|
pw_thread_loop_unlock(pw->thread_loop);
|
|
pw_thread_loop_unlock(pw->thread_loop);
|
|
- goto fail;
|
|
|
|
|
|
+ goto fail_error;
|
|
}
|
|
}
|
|
if (wait_resync(pw) < 0) {
|
|
if (wait_resync(pw) < 0) {
|
|
pw_thread_loop_unlock(pw->thread_loop);
|
|
pw_thread_loop_unlock(pw->thread_loop);
|
|
@@ -785,8 +786,9 @@ qpw_audio_init(Audiodev *dev)
|
|
|
|
|
|
return g_steal_pointer(&pw);
|
|
return g_steal_pointer(&pw);
|
|
|
|
|
|
|
|
+fail_error:
|
|
|
|
+ error_setg(errp, "Failed to initialize PW context");
|
|
fail:
|
|
fail:
|
|
- AUD_log(AUDIO_CAP, "Failed to initialize PW context");
|
|
|
|
if (pw->thread_loop) {
|
|
if (pw->thread_loop) {
|
|
pw_thread_loop_stop(pw->thread_loop);
|
|
pw_thread_loop_stop(pw->thread_loop);
|
|
}
|
|
}
|