[PATCH 07/10] hw/audio/virtio-sound: introduce virtio_snd_set_active()

Volker Rümelin posted 10 patches 10 months, 3 weeks ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Manos Pitsidianakis <manos.pitsidianakis@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>
There is a newer version of this series
[PATCH 07/10] hw/audio/virtio-sound: introduce virtio_snd_set_active()
Posted by Volker Rümelin 10 months, 3 weeks ago
Split out the function virtio_snd_pcm_set_active() from
virtio_snd_pcm_start_stop(). A later patch also needs this
new funcion. There is no functional change.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 hw/audio/virtio-snd.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index a1d2b3367e..16e8c49655 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -473,6 +473,21 @@ static void virtio_snd_pcm_open(VirtIOSoundPCMStream *stream)
     }
 }
 
+/*
+ * Activate/deactivate a stream.
+ *
+ * @stream: VirtIOSoundPCMStream *stream
+ * @active: whether to activate or deactivate the stream
+ */
+static void virtio_snd_pcm_set_active(VirtIOSoundPCMStream *stream, bool active)
+{
+    if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
+        AUD_set_active_out(stream->voice.out, active);
+    } else {
+        AUD_set_active_in(stream->voice.in, active);
+    }
+}
+
 /*
  * Close a stream and free all its resources.
  *
@@ -613,11 +628,7 @@ static uint32_t virtio_snd_pcm_start_stop(VirtIOSound *s,
         stream->state = VSND_PCMSTREAM_STATE_STOPPED;
     }
 
-    if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
-        AUD_set_active_out(stream->voice.out, start);
-    } else {
-        AUD_set_active_in(stream->voice.in, start);
-    }
+    virtio_snd_pcm_set_active(stream, start);
 
     return cpu_to_le32(VIRTIO_SND_S_OK);
 }
-- 
2.35.3


Re: [PATCH 07/10] hw/audio/virtio-sound: introduce virtio_snd_set_active()
Posted by Marc-André Lureau 10 months, 3 weeks ago
On Fri, Jan 5, 2024 at 12:34 AM Volker Rümelin <vr_qemu@t-online.de> wrote:
>
> Split out the function virtio_snd_pcm_set_active() from
> virtio_snd_pcm_start_stop(). A later patch also needs this
> new funcion. There is no functional change.
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  hw/audio/virtio-snd.c | 21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
> index a1d2b3367e..16e8c49655 100644
> --- a/hw/audio/virtio-snd.c
> +++ b/hw/audio/virtio-snd.c
> @@ -473,6 +473,21 @@ static void virtio_snd_pcm_open(VirtIOSoundPCMStream *stream)
>      }
>  }
>
> +/*
> + * Activate/deactivate a stream.
> + *
> + * @stream: VirtIOSoundPCMStream *stream
> + * @active: whether to activate or deactivate the stream
> + */
> +static void virtio_snd_pcm_set_active(VirtIOSoundPCMStream *stream, bool active)
> +{
> +    if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
> +        AUD_set_active_out(stream->voice.out, active);
> +    } else {
> +        AUD_set_active_in(stream->voice.in, active);
> +    }
> +}
> +
>  /*
>   * Close a stream and free all its resources.
>   *
> @@ -613,11 +628,7 @@ static uint32_t virtio_snd_pcm_start_stop(VirtIOSound *s,
>          stream->state = VSND_PCMSTREAM_STATE_STOPPED;
>      }
>
> -    if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
> -        AUD_set_active_out(stream->voice.out, start);
> -    } else {
> -        AUD_set_active_in(stream->voice.in, start);
> -    }
> +    virtio_snd_pcm_set_active(stream, start);
>
>      return cpu_to_le32(VIRTIO_SND_S_OK);
>  }
> --
> 2.35.3
>