[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 11/14] sdlaudio: port to -audiodev config
From: |
Kővágó, Zoltán |
Subject: |
[Qemu-devel] [PATCH v6 11/14] sdlaudio: port to -audiodev config |
Date: |
Fri, 8 Mar 2019 23:34:22 +0100 |
Signed-off-by: Kővágó, Zoltán <address@hidden>
---
audio/audio_legacy.c | 12 ++++++++++++
audio/sdlaudio.c | 22 ++++------------------
2 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index 8d7f1475b5..478cf76d5f 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -281,6 +281,14 @@ static void handle_pa(Audiodev *dev)
get_str("QEMU_PA_SERVER", &dev->u.pa.server, &dev->u.pa.has_server);
}
+/* SDL */
+static void handle_sdl(Audiodev *dev)
+{
+ /* SDL is output only */
+ get_samples_to_usecs("QEMU_SDL_SAMPLES", &dev->u.sdl.out->buffer_length,
+ &dev->u.sdl.out->has_buffer_length, dev->u.sdl.out);
+}
+
/* general */
static void handle_per_direction(
AudiodevPerDirectionOptions *pdo, const char *prefix)
@@ -342,6 +350,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)
handle_pa(e->dev);
break;
+ case AUDIODEV_DRIVER_SDL:
+ handle_sdl(e->dev);
+ break;
+
default:
break;
}
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index b9ae506a56..ff9248ba68 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -44,16 +44,11 @@ typedef struct SDLVoiceOut {
int decr;
} SDLVoiceOut;
-static struct {
- int nb_samples;
-} conf = {
- .nb_samples = 1024
-};
-
static struct SDLAudioState {
int exit;
int initialized;
bool driver_created;
+ Audiodev *dev;
} glob_sdl;
typedef struct SDLAudioState SDLAudioState;
@@ -271,7 +266,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->u.sdl.out, as, 11610);
req.callback = sdl_callback;
req.userdata = sdl;
@@ -329,6 +324,7 @@ static void *sdl_audio_init(Audiodev *dev)
}
s->driver_created = true;
+ s->dev = dev;
return s;
}
@@ -338,18 +334,9 @@ static void sdl_audio_fini (void *opaque)
sdl_close (s);
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,
@@ -361,7 +348,6 @@ static struct audio_pcm_ops sdl_pcm_ops = {
static 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.20.1
- [Qemu-devel] [PATCH v6 00/14] Audio patches, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 01/14] qapi: qapi for audio backends, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 03/14] audio: -audiodev command line option: documentation, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 02/14] audio: use qapi AudioFormat instead of audfmt_e, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 08/14] noaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 07/14] dsoundaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 06/14] coreaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 05/14] alsaaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 11/14] sdlaudio: port to -audiodev config,
Kővágó, Zoltán <=
- [Qemu-devel] [PATCH v6 09/14] ossaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 04/14] audio: -audiodev command line option basic implementation, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 10/14] paaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 14/14] audio: -audiodev command line option: cleanup, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 13/14] wavaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- [Qemu-devel] [PATCH v6 12/14] spiceaudio: port to -audiodev config, Kővágó, Zoltán, 2019/03/08
- Re: [Qemu-devel] [PATCH v6 00/14] Audio patches, no-reply, 2019/03/08