[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/6] paaudio: drop recording stream in qpa_fini_in
From: |
Gerd Hoffmann |
Subject: |
[PULL 3/6] paaudio: drop recording stream in qpa_fini_in |
Date: |
Mon, 6 Jan 2020 13:52:33 +0100 |
From: Volker RĂ¼melin <address@hidden>
Every call to pa_stream_peek which returns a data length > 0
should have a corresponding pa_stream_drop. A call to qpa_read
does not necessarily call pa_stream_drop immediately after a
call to pa_stream_peek. Test in qpa_fini_in if a last
pa_stream_drop is needed.
This prevents following messages in the libvirt log file after
a recording stream gets closed and a new one opened.
pulseaudio: pa_stream_drop failed
pulseaudio: Reason: Bad state
pulseaudio: pa_stream_drop failed
pulseaudio: Reason: Bad state
To reproduce start qemu with
-audiodev pa,id=audio0,in.mixing-engine=off
and in the guest start and stop Audacity several times.
Signed-off-by: Volker RĂ¼melin <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
audio/paaudio.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/audio/paaudio.c b/audio/paaudio.c
index 55a91f898073..7db1dc15f09e 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -536,7 +536,6 @@ static void qpa_simple_disconnect(PAConnection *c,
pa_stream *stream)
{
int err;
- pa_threaded_mainloop_lock(c->mainloop);
/*
* wait until actually connects. workaround pa bug #247
* https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/247
@@ -550,7 +549,6 @@ static void qpa_simple_disconnect(PAConnection *c,
pa_stream *stream)
dolog("Failed to disconnect! err=%d\n", err);
}
pa_stream_unref(stream);
- pa_threaded_mainloop_unlock(c->mainloop);
}
static void qpa_fini_out (HWVoiceOut *hw)
@@ -558,8 +556,12 @@ static void qpa_fini_out (HWVoiceOut *hw)
PAVoiceOut *pa = (PAVoiceOut *) hw;
if (pa->stream) {
- qpa_simple_disconnect(pa->g->conn, pa->stream);
+ PAConnection *c = pa->g->conn;
+
+ pa_threaded_mainloop_lock(c->mainloop);
+ qpa_simple_disconnect(c, pa->stream);
pa->stream = NULL;
+ pa_threaded_mainloop_unlock(c->mainloop);
}
}
@@ -568,8 +570,20 @@ static void qpa_fini_in (HWVoiceIn *hw)
PAVoiceIn *pa = (PAVoiceIn *) hw;
if (pa->stream) {
- qpa_simple_disconnect(pa->g->conn, pa->stream);
+ PAConnection *c = pa->g->conn;
+
+ pa_threaded_mainloop_lock(c->mainloop);
+ if (pa->read_length) {
+ int r = pa_stream_drop(pa->stream);
+ if (r) {
+ qpa_logerr(pa_context_errno(c->context),
+ "pa_stream_drop failed\n");
+ }
+ pa->read_length = 0;
+ }
+ qpa_simple_disconnect(c, pa->stream);
pa->stream = NULL;
+ pa_threaded_mainloop_unlock(c->mainloop);
}
}
--
2.18.1
- [PULL 0/6] Audio 20200106 patches, Gerd Hoffmann, 2020/01/06
- [PULL 2/6] hda-codec: fix recording rate control, Gerd Hoffmann, 2020/01/06
- [PULL 4/6] paaudio: try to drain the recording stream, Gerd Hoffmann, 2020/01/06
- [PULL 1/6] hda-codec: fix playback rate control, Gerd Hoffmann, 2020/01/06
- [PULL 5/6] paaudio: wait until the recording stream is ready, Gerd Hoffmann, 2020/01/06
- [PULL 6/6] audio: fix integer overflow, Gerd Hoffmann, 2020/01/06
- [PULL 3/6] paaudio: drop recording stream in qpa_fini_in,
Gerd Hoffmann <=
- Re: [PULL 0/6] Audio 20200106 patches, Peter Maydell, 2020/01/06