[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 03/14] audio: add audiodev property to vnc and wa
From: |
Kővágó, Zoltán |
Subject: |
[Qemu-devel] [PATCH v4 03/14] audio: add audiodev property to vnc and wav_capture |
Date: |
Mon, 19 Aug 2019 01:06:48 +0200 |
Signed-off-by: Kővágó, Zoltán <address@hidden>
---
Notes:
Changes from v2:
* audiodev parameter for wavcapture is now mandatory.
* removed some unnecessary qdict_haskey calls from hmp_wavcapture
ui/vnc.h | 2 ++
monitor/misc.c | 22 +++++++++++-----------
ui/vnc.c | 15 ++++++++++++++-
hmp-commands.hx | 11 ++++++-----
qemu-options.hx | 6 ++++++
5 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/ui/vnc.h b/ui/vnc.h
index 18f1b1d6d0..8643860967 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -182,6 +182,8 @@ struct VncDisplay
#ifdef CONFIG_VNC_SASL
VncDisplaySASL sasl;
#endif
+
+ AudioState *audio_state;
};
typedef struct VncTight {
diff --git a/monitor/misc.c b/monitor/misc.c
index 6b71059739..aef16f6cfb 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -1142,21 +1142,21 @@ static void hmp_stopcapture(Monitor *mon, const QDict
*qdict)
static void hmp_wavcapture(Monitor *mon, const QDict *qdict)
{
const char *path = qdict_get_str(qdict, "path");
- int has_freq = qdict_haskey(qdict, "freq");
- int freq = qdict_get_try_int(qdict, "freq", -1);
- int has_bits = qdict_haskey(qdict, "bits");
- int bits = qdict_get_try_int(qdict, "bits", -1);
- int has_channels = qdict_haskey(qdict, "nchannels");
- int nchannels = qdict_get_try_int(qdict, "nchannels", -1);
+ int freq = qdict_get_try_int(qdict, "freq", 44100);
+ int bits = qdict_get_try_int(qdict, "bits", 16);
+ int nchannels = qdict_get_try_int(qdict, "nchannels", 2);
+ const char *audiodev = qdict_get_str(qdict, "audiodev");
CaptureState *s;
+ AudioState *as = audio_state_by_name(audiodev);
+
+ if (!as) {
+ monitor_printf(mon, "Audiodev '%s' not found\n", audiodev);
+ return;
+ }
s = g_malloc0 (sizeof (*s));
- freq = has_freq ? freq : 44100;
- bits = has_bits ? bits : 16;
- nchannels = has_channels ? nchannels : 2;
-
- if (wav_start_capture(NULL, s, path, freq, bits, nchannels)) {
+ if (wav_start_capture(as, s, path, freq, bits, nchannels)) {
monitor_printf(mon, "Failed to add wave capture\n");
g_free (s);
return;
diff --git a/ui/vnc.c b/ui/vnc.c
index ed5e8aa5f8..649ce93cd2 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1224,7 +1224,7 @@ static void audio_add(VncState *vs)
ops.destroy = audio_capture_destroy;
ops.capture = audio_capture;
- vs->audio_cap = AUD_add_capture(NULL, &vs->as, &ops, vs);
+ vs->audio_cap = AUD_add_capture(vs->vd->audio_state, &vs->as, &ops, vs);
if (!vs->audio_cap) {
error_report("Failed to add audio capture");
}
@@ -3371,6 +3371,9 @@ static QemuOptsList qemu_vnc_opts = {
},{
.name = "non-adaptive",
.type = QEMU_OPT_BOOL,
+ },{
+ .name = "audiodev",
+ .type = QEMU_OPT_STRING,
},
{ /* end of list */ }
},
@@ -3808,6 +3811,7 @@ void vnc_display_open(const char *id, Error **errp)
const char *saslauthz;
int lock_key_sync = 1;
int key_delay_ms;
+ const char *audiodev;
if (!vd) {
error_setg(errp, "VNC display not active");
@@ -3993,6 +3997,15 @@ void vnc_display_open(const char *id, Error **errp)
}
vd->ledstate = 0;
+ audiodev = qemu_opt_get(opts, "audiodev");
+ if (audiodev) {
+ vd->audio_state = audio_state_by_name(audiodev);
+ if (!vd->audio_state) {
+ error_setg(errp, "Audiodev '%s' not found", audiodev);
+ goto fail;
+ }
+ }
+
device_id = qemu_opt_get(opts, "display");
if (device_id) {
int head = qemu_opt_get_number(opts, "head", 0);
diff --git a/hmp-commands.hx b/hmp-commands.hx
index bfa5681dd2..cfcc044ce4 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -819,16 +819,17 @@ ETEXI
{
.name = "wavcapture",
- .args_type = "path:F,freq:i?,bits:i?,nchannels:i?",
- .params = "path [frequency [bits [channels]]]",
+ .args_type = "path:F,audiodev:s,freq:i?,bits:i?,nchannels:i?",
+ .params = "path audiodev [frequency [bits [channels]]]",
.help = "capture audio to a wave file (default frequency=44100
bits=16 channels=2)",
.cmd = hmp_wavcapture,
},
STEXI
-@item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channels}]]]
+@item wavcapture @var{filename} @var{audiodev} [@var{frequency} [@var{bits}
[@var{channels}]]]
@findex wavcapture
-Capture audio into @var{filename}. Using sample rate @var{frequency}
-bits per sample @var{bits} and number of channels @var{channels}.
+Capture audio into @var{filename} from @var{audiodev}, using sample rate
+@var{frequency} bits per sample @var{bits} and number of channels
+@var{channels}.
Defaults:
@itemize @minus
diff --git a/qemu-options.hx b/qemu-options.hx
index 9621e934c0..a308e5f5aa 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1978,6 +1978,12 @@ can help the device and guest to keep up and not lose
events in case
events are arriving in bulk. Possible causes for the latter are flaky
network connections, or scripts for automated testing.
+@item audiodev=@var{audiodev}
+
+Use the specified @var{audiodev} when the VNC client requests audio
+transmission. When not using an -audiodev argument, this option must
+be omitted, otherwise is must be present and specify a valid audiodev.
+
@end table
ETEXI
--
2.22.0
- [Qemu-devel] [PATCH v4 00/14] Multiple simultaneous audio backends, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 02/14] audio: basic support for multi backend audio, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 03/14] audio: add audiodev property to vnc and wav_capture,
Kővágó, Zoltán <=
- [Qemu-devel] [PATCH v4 04/14] audio: add audiodev properties to frontends, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 07/14] paaudio: do not move stream when sink/source name is specified, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 06/14] audio: audiodev= parameters no longer optional when -audiodev present, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 08/14] paaudio: properly disconnect streams in fini_*, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 01/14] audio: reduce glob_audio_state usage, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 05/14] paaudio: prepare for multiple audiodev, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 11/14] paaudio: fix playback glitches, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 10/14] audio: do not run each backend in audio_run, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 12/14] audio: remove read and write pcm_ops, Kővágó, Zoltán, 2019/08/18
- [Qemu-devel] [PATCH v4 14/14] audio: fix memory leak reported by ASAN, Kővágó, Zoltán, 2019/08/18