* [PATCH] dbus: add -audio dbus nsamples option
@ 2025-01-28 12:05 marcandre.lureau
2025-02-05 8:33 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: marcandre.lureau @ 2025-01-28 12:05 UTC (permalink / raw)
To: qemu-devel
Cc: Marc-André Lureau, Gerd Hoffmann, Eric Blake,
Markus Armbruster
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Allow to set the number of audio samples per read/write to dbus.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
qapi/audio.json | 22 +++++++++++++++++++++-
audio/dbusaudio.c | 21 ++++++++++++++++++---
ui/dbus-display1.xml | 12 ++++++++++++
3 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/qapi/audio.json b/qapi/audio.json
index 519697c0cd..dd5a58d13e 100644
--- a/qapi/audio.json
+++ b/qapi/audio.json
@@ -65,6 +65,26 @@
'*in': 'AudiodevPerDirectionOptions',
'*out': 'AudiodevPerDirectionOptions' } }
+##
+# @AudiodevDBusOptions:
+#
+# Options of the D-Bus audio backend.
+#
+# @in: options of the capture stream
+#
+# @out: options of the playback stream
+#
+# @nsamples: set the number of samples per read/write calls (default to 480,
+# 10ms at 48kHz).
+#
+# Since: 10.0
+##
+{ 'struct': 'AudiodevDBusOptions',
+ 'data': {
+ '*in': 'AudiodevPerDirectionOptions',
+ '*out': 'AudiodevPerDirectionOptions',
+ '*nsamples': 'uint32'} }
+
##
# @AudiodevAlsaPerDirectionOptions:
#
@@ -490,7 +510,7 @@
'if': 'CONFIG_AUDIO_ALSA' },
'coreaudio': { 'type': 'AudiodevCoreaudioOptions',
'if': 'CONFIG_AUDIO_COREAUDIO' },
- 'dbus': { 'type': 'AudiodevGenericOptions',
+ 'dbus': { 'type': 'AudiodevDBusOptions',
'if': 'CONFIG_DBUS_DISPLAY' },
'dsound': { 'type': 'AudiodevDsoundOptions',
'if': 'CONFIG_AUDIO_DSOUND' },
diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c
index af77e7cc33..b44fdd1511 100644
--- a/audio/dbusaudio.c
+++ b/audio/dbusaudio.c
@@ -43,9 +43,10 @@
#define DBUS_DISPLAY1_AUDIO_PATH DBUS_DISPLAY1_ROOT "/Audio"
-#define DBUS_AUDIO_NSAMPLES 1024 /* could be configured? */
+#define DBUS_DEFAULT_AUDIO_NSAMPLES 480
typedef struct DBusAudio {
+ Audiodev *dev;
GDBusObjectManagerServer *server;
bool p2p;
GDBusObjectSkeleton *audio;
@@ -151,6 +152,18 @@ dbus_init_out_listener(QemuDBusDisplay1AudioOutListener *listener,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
}
+static guint
+dbus_audio_get_nsamples(DBusAudio *da)
+{
+ AudiodevDBusOptions *opts = &da->dev->u.dbus;
+
+ if (opts->has_nsamples && opts->nsamples) {
+ return opts->nsamples;
+ } else {
+ return DBUS_DEFAULT_AUDIO_NSAMPLES;
+ }
+}
+
static int
dbus_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
{
@@ -160,7 +173,7 @@ dbus_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
QemuDBusDisplay1AudioOutListener *listener = NULL;
audio_pcm_init_info(&hw->info, as);
- hw->samples = DBUS_AUDIO_NSAMPLES;
+ hw->samples = dbus_audio_get_nsamples(da);
audio_rate_start(&vo->rate);
g_hash_table_iter_init(&iter, da->out_listeners);
@@ -274,7 +287,7 @@ dbus_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
QemuDBusDisplay1AudioInListener *listener = NULL;
audio_pcm_init_info(&hw->info, as);
- hw->samples = DBUS_AUDIO_NSAMPLES;
+ hw->samples = dbus_audio_get_nsamples(da);
audio_rate_start(&vo->rate);
g_hash_table_iter_init(&iter, da->in_listeners);
@@ -399,6 +412,7 @@ dbus_audio_init(Audiodev *dev, Error **errp)
{
DBusAudio *da = g_new0(DBusAudio, 1);
+ da->dev = dev;
da->out_listeners = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_object_unref);
da->in_listeners = g_hash_table_new_full(g_str_hash, g_str_equal,
@@ -652,6 +666,7 @@ dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server, bool p2p)
"swapped-signal::handle-register-out-listener",
dbus_audio_register_out_listener, s,
NULL);
+ qemu_dbus_display1_audio_set_nsamples(da->iface, dbus_audio_get_nsamples(da));
g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(da->audio),
G_DBUS_INTERFACE_SKELETON(da->iface));
diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml
index d702253431..72deefa455 100644
--- a/ui/dbus-display1.xml
+++ b/ui/dbus-display1.xml
@@ -773,6 +773,18 @@
<?endif?>
</method>
+ <!--
+ NSamples:
+
+ The number of samples per read/write frames. (for example the default is
+ 480, or 10ms at 48kHz)
+
+ (earlier version of the display interface do not provide this property)
+ -->
+ <property name="NSamples" type="u" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
+ </property>
+
<!--
Interfaces:
--
2.47.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dbus: add -audio dbus nsamples option
2025-01-28 12:05 [PATCH] dbus: add -audio dbus nsamples option marcandre.lureau
@ 2025-02-05 8:33 ` Markus Armbruster
2025-02-05 9:41 ` Marc-André Lureau
0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2025-02-05 8:33 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, Gerd Hoffmann, Eric Blake
marcandre.lureau@redhat.com writes:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Allow to set the number of audio samples per read/write to dbus.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> qapi/audio.json | 22 +++++++++++++++++++++-
> audio/dbusaudio.c | 21 ++++++++++++++++++---
> ui/dbus-display1.xml | 12 ++++++++++++
> 3 files changed, 51 insertions(+), 4 deletions(-)
>
> diff --git a/qapi/audio.json b/qapi/audio.json
> index 519697c0cd..dd5a58d13e 100644
> --- a/qapi/audio.json
> +++ b/qapi/audio.json
> @@ -65,6 +65,26 @@
> '*in': 'AudiodevPerDirectionOptions',
> '*out': 'AudiodevPerDirectionOptions' } }
>
> +##
> +# @AudiodevDBusOptions:
> +#
> +# Options of the D-Bus audio backend.
> +#
> +# @in: options of the capture stream
> +#
> +# @out: options of the playback stream
> +#
> +# @nsamples: set the number of samples per read/write calls (default to 480,
> +# 10ms at 48kHz).
Markup error. This is rendered like
"nsamples": "int" (optional)
set the number of samples per read/write calls (default to 480,
10ms at 48kHz).
Fix:
# @nsamples: set the number of samples per read/write calls
# (default to 480, 10ms at 48kHz).
I'm not sure I understand the parenthesis. I guess it means default
value is 480 samples per read/write call, which translates to 10ms when
sampling at 48kHz. Correct?
> +#
> +# Since: 10.0
> +##
> +{ 'struct': 'AudiodevDBusOptions',
> + 'data': {
> + '*in': 'AudiodevPerDirectionOptions',
> + '*out': 'AudiodevPerDirectionOptions',
> + '*nsamples': 'uint32'} }
> +
Could use 'base': 'AudiodevGenericOptions' instead of duplicating @in
and @out, but that would deviate from all the other AudiodevFOOOptions.
I agree with your decision.
> ##
> # @AudiodevAlsaPerDirectionOptions:
> #
> @@ -490,7 +510,7 @@
> 'if': 'CONFIG_AUDIO_ALSA' },
> 'coreaudio': { 'type': 'AudiodevCoreaudioOptions',
> 'if': 'CONFIG_AUDIO_COREAUDIO' },
> - 'dbus': { 'type': 'AudiodevGenericOptions',
> + 'dbus': { 'type': 'AudiodevDBusOptions',
> 'if': 'CONFIG_DBUS_DISPLAY' },
> 'dsound': { 'type': 'AudiodevDsoundOptions',
> 'if': 'CONFIG_AUDIO_DSOUND' },
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dbus: add -audio dbus nsamples option
2025-02-05 8:33 ` Markus Armbruster
@ 2025-02-05 9:41 ` Marc-André Lureau
0 siblings, 0 replies; 3+ messages in thread
From: Marc-André Lureau @ 2025-02-05 9:41 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, Gerd Hoffmann, Eric Blake
Hi
On Wed, Feb 5, 2025 at 12:33 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> marcandre.lureau@redhat.com writes:
>
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Allow to set the number of audio samples per read/write to dbus.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > qapi/audio.json | 22 +++++++++++++++++++++-
> > audio/dbusaudio.c | 21 ++++++++++++++++++---
> > ui/dbus-display1.xml | 12 ++++++++++++
> > 3 files changed, 51 insertions(+), 4 deletions(-)
> >
> > diff --git a/qapi/audio.json b/qapi/audio.json
> > index 519697c0cd..dd5a58d13e 100644
> > --- a/qapi/audio.json
> > +++ b/qapi/audio.json
> > @@ -65,6 +65,26 @@
> > '*in': 'AudiodevPerDirectionOptions',
> > '*out': 'AudiodevPerDirectionOptions' } }
> >
> > +##
> > +# @AudiodevDBusOptions:
> > +#
> > +# Options of the D-Bus audio backend.
> > +#
> > +# @in: options of the capture stream
> > +#
> > +# @out: options of the playback stream
> > +#
> > +# @nsamples: set the number of samples per read/write calls (default to 480,
> > +# 10ms at 48kHz).
>
> Markup error. This is rendered like
>
> "nsamples": "int" (optional)
> set the number of samples per read/write calls (default to 480,
>
> 10ms at 48kHz).
>
> Fix:
>
> # @nsamples: set the number of samples per read/write calls
> # (default to 480, 10ms at 48kHz).
>
ack, could you send a patch?
> I'm not sure I understand the parenthesis. I guess it means default
> value is 480 samples per read/write call, which translates to 10ms when
> sampling at 48kHz. Correct?
correct, feel free to improve the wording.
> > +#
> > +# Since: 10.0
> > +##
> > +{ 'struct': 'AudiodevDBusOptions',
> > + 'data': {
> > + '*in': 'AudiodevPerDirectionOptions',
> > + '*out': 'AudiodevPerDirectionOptions',
> > + '*nsamples': 'uint32'} }
> > +
>
> Could use 'base': 'AudiodevGenericOptions' instead of duplicating @in
> and @out, but that would deviate from all the other AudiodevFOOOptions.
> I agree with your decision.
>
> > ##
> > # @AudiodevAlsaPerDirectionOptions:
> > #
> > @@ -490,7 +510,7 @@
> > 'if': 'CONFIG_AUDIO_ALSA' },
> > 'coreaudio': { 'type': 'AudiodevCoreaudioOptions',
> > 'if': 'CONFIG_AUDIO_COREAUDIO' },
> > - 'dbus': { 'type': 'AudiodevGenericOptions',
> > + 'dbus': { 'type': 'AudiodevDBusOptions',
> > 'if': 'CONFIG_DBUS_DISPLAY' },
> > 'dsound': { 'type': 'AudiodevDsoundOptions',
> > 'if': 'CONFIG_AUDIO_DSOUND' },
>
> [...]
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-05 9:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-28 12:05 [PATCH] dbus: add -audio dbus nsamples option marcandre.lureau
2025-02-05 8:33 ` Markus Armbruster
2025-02-05 9:41 ` Marc-André Lureau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).