[PATCH 27/43] audio/sdl: replace custom logging with error_report

marcandre.lureau@redhat.com posted 43 patches 1 week, 6 days ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Christian Schoenebeck <qemu_oss@crudebyte.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Thomas Huth <huth@tuxfamily.org>, Alexandre Ratchov <alex@caoua.org>, Laurent Vivier <laurent@vivier.eu>, Manos Pitsidianakis <manos.pitsidianakis@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Alistair Francis <alistair@alistair23.me>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Peter Maydell <peter.maydell@linaro.org>
[PATCH 27/43] audio/sdl: replace custom logging with error_report
Posted by marcandre.lureau@redhat.com 1 week, 6 days ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

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.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 audio/sdlaudio.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index 4fb9abd66c3..bb667ef9525 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -26,6 +26,7 @@
 #include <SDL.h>
 #include <SDL_thread.h>
 #include "qemu/module.h"
+#include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu/audio.h"
 #include "qom/object.h"
@@ -38,7 +39,6 @@
 #endif
 #endif
 
-#define AUDIO_CAP "sdl"
 #include "audio_int.h"
 
 #define TYPE_AUDIO_SDL "audio-sdl"
@@ -67,15 +67,15 @@ typedef struct SDLVoiceIn {
     SDL_AudioDeviceID devid;
 } SDLVoiceIn;
 
-static void G_GNUC_PRINTF (1, 2) sdl_logerr (const char *fmt, ...)
+static void G_GNUC_PRINTF (1, 2) sdl_logerr(const char *fmt, ...)
 {
     va_list ap;
 
-    va_start (ap, fmt);
-    AUD_vlog (AUDIO_CAP, fmt, ap);
-    va_end (ap);
+    va_start(ap, fmt);
+    error_vprintf(fmt, ap);
+    va_end(ap);
 
-    AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ());
+    error_printf("Reason: %s\n", SDL_GetError());
 }
 
 static int aud_to_sdlfmt (AudioFormat fmt)
@@ -102,10 +102,7 @@ static int aud_to_sdlfmt (AudioFormat fmt)
         return AUDIO_F32LSB;
 
     default:
-        dolog ("Internal logic error: Bad audio format %d\n", fmt);
-#ifdef DEBUG_AUDIO
-        abort ();
-#endif
+        error_report("sdl: internal logic error: bad audio format %d", fmt);
         return AUDIO_U8;
     }
 }
@@ -164,7 +161,7 @@ static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, int *endianness)
         break;
 
     default:
-        dolog ("Unrecognized SDL audio format %d\n", sdlfmt);
+        error_report("sdl: unrecognized audio format %d", sdlfmt);
         return -1;
     }
 
@@ -182,12 +179,12 @@ static SDL_AudioDeviceID sdl_open(SDL_AudioSpec *req, SDL_AudioSpec *obt,
     /* Make sure potential threads created by SDL don't hog signals.  */
     err = sigfillset (&new);
     if (err) {
-        dolog ("sdl_open: sigfillset failed: %s\n", strerror (errno));
+        error_report("sdl: sigfillset failed: %s", strerror (errno));
         return 0;
     }
     err = pthread_sigmask (SIG_BLOCK, &new, &old);
     if (err) {
-        dolog ("sdl_open: pthread_sigmask failed: %s\n", strerror (err));
+        error_report("sdl: pthread_sigmask failed: %s", strerror (err));
         return 0;
     }
 #endif
@@ -201,8 +198,8 @@ static SDL_AudioDeviceID sdl_open(SDL_AudioSpec *req, SDL_AudioSpec *obt,
 #ifndef _WIN32
     err = pthread_sigmask (SIG_SETMASK, &old, NULL);
     if (err) {
-        dolog ("sdl_open: pthread_sigmask (restore) failed: %s\n",
-               strerror (errno));
+        error_report("sdl: pthread_sigmask (restore) failed: %s",
+                     strerror (errno));
         /* We have failed to restore original signal mask, all bets are off,
            so exit the process */
         exit (EXIT_FAILURE);
@@ -233,8 +230,6 @@ static void sdl_callback_out(void *opaque, Uint8 *buf, int len)
 
     if (!sdl->exit) {
 
-        /* dolog("callback_out: len=%d avail=%zu\n", len, hw->pending_emul); */
-
         while (hw->pending_emul && len) {
             size_t write_len, start;
 
@@ -283,8 +278,6 @@ static void sdl_callback_in(void *opaque, Uint8 *buf, int len)
         return;
     }
 
-    /* dolog("callback_in: len=%d pending=%zu\n", len, hw->pending_emul); */
-
     while (hw->pending_emul < hw->size_emul && len) {
         size_t read_len = MIN(len, MIN(hw->size_emul - hw->pos_emul,
                                        hw->size_emul - hw->pending_emul));
-- 
2.52.0