qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Martin Schrodt <martin@schrodt.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Several fixes for the Pulse Audio driver, and the HDA device.
Date: Wed, 11 Oct 2017 08:10:42 +0200	[thread overview]
Message-ID: <1507702242.31518.1.camel@redhat.com> (raw)
In-Reply-To: <20171010171218.14298-1-martin@schrodt.org>

On Tue, 2017-10-10 at 19:12 +0200, Martin Schrodt wrote:
> Please see
> 
> https://www.reddit.com/r/VFIO/comments/74vokw/improved_pulse_audio_dr
> iver_for_qemu/
> 
> for motivation, and more coverage.
> 
> Changes:
> 
> - Remove PA reader/writer threads from paaudio.c, and do IO from the
> audio timer directly.
> - Add 1 millisecond timers which interface with the HDA device,
> pulling and pushing data
>   to and from it, to enable the guest driver to measure DMA timing by
> just looking the
>   LPIB registers.
> - Expose new configurable settings, such as TLENGTH and FRAGSIZE,
> plus settings to
>   enable PA_STREAM_ADJUST_LATENCY for input and output device
> separately.
> - Fix the input delay when first using the input device.

This needs splitting into smaller patches, probably at least one patch
per change listed here.  Also the description of each change should go
directly into the commit message, not into a link pointing to the web.

> diff --git a/audio/paaudio.c b/audio/paaudio.c
> index 65beb6f010..089af32e4d 100644
> --- a/audio/paaudio.c
> +++ b/audio/paaudio.c
> @@ -1,16 +1,44 @@
> -/* public domain */
> +/*
> + * QEMU ALSA audio driver
           ^^^^ ???

> + *
> + * Copyright (c) 2017 Martin Schrodt (spheenik)
> + *
> + * Permission is hereby granted, free of charge, to any person
> obtaining a copy
> + * of this software and associated documentation files (the
> "Software"), to deal
> + * in the Software without restriction, including without limitation
> the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense,
> and/or sell
> + * copies of the Software, and to permit persons to whom the
> Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
> SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
> OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> DEALINGS IN
> + * THE SOFTWARE.
> + */

Hmm.  Changing the licence of existing files need agreement from all
past authors.  This looks ok though, seems to be just the long version
of "public domain", so no actual change.  Should be a separate patch.

> +#ifdef PA_STREAM_ADJUST_LATENCY
> +    int adjust_latency_out;
> +    int adjust_latency_in;
> +#endif

Do you know which pa version added this?

If it is old enough we maybe can simply require it and don't need the
ifdefs here.

> +//    if (avail_bytes < max_bytes) {
> +//        dolog("avail: %d, wanted: %d \n", (int)avail_bytes,
> (int)max_bytes);
> +//    }

qemu has support for tracepoints (see docs/devel/tracing.txt) which are
 useful for this kind of debug messages.

> @@ -897,11 +779,37 @@ static void qpa_audio_fini (void *opaque)
>  
>  struct audio_option qpa_options[] = {
>      {
> -        .name  = "SAMPLES",
> +        .name  = "INT_BUF_SIZE",
>          .tag   = AUD_OPT_INT,
> -        .valp  = &glob_conf.samples,
> -        .descr = "buffer size in samples"
> +        .valp  = &glob_conf.buffer_size,
> +        .descr = "internal buffer size in frames"
>      },
> +    {
> +        .name  = "TLENGTH",
> +        .tag   = AUD_OPT_INT,
> +        .valp  = &glob_conf.tlength,
> +        .descr = "playback buffer target length in frames"
> +    },

What is the difference between these two?

> +    {
> +        .name  = "FRAGSIZE",
> +        .tag   = AUD_OPT_INT,
> +        .valp  = &glob_conf.fragsize,
> +        .descr = "fragment length of recording device in frames"
> +    },
> +#ifdef PA_STREAM_ADJUST_LATENCY
> +    {
> +        .name  = "ADJUST_LATENCY_OUT",
> +        .tag   = AUD_OPT_BOOL,
> +        .valp  = &glob_conf.adjust_latency_out,
> +        .descr = "let PA adjust latency for playback device"
> +    },
> +    {
> +        .name  = "ADJUST_LATENCY_IN",
> +        .tag   = AUD_OPT_BOOL,
> +        .valp  = &glob_conf.adjust_latency_in,
> +        .descr = "let PA adjust latency for recording device"
> +    },
> +#endif

What are the effects of enabling/disabling these settings?

> @@ -592,8 +733,9 @@ static const VMStateDescription
> vmstate_hda_audio_stream = {
>          VMSTATE_UINT32(gain_right, HDAAudioStream),
>          VMSTATE_BOOL(mute_left, HDAAudioStream),
>          VMSTATE_BOOL(mute_right, HDAAudioStream),
> -        VMSTATE_UINT32(bpos, HDAAudioStream),
>          VMSTATE_BUFFER(buf, HDAAudioStream),
> +        VMSTATE_INT64(rpos, HDAAudioStream),
> +        VMSTATE_INT64(wpos, HDAAudioStream),
>          VMSTATE_END_OF_LIST()
>      }

Oops.  vmstate changes break live migration.
Must figure something for backward compatibility here.

> -    if (st->ctl & (1 << 26)) {
> -        /*
> -         * Wait with the next DMA xfer until the guest
> -         * has acked the buffer completion interrupt
> -         */
> -        return false;
> -    }
> +//    if (st->ctl & (1 << 26)) {
> +//        /*
> +//         * Wait with the next DMA xfer until the guest
> +//         * has acked the buffer completion interrupt
> +//         */
> +//        return false;
> +//    }

Just drop the code, best as separate patch saying why it isn't needed
(any more) in the commit message.  There is always "git revert" in case
it turns out to be wrong, so no need to keep the code commented out.

cheers,
  Gerd

  parent reply	other threads:[~2017-10-11  6:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 17:12 [Qemu-devel] [PATCH] Several fixes for the Pulse Audio driver, and the HDA device Martin Schrodt
2017-10-10 23:15 ` no-reply
2017-10-11  6:10 ` Gerd Hoffmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-10-10 17:44 Martin Schrodt
2017-10-10 18:18 ` Eric Blake
2017-10-10 18:32   ` Martin Schrodt
2017-10-11 20:04     ` Paolo Bonzini
2017-10-10 23:16 ` no-reply
2017-10-10 17:45 qemu
2017-10-10 22:41 ` no-reply

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=1507702242.31518.1.camel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=martin@schrodt.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 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).