Audio: misc fixes for "Audio 20190821 patches", part two
cover Audio: misc fixes for "Audio 20190821 patches", part two
Hi,
This series contains some random fixes for the "Audio 20190821 patches":
a coverity bugfix and pulseaudio connection/stream names fix.
Since there wasn't a clear consensus about naming the pa streams, I've split it into two commits: the first time just uses the audiodev id unconditionally, while the last commit adds a new option to qapi to override it. This way we can easily drop the last commit if it turns out to be unnecessary.
Regards,
Zoltan
Kővágó, Zoltán (3):
audio: fix parameter dereference before NULL check
audio: paaudio: fix connection and stream name
audio: paaudio: ability to specify stream name
audio/audio_template.h | 7 +++++-- audio/paaudio.c | 9 ++++++--- qapi/audio.json | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-)
Signature · 1 line
2.23.0
PATCH 1/3 audio: fix parameter dereference before NULL check
This should fix Coverity issues CID 1405305 and 1405301.
--- audio/audio_template.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
audio/audio_template.h +5 -2
@@ -428,8 +428,8 @@ SW *glue (AUD_open_, TYPE) (struct audsettings *as ) { -AudioState *s = card->state; -AudiodevPerDirectionOptions *pdo =glue (audio_get_pdo_,TYPE )(s->dev); +AudioState *s; +AudiodevPerDirectionOptions *pdo;if (audio_bug (__func__, !card || !name || !callback_fn || !as)) { dolog ("card=%p name=%p callback_fn=%p as=%p\n",
@@ -437,6 +437,9 @@ SW *glue (AUD_open_, TYPE) ( goto fail; } + s = card->state; + pdo =glue (audio_get_pdo_,TYPE )(s->dev); +ldebug ("open %s, freq %d, nchannels %d, fmt %d\n" , name, as->freq, as->nchannels, as->fmt);
Signature · 1 line
2.23.0
PATCH 2/3 audio: paaudio: fix connection and stream name
In reply to Kővágó, ZoltánConnection name was previously erroneously set to the server socket path, while connection names were simply "qemu". After this patch, the connection name will be the vm name (falling back to "qemu" if not specified), while stream names will be the audiodev's id.
--- audio/paaudio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
audio/paaudio.c +6 -3
@@ -2,6 +2,7 @@#include "qemu/osdep.h" #include "qemu/module.h" +#include "qemu-common.h" #include "audio.h" #include "qapi/opts-visitor.h"
@@ -562,7 +563,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, pa->stream = qpa_simple_new ( c, - "qemu", + g->dev->id, PA_STREAM_PLAYBACK, ppdo->has_name ? ppdo->name : NULL, &ss,
@@ -630,7 +631,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) pa->stream = qpa_simple_new ( c, - "qemu", + g->dev->id, PA_STREAM_RECORD, ppdo->has_name ? ppdo->name : NULL, &ss,
@@ -857,6 +858,7 @@ static int qpa_validate_per_direction_opts(Audiodev *dev,/* common */ static void *qpa_conn_init (const char *server) { +const char *vm_name;PAConnection *c =g_malloc0 (sizeof (PAConnection));QTAILQ_INSERT_TAIL (&pa_conns, c, list);
@@ -865,8 +867,9 @@ static void *qpa_conn_init(const char *server) goto fail; } + vm_name =qemu_get_vm_name (); c->context =pa_context_new (pa_threaded_mainloop_get_api (c->mainloop), - server); + vm_name ? vm_name :"qemu" );if (!c->context) { goto fail; }
Signature · 1 line
2.23.0
PATCH 3/3 audio: paaudio: ability to specify stream name
In reply to Kővágó, ZoltánThis can be used to identify stream in tools like pavucontrol when one creates multiple -audiodevs or runs multiple qemu instances.
--- audio/paaudio.c | 4 ++-- qapi/audio.json | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-)
audio/paaudio.c +2 -2
@@ -563,7 +563,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, pa->stream = qpa_simple_new ( c, - g->dev->id, + ppdo->has_stream_name ? ppdo->stream_name : g->dev->id, PA_STREAM_PLAYBACK, ppdo->has_name ? ppdo->name : NULL, &ss,
@@ -631,7 +631,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) pa->stream = qpa_simple_new ( c, - g->dev->id, + ppdo->has_stream_name ? ppdo->stream_name : g->dev->id, PA_STREAM_RECORD, ppdo->has_name ? ppdo->name : NULL, &ss,
qapi/audio.json +6 -0
@@ -206,6 +206,11 @@ # # @name: name of the sink/source to use # +# @stream-name: name of the PulseAudio stream created by qemu. Can be +# used to identify the stream in PulseAudio when you +# create multiple PulseAudio devices or run multiple qemu +# instances (default: audiodev's id, since 4.2) +# # @latency: latency you want PulseAudio to achieve in microseconds # (default 15000) #
@@ -215,6 +220,7 @@ 'base': 'AudiodevPerDirectionOptions', 'data': { '*name': 'str', + '*stream-name': 'str', '*latency': 'uint32' } } ##
Signature · 1 line
2.23.0
Re: [Qemu-devel] [PATCH 3/3] audio: paaudio: ability to specify stream name
Quoted 48 lines · Zoltán
This can be used to identify stream in tools like pavucontrol when one creates multiple -audiodevs or runs multiple qemu instances.
Signed-off-by Kővágó, Zoltán <[email protected]>--- audio/paaudio.c | 4 ++-- qapi/audio.json | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-)audio/paaudio.c +2
-2@@ -563,7 +563,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, pa->stream = qpa_simple_new ( c, - g->dev->id, + ppdo->has_stream_name ? ppdo->stream_name : g->dev->id, PA_STREAM_PLAYBACK, ppdo->has_name ? ppdo->name : NULL, &ss,@@ -631,7 +631,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) pa->stream = qpa_simple_new ( c, - g->dev->id, + ppdo->has_stream_name ? ppdo->stream_name : g->dev->id, PA_STREAM_RECORD, ppdo->has_name ? ppdo->name : NULL, &ss,qapi/audio.json +5
-0@@ -206,6 +206,11 @@ # # @name: name of the sink/source to use # +# @stream-name: name of the PulseAudio stream created by qemu. Can be +# used to identify the stream in PulseAudio when you +# create multiple PulseAudio devices or run multiple qemu +# instances (default: audiodev's id, since 4.2) +# # @latency: latency you want PulseAudio to achieve in microseconds # (default 15000) #
qapi/audio.json line 226
Quoted 7 lines
qapi/audio.json +1
-0@@ -215,6 +220,7 @@ 'base': 'AudiodevPerDirectionOptions', 'data': { '*name': 'str', + '*stream-name': 'str', '*latency': 'uint32' } } ##
QAPI schema
Hi -- not sure what's happened with this patchset, but can we at least get the first patch (which fixes some coverity errors) in, even if the other two need more consideration?
(cc'ing Gerd as audio maintainer.)
thanks
-- PMM
Quoted 25 lines · Zoltán
Hi,
This series contains some random fixes for the "Audio 20190821 patches":
a coverity bugfix and pulseaudio connection/stream names fix.Since there wasn't a clear consensus about naming the pa streams, I've split it into two commits: the first time just uses the audiodev id unconditionally, while the last commit adds a new option to qapi to override it. This way we can easily drop the last commit if it turns out to be unnecessary.
Regards,
ZoltanKővágó, Zoltán (3):
audio: fix parameter dereference before NULL check
audio: paaudio: fix connection and stream name
audio: paaudio: ability to specify stream nameaudio/audio_template.h | 7 +++++-- audio/paaudio.c | 9 ++++++--- qapi/audio.json | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-)