@samitouri / QOSamiQemu / commits / 513d4d071e

audio/wav: replace custom logging with error_report

Replace the custom audio logging infrastructure (dolog macro) with standard QEMU error reporting (error_report). Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.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:18 UTC 513d4d071ef75add2d310332e9f55860dec34261
1 file changed +13 -19
audio/wavaudio.c
+13 -19
@@ -24,10 +24,10 @@
24
25 #include "qemu/osdep.h"
26 #include "qemu/module.h"
27 +#include "qemu/error-report.h"
28 #include "qemu/audio.h"
29 #include "qom/object.h"
30
30 -#define AUDIO_CAP "wav"
31 #include "audio_int.h"
32
33 #define TYPE_AUDIO_WAV "audio-wav"
@@ -51,8 +51,8 @@ static size_t wav_write_out(HWVoiceOut *hw, void *buf, size_t len)
51 assert(bytes % hw->info.bytes_per_frame == 0);
52
53 if (bytes && fwrite(buf, bytes, 1, wav->f) != 1) {
54 - dolog("wav_write_out: fwrite of %" PRId64 " bytes failed\nReason: %s\n",
55 - bytes, strerror(errno));
54 + error_report("wav: fwrite of %" PRId64 " bytes failed: %s",
55 + bytes, strerror(errno));
56 }
57
58 wav->total_samples += bytes / hw->info.bytes_per_frame;
@@ -98,11 +98,11 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as)
98
99 case AUDIO_FORMAT_S32:
100 case AUDIO_FORMAT_U32:
101 - dolog ("WAVE files can not handle 32bit formats\n");
101 + error_report("wav: WAVE files cannot handle 32-bit formats");
102 return -1;
103
104 case AUDIO_FORMAT_F32:
105 - dolog("WAVE files can not handle float formats\n");
105 + error_report("wav: WAVE files cannot handle float formats");
106 return -1;
107
108 default:
@@ -122,14 +122,13 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as)
122
123 wav->f = fopen(wav_path, "wb");
124 if (!wav->f) {
125 - dolog ("Failed to open wave file `%s'\nReason: %s\n",
126 - wav_path, strerror(errno));
125 + error_report("wav: failed to open wave file '%s': %s",
126 + wav_path, strerror(errno));
127 return -1;
128 }
129
130 if (fwrite (hdr, sizeof (hdr), 1, wav->f) != 1) {
131 - dolog ("wav_init_out: failed to write header\nReason: %s\n",
132 - strerror(errno));
131 + error_report("wav: failed to write header: %s", strerror(errno));
132 return -1;
133 }
134
@@ -153,30 +152,25 @@ static void wav_fini_out (HWVoiceOut *hw)
152 le_store (dlen, datalen, 4);
153
154 if (fseek (wav->f, 4, SEEK_SET)) {
156 - dolog ("wav_fini_out: fseek to rlen failed\nReason: %s\n",
157 - strerror(errno));
155 + error_report("wav: fseek to rlen failed: %s", strerror(errno));
156 goto doclose;
157 }
158 if (fwrite (rlen, 4, 1, wav->f) != 1) {
161 - dolog ("wav_fini_out: failed to write rlen\nReason: %s\n",
162 - strerror (errno));
159 + error_report("wav: failed to write rlen: %s", strerror(errno));
160 goto doclose;
161 }
162 if (fseek (wav->f, 32, SEEK_CUR)) {
166 - dolog ("wav_fini_out: fseek to dlen failed\nReason: %s\n",
167 - strerror (errno));
163 + error_report("wav: fseek to dlen failed: %s", strerror(errno));
164 goto doclose;
165 }
166 if (fwrite (dlen, 4, 1, wav->f) != 1) {
171 - dolog ("wav_fini_out: failed to write dlen\nReaons: %s\n",
172 - strerror (errno));
167 + error_report("wav: failed to write dlen: %s", strerror(errno));
168 goto doclose;
169 }
170
171 doclose:
172 if (fclose (wav->f)) {
178 - dolog ("wav_fini_out: fclose %p failed\nReason: %s\n",
179 - wav->f, strerror (errno));
173 + error_report("wav: fclose failed: %s", strerror(errno));
174 }
175 wav->f = NULL;
176 }