qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 13/51] sdlaudio: port to -audiodev config


From: Kővágó, Zoltán
Subject: [Qemu-devel] [PATCH 13/51] sdlaudio: port to -audiodev config
Date: Thu, 14 Jan 2016 14:45:26 +0100

Signed-off-by: Kővágó, Zoltán <address@hidden>
---
 audio/audio_legacy.c |  7 +++++++
 audio/sdlaudio.c     | 22 ++++------------------
 2 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index 3eab2b9..4d8e2b9 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -100,6 +100,11 @@ SimpleEnvMap pa_map[] = {
     { /* End of list */ }
 };
 
+SimpleEnvMap sdl_map[] = {
+    { "QEMU_SDL_SAMPLES", "buffer-len", ENV_TRANSFORM_SAMPLES_TO_USECS_OUT },
+    { /* End of list */ }
+};
+
 static unsigned long long toull(const char *str)
 {
     unsigned long long ret;
@@ -278,6 +283,8 @@ static void legacy_opt(const char *drv)
         handle_env_opts(opts, oss_map);
     } else if (strcmp(drv, "pa") == 0) {
         handle_env_opts(opts, pa_map);
+    } else if (strcmp(drv, "sdl") == 0) {
+        handle_env_opts(opts, sdl_map);
     }
 }
 
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index 580c613..796238a 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -44,18 +44,13 @@ typedef struct SDLVoiceOut {
     int decr;
 } SDLVoiceOut;
 
-static struct {
-    int nb_samples;
-} conf = {
-    .nb_samples = 1024
-};
-
 static struct SDLAudioState {
     int exit;
     SDL_mutex *mutex;
     SDL_sem *sem;
     int initialized;
     bool driver_created;
+    Audiodev *dev;
 } glob_sdl;
 typedef struct SDLAudioState SDLAudioState;
 
@@ -347,7 +342,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings 
*as,
     req.freq = as->freq;
     req.format = aud_to_sdlfmt (as->fmt);
     req.channels = as->nchannels;
-    req.samples = conf.nb_samples;
+    req.samples = audio_buffer_samples(s->dev->out, as, 11610);
     req.callback = sdl_callback;
     req.userdata = sdl;
 
@@ -420,6 +415,7 @@ static void *sdl_audio_init(Audiodev *dev)
     }
 
     s->driver_created = true;
+    s->dev = dev;
     return s;
 }
 
@@ -431,18 +427,9 @@ static void sdl_audio_fini (void *opaque)
     SDL_DestroyMutex (s->mutex);
     SDL_QuitSubSystem (SDL_INIT_AUDIO);
     s->driver_created = false;
+    s->dev = NULL;
 }
 
-static struct audio_option sdl_options[] = {
-    {
-        .name  = "SAMPLES",
-        .tag   = AUD_OPT_INT,
-        .valp  = &conf.nb_samples,
-        .descr = "Size of SDL buffer in samples"
-    },
-    { /* End of list */ }
-};
-
 static struct audio_pcm_ops sdl_pcm_ops = {
     .init_out = sdl_init_out,
     .fini_out = sdl_fini_out,
@@ -454,7 +441,6 @@ static struct audio_pcm_ops sdl_pcm_ops = {
 struct audio_driver sdl_audio_driver = {
     .name           = "sdl",
     .descr          = "SDL http://www.libsdl.org";,
-    .options        = sdl_options,
     .init           = sdl_audio_init,
     .fini           = sdl_audio_fini,
     .pcm_ops        = &sdl_pcm_ops,
-- 
2.7.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]