From: Markus Armbruster <armbru@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] paaudio race condition on close
Date: Mon, 15 Dec 2014 10:08:07 +0100 [thread overview]
Message-ID: <87fvchffgo.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <CAFEAcA9YQR8A13oy07TfRC_q6LhyVP5YaWjniKLh1-WdKxOOPg@mail.gmail.com> (Peter Maydell's message of "Fri, 12 Dec 2014 16:47:46 +0000")
If Gerd (cc'ed) doesn't know, then I'm afraid nobody around here does.
Peter Maydell <peter.maydell@linaro.org> writes:
> There seems to be a race condition in the pulseaudio backend on
> closing of a voice...
>
> There are two threads involved here. The first one is a worker
> thread that just sits executing our qpa_thread_in() function
> to get input audio from PA and feed it to us. The second thread
> is QEMU itself (the cpu thread in the case of TCG), which calls
> AUD_close_in():
>
> #0 0x00007ffff054466b in pthread_join (threadid=140736709240576,
> thread_return=0x7fffdfdcc130)
> at pthread_join.c:92
> #1 0x00005555557def8f in audio_pt_join (p=0x7fffbc0195b8, arg=0x7fffdfdcc178,
> cap=0x555555b0dfd5 <__FUNCTION__.21892> "qpa_fini_in")
> at /home/petmay01/linaro/qemu-from-laptop/qemu/audio/audio_pt_int.c:166
> #2 0x00005555557ddec7 in qpa_fini_in (hw=0x7fffbc019520)
> at /home/petmay01/linaro/qemu-from-laptop/qemu/audio/paaudio.c:689
> #3 0x00005555557d3cab in audio_pcm_hw_gc_in (hwp=0x7fffbc032c28)
> at /home/petmay01/linaro/qemu-from-laptop/qemu/audio/audio_template.h:196
> #4 0x00005555557d432a in audio_close_in (sw=0x7fffbc032bd0)
> at /home/petmay01/linaro/qemu-from-laptop/qemu/audio/audio_template.h:375
> #5 0x00005555557d43bc in AUD_close_in (card=0x555556a29a08, sw=0x7fffbc032bd0)
> at /home/petmay01/linaro/qemu-from-laptop/qemu/audio/audio_template.h:387
>
> qpa_fini_in() basically sets a "done" flag in the PAVoiceIn struct,
> and prods the worker thread to make sure it exits before continuing.
> Usually this works. Unfortunately if the input thread is in the
> middle of actually writing to the buffer then things can go pear
> shaped, because the sample buffer itself is freed earlier, by
> audio_pcm_hw_gc_in():
>
> glue (s->nb_hw_voices_, TYPE) += 1;
> glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
> glue (hw->pcm_ops->fini_, TYPE) (hw);
>
> So we end up freeing hw resources (like the conv_buf) before we
> give the pulseaudio backend a chance to actually shut down its
> helper thread.
>
> Does anybody know how this is supposed to work? Is the fix as
> simple as just moving the free_resources call below the fini?
>
> thanks
> -- PMM
next prev parent reply other threads:[~2014-12-15 9:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 16:47 [Qemu-devel] paaudio race condition on close Peter Maydell
2014-12-15 9:08 ` Markus Armbruster [this message]
2014-12-15 9:23 ` Gerd Hoffmann
2014-12-15 15:37 ` Peter Maydell
2014-12-16 6:37 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvchffgo.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.