[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 15/52] wavaudio: port to -audiodev config
From: |
Kővágó, Zoltán |
Subject: |
[Qemu-devel] [PATCH v2 15/52] wavaudio: port to -audiodev config |
Date: |
Sun, 23 Dec 2018 21:51:51 +0100 |
Signed-off-by: Kővágó, Zoltán <address@hidden>
---
audio/audio_legacy.c | 10 ++++++++
audio/wavaudio.c | 58 +++++++-------------------------------------
2 files changed, 19 insertions(+), 49 deletions(-)
diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index 6d95b761b8..71bbda04e2 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -110,6 +110,14 @@ SimpleEnvMap sdl_map[] = {
{ /* End of list */ }
};
+SimpleEnvMap wav_map[] = {
+ { "QEMU_WAV_FREQUENCY", "out.frequency" },
+ { "QEMU_WAV_FORMAT", "out.format", ENV_TRANSFORM_FMT },
+ { "QEMU_WAV_DAC_FIXED_CHANNELS", "out.channels" },
+ { "QEMU_WAV_PATH", "path" },
+ { /* End of list */ }
+};
+
static unsigned long long toull(const char *str)
{
unsigned long long ret;
@@ -290,6 +298,8 @@ static void legacy_opt(const char *drv)
handle_env_opts(opts, pa_map);
} else if (strcmp(drv, "sdl") == 0) {
handle_env_opts(opts, sdl_map);
+ } else if (strcmp(drv, "wav") == 0) {
+ handle_env_opts(opts, wav_map);
}
}
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index 9eff3555b3..214e30ccd9 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/host-utils.h"
#include "qemu/timer.h"
+#include "qapi/opts-visitor.h"
#include "audio.h"
#define AUDIO_CAP "wav"
@@ -37,11 +38,6 @@ typedef struct WAVVoiceOut {
int total_samples;
} WAVVoiceOut;
-typedef struct {
- struct audsettings settings;
- const char *wav_path;
-} WAVConf;
-
static int wav_run_out (HWVoiceOut *hw, int live)
{
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
@@ -112,8 +108,10 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings
*as,
0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04,
0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00
};
- WAVConf *conf = drv_opaque;
- struct audsettings wav_as = conf->settings;
+ Audiodev *dev = drv_opaque;
+ AudiodevWavOptions *wopts = &dev->u.wav;
+ struct audsettings wav_as = audiodev_to_audsettings(dev->out);
+ const char *wav_path = wopts->has_path ? wopts->path : "qemu.wav";
stereo = wav_as.nchannels == 2;
switch (wav_as.fmt) {
@@ -154,10 +152,10 @@ static int wav_init_out(HWVoiceOut *hw, struct
audsettings *as,
le_store (hdr + 28, hw->info.freq << (bits16 + stereo), 4);
le_store (hdr + 32, 1 << (bits16 + stereo), 2);
- wav->f = fopen (conf->wav_path, "wb");
+ wav->f = fopen(wav_path, "wb");
if (!wav->f) {
dolog ("Failed to open wave file `%s'\nReason: %s\n",
- conf->wav_path, strerror (errno));
+ wav_path, strerror(errno));
g_free (wav->pcm_buf);
wav->pcm_buf = NULL;
return -1;
@@ -225,54 +223,17 @@ static int wav_ctl_out (HWVoiceOut *hw, int cmd, ...)
return 0;
}
-static WAVConf glob_conf = {
- .settings.freq = 44100,
- .settings.nchannels = 2,
- .settings.fmt = AUDIO_FORMAT_S16,
- .wav_path = "qemu.wav"
-};
-
static void *wav_audio_init(Audiodev *dev)
{
- WAVConf *conf = g_malloc(sizeof(WAVConf));
- *conf = glob_conf;
- return conf;
+ assert(dev->driver == AUDIODEV_DRIVER_WAV);
+ return dev;
}
static void wav_audio_fini (void *opaque)
{
ldebug ("wav_fini");
- g_free(opaque);
}
-static struct audio_option wav_options[] = {
- {
- .name = "FREQUENCY",
- .tag = AUD_OPT_INT,
- .valp = &glob_conf.settings.freq,
- .descr = "Frequency"
- },
- {
- .name = "FORMAT",
- .tag = AUD_OPT_FMT,
- .valp = &glob_conf.settings.fmt,
- .descr = "Format"
- },
- {
- .name = "DAC_FIXED_CHANNELS",
- .tag = AUD_OPT_INT,
- .valp = &glob_conf.settings.nchannels,
- .descr = "Number of channels (1 - mono, 2 - stereo)"
- },
- {
- .name = "PATH",
- .tag = AUD_OPT_STR,
- .valp = &glob_conf.wav_path,
- .descr = "Path to wave file"
- },
- { /* End of list */ }
-};
-
static struct audio_pcm_ops wav_pcm_ops = {
.init_out = wav_init_out,
.fini_out = wav_fini_out,
@@ -284,7 +245,6 @@ static struct audio_pcm_ops wav_pcm_ops = {
static struct audio_driver wav_audio_driver = {
.name = "wav",
.descr = "WAV renderer http://wikipedia.org/wiki/WAV",
- .options = wav_options,
.init = wav_audio_init,
.fini = wav_audio_fini,
.pcm_ops = &wav_pcm_ops,
--
2.20.1
- [Qemu-devel] [PATCH v2 02/52] qapi: support nested structs in OptsVisitor, (continued)
- [Qemu-devel] [PATCH v2 02/52] qapi: support nested structs in OptsVisitor, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 07/52] alsaaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 09/52] dsoundaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 04/52] audio: use qapi AudioFormat instead of audfmt_e, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 08/52] coreaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 13/52] sdlaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 06/52] audio: -audiodev command line option basic implementation, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 14/52] spiceaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 12/52] paaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 10/52] noaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 15/52] wavaudio: port to -audiodev config,
Kővágó, Zoltán <=
- [Qemu-devel] [PATCH v2 16/52] audio: -audiodev command line option: cleanup, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 11/52] ossaudio: port to -audiodev config, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 17/52] audio: reduce glob_audio_state usage, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 21/52] paaudio: do not move stream when sink/source name is specified, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 22/52] paaudio: properly disconnect streams in fini_*, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 20/52] audio: audiodev= parameters no longer optional when -audiodev present, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 18/52] audio: basic support for multi backend audio, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 24/52] audio: do not run each backend in audio_run, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 19/52] audio: add audiodev properties to frontends, Kővágó, Zoltán, 2018/12/23
- [Qemu-devel] [PATCH v2 25/52] paaudio: fix playback glitches, Kővágó, Zoltán, 2018/12/23