audio/sdl: replace custom logging with error_report
Replace the custom audio logging infrastructure (dolog macro and AUD_log/AUD_vlog) with standard QEMU error reporting (error_report, error_printf, error_vprintf). Note that we also dropped the abort() call in DEBUG_AUDIO, as it is not usually compiled with, doesn't help much, and can easily be added back when doing development as needed. Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Jan 20, 2026 at 20:13 UTC
b4d6c29b84a5dc933103bfd954e8e0ec76c891f4
1 file changed
+9
-27
audio/sdlaudio.c
+9
-27
@@ -26,6 +26,7 @@
26
#include <SDL.h>
27
#include <SDL_thread.h>
28
#include "qemu/module.h"
29
+#include "qemu/error-report.h"
30
#include "qapi/error.h"
31
#include "qemu/audio.h"
32
#include "qom/object.h"
@@ -38,7 +39,6 @@
39
#endif
40
#endif
41
41
-#define AUDIO_CAP "sdl"
42
#include "audio_int.h"
43
44
#define TYPE_AUDIO_SDL "audio-sdl"
@@ -67,17 +67,6 @@ typedef struct SDLVoiceIn {
67
SDL_AudioDeviceID devid;
68
} SDLVoiceIn;
69
70
-static void G_GNUC_PRINTF (1, 2) sdl_logerr (const char *fmt, ...)
71
-{
72
- va_list ap;
73
-
74
- va_start (ap, fmt);
75
- AUD_vlog (AUDIO_CAP, fmt, ap);
76
- va_end (ap);
77
-
78
- AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ());
79
-}
80
-
70
static int aud_to_sdlfmt (AudioFormat fmt)
71
{
72
switch (fmt) {
@@ -102,10 +91,7 @@ static int aud_to_sdlfmt (AudioFormat fmt)
91
return AUDIO_F32LSB;
92
93
default:
105
- dolog ("Internal logic error: Bad audio format %d\n", fmt);
106
-#ifdef DEBUG_AUDIO
107
- abort ();
108
-#endif
94
+ error_report("sdl: internal logic error: bad audio format %d", fmt);
95
return AUDIO_U8;
96
}
97
}
@@ -164,7 +150,7 @@ static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, int *endianness)
150
break;
151
152
default:
167
- dolog ("Unrecognized SDL audio format %d\n", sdlfmt);
153
+ error_report("sdl: unrecognized audio format %d", sdlfmt);
154
return -1;
155
}
156
@@ -182,27 +168,27 @@ static SDL_AudioDeviceID sdl_open(SDL_AudioSpec *req, SDL_AudioSpec *obt,
168
/* Make sure potential threads created by SDL don't hog signals. */
169
err = sigfillset (&new);
170
if (err) {
185
- dolog ("sdl_open: sigfillset failed: %s\n", strerror (errno));
171
+ error_report("sdl: sigfillset failed: %s", strerror (errno));
172
return 0;
173
}
174
err = pthread_sigmask (SIG_BLOCK, &new, &old);
175
if (err) {
190
- dolog ("sdl_open: pthread_sigmask failed: %s\n", strerror (err));
176
+ error_report("sdl: pthread_sigmask failed: %s", strerror (err));
177
return 0;
178
}
179
#endif
180
181
devid = SDL_OpenAudioDevice(NULL, rec, req, obt, 0);
182
if (!devid) {
197
- sdl_logerr("SDL_OpenAudioDevice for %s failed\n",
198
- rec ? "recording" : "playback");
183
+ error_report("SDL_OpenAudioDevice for %s failed: %s",
184
+ rec ? "recording" : "playback", SDL_GetError());
185
}
186
187
#ifndef _WIN32
188
err = pthread_sigmask (SIG_SETMASK, &old, NULL);
189
if (err) {
204
- dolog ("sdl_open: pthread_sigmask (restore) failed: %s\n",
205
- strerror (errno));
190
+ error_report("sdl: pthread_sigmask (restore) failed: %s",
191
+ strerror (errno));
192
/* We have failed to restore original signal mask, all bets are off,
193
so exit the process */
194
exit (EXIT_FAILURE);
@@ -233,8 +219,6 @@ static void sdl_callback_out(void *opaque, Uint8 *buf, int len)
219
220
if (!sdl->exit) {
221
236
- /* dolog("callback_out: len=%d avail=%zu\n", len, hw->pending_emul); */
237
-
222
while (hw->pending_emul && len) {
223
size_t write_len, start;
224
@@ -283,8 +267,6 @@ static void sdl_callback_in(void *opaque, Uint8 *buf, int len)
267
return;
268
}
269
286
- /* dolog("callback_in: len=%d pending=%zu\n", len, hw->pending_emul); */
287
-
270
while (hw->pending_emul < hw->size_emul && len) {
271
size_t read_len = MIN(len, MIN(hw->size_emul - hw->pos_emul,
272
hw->size_emul - hw->pending_emul));